mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Merge pull request #310 from RyanRory/open-group-date-handling
Fix Open Group Date Handling
This commit is contained in:
commit
9865bdeece
@ -396,8 +396,11 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
|
||||
if (position < 0) return -1;
|
||||
|
||||
MessageRecord record = getRecordForPositionOrThrow(position);
|
||||
|
||||
calendar.setTime(new Date(record.getDateSent()));
|
||||
if (record.getRecipient().getAddress().isOpenGroup()) {
|
||||
calendar.setTime(new Date(record.getDateReceived()));
|
||||
} else {
|
||||
calendar.setTime(new Date(record.getDateSent()));
|
||||
}
|
||||
return Util.hashCode(calendar.get(Calendar.YEAR), calendar.get(Calendar.DAY_OF_YEAR));
|
||||
}
|
||||
|
||||
|
@ -972,6 +972,14 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
public long insertMessageOutbox(@NonNull OutgoingMediaMessage message,
|
||||
long threadId, boolean forceSms,
|
||||
@Nullable SmsDatabase.InsertListener insertListener)
|
||||
throws MmsException {
|
||||
return insertMessageOutbox(message, threadId, forceSms, insertListener, 0);
|
||||
}
|
||||
|
||||
public long insertMessageOutbox(@NonNull OutgoingMediaMessage message,
|
||||
long threadId, boolean forceSms,
|
||||
@Nullable SmsDatabase.InsertListener insertListener,
|
||||
long serverTimestamp)
|
||||
throws MmsException
|
||||
{
|
||||
long type = Types.BASE_SENDING_TYPE;
|
||||
@ -998,7 +1006,10 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
contentValues.put(MESSAGE_BOX, type);
|
||||
contentValues.put(THREAD_ID, threadId);
|
||||
contentValues.put(READ, 1);
|
||||
contentValues.put(DATE_RECEIVED, System.currentTimeMillis());
|
||||
// In open groups messages should be sorted by their server timestamp
|
||||
long receivedTimestamp = serverTimestamp;
|
||||
if (serverTimestamp == 0) { receivedTimestamp = System.currentTimeMillis(); }
|
||||
contentValues.put(DATE_RECEIVED, receivedTimestamp);
|
||||
contentValues.put(SUBSCRIPTION_ID, message.getSubscriptionId());
|
||||
contentValues.put(EXPIRES_IN, message.getExpiresIn());
|
||||
contentValues.put(ADDRESS, message.getRecipient().getAddress().serialize());
|
||||
|
@ -136,10 +136,10 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
if (isPush() && getDateSent() < getDateReceived()) {
|
||||
return getDateSent();
|
||||
}
|
||||
if (getRecipient().getAddress().isOpenGroup()) {
|
||||
return getDateReceived();
|
||||
}
|
||||
if (isPush() && getDateSent() < getDateReceived()) {
|
||||
return getDateSent();
|
||||
}
|
||||
return getDateReceived();
|
||||
|
@ -1021,10 +1021,10 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
long messageId;
|
||||
|
||||
if (isGroup) {
|
||||
OutgoingMediaMessage outgoingMediaMessage = new OutgoingMediaMessage(recipient, new SlideDeck(), body, message.getTimestamp(), -1, expiresInMillis, ThreadDatabase.DistributionTypes.DEFAULT, null, Collections.emptyList(), Collections.emptyList());
|
||||
OutgoingMediaMessage outgoingMediaMessage = new OutgoingMediaMessage(recipient, new SlideDeck(), body, message.getMessage().getTimestamp(), -1, expiresInMillis, ThreadDatabase.DistributionTypes.DEFAULT, null, Collections.emptyList(), Collections.emptyList());
|
||||
outgoingMediaMessage = new OutgoingSecureMediaMessage(outgoingMediaMessage);
|
||||
|
||||
messageId = DatabaseFactory.getMmsDatabase(context).insertMessageOutbox(outgoingMediaMessage, threadId, false, null);
|
||||
messageId = DatabaseFactory.getMmsDatabase(context).insertMessageOutbox(outgoingMediaMessage, threadId, false, null,message.getTimestamp());
|
||||
if (message.messageServerID >= 0) { DatabaseFactory.getLokiMessageDatabase(context).setServerID(messageId, message.messageServerID); }
|
||||
|
||||
database = DatabaseFactory.getMmsDatabase(context);
|
||||
|
@ -192,7 +192,7 @@ class PublicChatPoller(private val context: Context, private val group: PublicCh
|
||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||
val dataMessage = getDataMessage(message)
|
||||
SessionMetaProtocol.dropFromTimestampCacheIfNeeded(dataMessage.timestamp)
|
||||
val transcript = SentTranscriptMessage(userHexEncodedPublicKey, dataMessage.timestamp, dataMessage, dataMessage.expiresInSeconds.toLong(), Collections.singletonMap(userHexEncodedPublicKey, false))
|
||||
val transcript = SentTranscriptMessage(userHexEncodedPublicKey, message.serverTimestamp, dataMessage, dataMessage.expiresInSeconds.toLong(), Collections.singletonMap(userHexEncodedPublicKey, false))
|
||||
transcript.messageServerID = messageServerID
|
||||
if (dataMessage.quote.isPresent || (dataMessage.attachments.isPresent && dataMessage.attachments.get().size > 0) || dataMessage.previews.isPresent) {
|
||||
PushDecryptJob(context).handleSynchronizeSentMediaMessage(transcript)
|
||||
|
Loading…
Reference in New Issue
Block a user