mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
Expiring message handling for groups
This commit is contained in:
parent
a5c89d8d5a
commit
49b9ec9914
@ -126,17 +126,9 @@ public class ThreadRecord extends DisplayRecord {
|
||||
@Override
|
||||
public CharSequence getDisplayBody(@NonNull Context context) {
|
||||
if (isGroupUpdateMessage()) {
|
||||
String body = getBody();
|
||||
if (!body.isEmpty()) {
|
||||
UpdateMessageData updateMessageData = UpdateMessageData.fromJSON(body);
|
||||
if (updateMessageData != null) {
|
||||
return UpdateMessageBuilder.buildGroupUpdateMessage(context, updateMessageData, null, isOutgoing(), false)
|
||||
.toString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return context.getString(R.string.groupUpdated);
|
||||
return lastMessage != null
|
||||
? lastMessage.getDisplayBody(context).toString()
|
||||
: context.getString(R.string.groupUpdated);
|
||||
} else if (isOpenGroupInvitation()) {
|
||||
return context.getString(R.string.communityInvitation);
|
||||
} else if (MmsSmsColumns.Types.isLegacyType(type)) {
|
||||
@ -159,22 +151,8 @@ public class ThreadRecord extends DisplayRecord {
|
||||
.put(NAME_KEY, getName())
|
||||
.format().toString();
|
||||
} else if (SmsDatabase.Types.isExpirationTimerUpdate(type)) {
|
||||
int seconds = (int) (getExpiresIn() / 1000);
|
||||
if (seconds <= 0) {
|
||||
return Phrase.from(context, R.string.disappearingMessagesTurnedOff)
|
||||
.put(NAME_KEY, getName())
|
||||
.format().toString();
|
||||
}
|
||||
|
||||
// Implied that disappearing messages is enabled..
|
||||
String time = ExpirationUtil.getExpirationDisplayValue(context, seconds);
|
||||
String disappearAfterWhat = getDisappearingMsgExpiryTypeString(context); // Disappear after send or read?
|
||||
return Phrase.from(context, R.string.disappearingMessagesSet)
|
||||
.put(NAME_KEY, getName())
|
||||
.put(TIME_KEY, time)
|
||||
.put(DISAPPEARING_MESSAGES_TYPE_KEY, disappearAfterWhat)
|
||||
.format().toString();
|
||||
|
||||
// Remove formatting on the message by calling .getString() on the SpannableString
|
||||
return lastMessage != null ? lastMessage.getDisplayBody(context).toString() : null;
|
||||
} else if (MmsSmsColumns.Types.isMediaSavedExtraction(type)) {
|
||||
return Phrase.from(context, R.string.attachmentsMediaSaved)
|
||||
.put(NAME_KEY, getName())
|
||||
|
@ -126,9 +126,11 @@ class ExpiringMessageManager(context: Context) : MessageExpirationManagerProtoco
|
||||
val groupId = message.groupPublicKey
|
||||
val duration = message.expiryMode.expiryMillis
|
||||
try {
|
||||
val serializedAddress = groupId?.let(::doubleEncodeGroupID)
|
||||
?: message.syncTarget?.takeIf { it.isNotEmpty() }
|
||||
?: message.recipient!!
|
||||
val serializedAddress = when {
|
||||
groupId == null -> message.syncTarget ?: message.recipient!!
|
||||
groupId.startsWith(IdPrefix.GROUP.value) -> groupId
|
||||
else -> doubleEncodeGroupID(groupId)
|
||||
}
|
||||
val address = fromSerialized(serializedAddress)
|
||||
val recipient = Recipient.from(context, address, false)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user