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
|
@Override
|
||||||
public CharSequence getDisplayBody(@NonNull Context context) {
|
public CharSequence getDisplayBody(@NonNull Context context) {
|
||||||
if (isGroupUpdateMessage()) {
|
if (isGroupUpdateMessage()) {
|
||||||
String body = getBody();
|
return lastMessage != null
|
||||||
if (!body.isEmpty()) {
|
? lastMessage.getDisplayBody(context).toString()
|
||||||
UpdateMessageData updateMessageData = UpdateMessageData.fromJSON(body);
|
: context.getString(R.string.groupUpdated);
|
||||||
if (updateMessageData != null) {
|
|
||||||
return UpdateMessageBuilder.buildGroupUpdateMessage(context, updateMessageData, null, isOutgoing(), false)
|
|
||||||
.toString();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return context.getString(R.string.groupUpdated);
|
|
||||||
} else if (isOpenGroupInvitation()) {
|
} else if (isOpenGroupInvitation()) {
|
||||||
return context.getString(R.string.communityInvitation);
|
return context.getString(R.string.communityInvitation);
|
||||||
} else if (MmsSmsColumns.Types.isLegacyType(type)) {
|
} else if (MmsSmsColumns.Types.isLegacyType(type)) {
|
||||||
@ -159,22 +151,8 @@ public class ThreadRecord extends DisplayRecord {
|
|||||||
.put(NAME_KEY, getName())
|
.put(NAME_KEY, getName())
|
||||||
.format().toString();
|
.format().toString();
|
||||||
} else if (SmsDatabase.Types.isExpirationTimerUpdate(type)) {
|
} else if (SmsDatabase.Types.isExpirationTimerUpdate(type)) {
|
||||||
int seconds = (int) (getExpiresIn() / 1000);
|
// Remove formatting on the message by calling .getString() on the SpannableString
|
||||||
if (seconds <= 0) {
|
return lastMessage != null ? lastMessage.getDisplayBody(context).toString() : null;
|
||||||
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();
|
|
||||||
|
|
||||||
} else if (MmsSmsColumns.Types.isMediaSavedExtraction(type)) {
|
} else if (MmsSmsColumns.Types.isMediaSavedExtraction(type)) {
|
||||||
return Phrase.from(context, R.string.attachmentsMediaSaved)
|
return Phrase.from(context, R.string.attachmentsMediaSaved)
|
||||||
.put(NAME_KEY, getName())
|
.put(NAME_KEY, getName())
|
||||||
|
@ -126,9 +126,11 @@ class ExpiringMessageManager(context: Context) : MessageExpirationManagerProtoco
|
|||||||
val groupId = message.groupPublicKey
|
val groupId = message.groupPublicKey
|
||||||
val duration = message.expiryMode.expiryMillis
|
val duration = message.expiryMode.expiryMillis
|
||||||
try {
|
try {
|
||||||
val serializedAddress = groupId?.let(::doubleEncodeGroupID)
|
val serializedAddress = when {
|
||||||
?: message.syncTarget?.takeIf { it.isNotEmpty() }
|
groupId == null -> message.syncTarget ?: message.recipient!!
|
||||||
?: message.recipient!!
|
groupId.startsWith(IdPrefix.GROUP.value) -> groupId
|
||||||
|
else -> doubleEncodeGroupID(groupId)
|
||||||
|
}
|
||||||
val address = fromSerialized(serializedAddress)
|
val address = fromSerialized(serializedAddress)
|
||||||
val recipient = Recipient.from(context, address, false)
|
val recipient = Recipient.from(context, address, false)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user