Implement UI and backend for sending story reactions.

Co-authored-by: Rashad Sookram <rashad@signal.org>
This commit is contained in:
Alex Hart
2022-03-16 13:44:54 -03:00
committed by Cody Henthorne
parent 7f4a12c179
commit 437c1e2f21
41 changed files with 689 additions and 343 deletions

View File

@@ -1479,7 +1479,23 @@ public class MmsDatabase extends MessageDatabase {
return new OutgoingExpirationUpdateMessage(recipient, timestamp, expiresIn);
}
OutgoingMediaMessage message = new OutgoingMediaMessage(recipient, body, attachments, timestamp, subscriptionId, expiresIn, viewOnce, distributionType, storyType, parentStoryId, quote, contacts, previews, mentions, networkFailures, mismatches);
OutgoingMediaMessage message = new OutgoingMediaMessage(recipient,
body,
attachments,
timestamp,
subscriptionId,
expiresIn,
viewOnce,
distributionType,
storyType,
parentStoryId,
Types.isStoryReaction(outboxType),
quote,
contacts,
previews,
mentions,
networkFailures,
mismatches);
if (Types.isSecureType(outboxType)) {
return new OutgoingSecureMediaMessage(message);
@@ -1675,6 +1691,10 @@ public class MmsDatabase extends MessageDatabase {
type |= Types.EXPIRATION_TIMER_UPDATE_BIT;
}
if (retrieved.isStoryReaction()) {
type |= Types.SPECIAL_TYPE_STORY_REACTION;
}
return insertMessageInbox(retrieved, "", threadId, type);
}
@@ -1779,6 +1799,10 @@ public class MmsDatabase extends MessageDatabase {
type |= Types.EXPIRATION_TIMER_UPDATE_BIT;
}
if (message.isStoryReaction()) {
type |= Types.SPECIAL_TYPE_STORY_REACTION;
}
Map<RecipientId, EarlyReceiptCache.Receipt> earlyDeliveryReceipts = earlyDeliveryReceiptCache.remove(message.getSentTimeMillis());
ContentValues contentValues = new ContentValues();

View File

@@ -45,20 +45,21 @@ public interface MmsSmsColumns {
* {@link #TOTAL_MASK}.
*
* <pre>
* _____________________________________ ENCRYPTION ({@link #ENCRYPTION_MASK})
* | _____________________________ SECURE MESSAGE INFORMATION (no mask, but look at {@link #SECURE_MESSAGE_BIT})
* | | ________________________ GROUPS (no mask, but look at {@link #GROUP_UPDATE_BIT})
* | | | _________________ KEY_EXCHANGE ({@link #KEY_EXCHANGE_MASK})
* | | | | _________ MESSAGE_ATTRIBUTES ({@link #MESSAGE_ATTRIBUTE_MASK})
* | | | | | ____ BASE_TYPE ({@link #BASE_TYPE_MASK})
* ___|___ _| _| ___|__ | __|_
* | | | | | | | | | || |
* 0000 0000 0000 0000 0000 0000 0000 0000
* _____________________________________________ SPECIAL TYPES (Story reactions) ({@link #SPECIAL_TYPES_MASK}
* | _____________________________________ ENCRYPTION ({@link #ENCRYPTION_MASK})
* | | _____________________________ SECURE MESSAGE INFORMATION (no mask, but look at {@link #SECURE_MESSAGE_BIT})
* | | | ________________________ GROUPS (no mask, but look at {@link #GROUP_UPDATE_BIT})
* | | | | _________________ KEY_EXCHANGE ({@link #KEY_EXCHANGE_MASK})
* | | | | | _________ MESSAGE_ATTRIBUTES ({@link #MESSAGE_ATTRIBUTE_MASK})
* | | | | | | ____ BASE_TYPE ({@link #BASE_TYPE_MASK})
* _| ___|___ _| _| ___|__ | __|_
* | | | | | | | | | | | || |
* 0000 0000 0000 0000 0000 0000 0000 0000 0000
* </pre>
*/
public static class Types {
protected static final long TOTAL_MASK = 0xFFFFFFFF;
protected static final long TOTAL_MASK = 0xFFFFFFFFFL;
// Base Types
protected static final long BASE_TYPE_MASK = 0x1F;
@@ -134,6 +135,18 @@ public interface MmsSmsColumns {
protected static final long ENCRYPTION_REMOTE_DUPLICATE_BIT = 0x04000000;
protected static final long ENCRYPTION_REMOTE_LEGACY_BIT = 0x02000000;
// Special message types
public static final long SPECIAL_TYPES_MASK = 0xF00000000L;
public static final long SPECIAL_TYPE_STORY_REACTION = 0x100000000L;
public static boolean isSpecialType(long type) {
return (type & SPECIAL_TYPES_MASK) != 0L;
}
public static boolean isStoryReaction(long type) {
return (type & SPECIAL_TYPE_STORY_REACTION) == SPECIAL_TYPE_STORY_REACTION;
}
public static boolean isDraftMessageType(long type) {
return (type & BASE_TYPE_MASK) == BASE_DRAFT_TYPE;
}