mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Implement link previews for group conversations
This commit is contained in:
parent
9d76b8bdf7
commit
e109df7525
@ -954,6 +954,41 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
content.isNeedsReceipt());
|
||||
|
||||
textMessage = new IncomingEncryptedMessage(textMessage, body);
|
||||
|
||||
List<Link> urls = LinkPreviewUtil.findWhitelistedUrls(body);
|
||||
int urlCount = urls.size();
|
||||
if (urlCount != 0) {
|
||||
IncomingMediaMessage mediaMessage = new IncomingMediaMessage(Address.fromExternal(context, content.getSender()),
|
||||
message.getTimestamp(), -1,
|
||||
message.getExpiresInSeconds() * 1000L, false,
|
||||
content.isNeedsReceipt(),
|
||||
message.getBody(),
|
||||
message.getGroupInfo(),
|
||||
message.getAttachments(),
|
||||
Optional.absent(),
|
||||
Optional.absent(),
|
||||
Optional.of(new ArrayList<>()),
|
||||
Optional.absent());
|
||||
LinkPreviewRepository lpr = new LinkPreviewRepository(context);
|
||||
final int[] count = { 0 };
|
||||
for (Link url : urls) {
|
||||
lpr.getLinkPreview(context, url.getUrl(), lp -> Util.runOnMain(() -> {
|
||||
int c = count[0];
|
||||
c = c + 1;
|
||||
count[0] = c;
|
||||
if (lp.isPresent()) {
|
||||
mediaMessage.getLinkPreviews().add(lp.get());
|
||||
}
|
||||
if (c == urlCount) {
|
||||
try {
|
||||
handleMediaMessage(content, mediaMessage, smsMessageId);
|
||||
} catch (Exception e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
Optional<InsertResult> insertResult = database.insertMessageInbox(textMessage);
|
||||
|
||||
if (insertResult.isPresent()) threadId = insertResult.get().getThreadId();
|
||||
@ -966,12 +1001,13 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
long messageServerID = messageServerIDOrNull.get();
|
||||
DatabaseFactory.getLokiMessageDatabase(context).setServerID(messageID, messageServerID);
|
||||
}
|
||||
}
|
||||
|
||||
if (threadId != null) {
|
||||
MessageNotifier.updateNotification(context, threadId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void acceptFriendRequestIfNeeded(@NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceContent content) {
|
||||
// If we get anything other than a friend request, we can assume that we have a session with the other user
|
||||
|
Loading…
x
Reference in New Issue
Block a user