mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 14:58:26 +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;
|
if (position < 0) return -1;
|
||||||
|
|
||||||
MessageRecord record = getRecordForPositionOrThrow(position);
|
MessageRecord record = getRecordForPositionOrThrow(position);
|
||||||
|
if (record.getRecipient().getAddress().isOpenGroup()) {
|
||||||
calendar.setTime(new Date(record.getDateSent()));
|
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));
|
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,
|
public long insertMessageOutbox(@NonNull OutgoingMediaMessage message,
|
||||||
long threadId, boolean forceSms,
|
long threadId, boolean forceSms,
|
||||||
@Nullable SmsDatabase.InsertListener insertListener)
|
@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
|
throws MmsException
|
||||||
{
|
{
|
||||||
long type = Types.BASE_SENDING_TYPE;
|
long type = Types.BASE_SENDING_TYPE;
|
||||||
@ -998,7 +1006,10 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
contentValues.put(MESSAGE_BOX, type);
|
contentValues.put(MESSAGE_BOX, type);
|
||||||
contentValues.put(THREAD_ID, threadId);
|
contentValues.put(THREAD_ID, threadId);
|
||||||
contentValues.put(READ, 1);
|
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(SUBSCRIPTION_ID, message.getSubscriptionId());
|
||||||
contentValues.put(EXPIRES_IN, message.getExpiresIn());
|
contentValues.put(EXPIRES_IN, message.getExpiresIn());
|
||||||
contentValues.put(ADDRESS, message.getRecipient().getAddress().serialize());
|
contentValues.put(ADDRESS, message.getRecipient().getAddress().serialize());
|
||||||
|
@ -136,10 +136,10 @@ public abstract class MessageRecord extends DisplayRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
if (isPush() && getDateSent() < getDateReceived()) {
|
|
||||||
return getDateSent();
|
|
||||||
}
|
|
||||||
if (getRecipient().getAddress().isOpenGroup()) {
|
if (getRecipient().getAddress().isOpenGroup()) {
|
||||||
|
return getDateReceived();
|
||||||
|
}
|
||||||
|
if (isPush() && getDateSent() < getDateReceived()) {
|
||||||
return getDateSent();
|
return getDateSent();
|
||||||
}
|
}
|
||||||
return getDateReceived();
|
return getDateReceived();
|
||||||
|
@ -1021,10 +1021,10 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
long messageId;
|
long messageId;
|
||||||
|
|
||||||
if (isGroup) {
|
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);
|
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); }
|
if (message.messageServerID >= 0) { DatabaseFactory.getLokiMessageDatabase(context).setServerID(messageId, message.messageServerID); }
|
||||||
|
|
||||||
database = DatabaseFactory.getMmsDatabase(context);
|
database = DatabaseFactory.getMmsDatabase(context);
|
||||||
|
@ -192,7 +192,7 @@ class PublicChatPoller(private val context: Context, private val group: PublicCh
|
|||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
val dataMessage = getDataMessage(message)
|
val dataMessage = getDataMessage(message)
|
||||||
SessionMetaProtocol.dropFromTimestampCacheIfNeeded(dataMessage.timestamp)
|
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
|
transcript.messageServerID = messageServerID
|
||||||
if (dataMessage.quote.isPresent || (dataMessage.attachments.isPresent && dataMessage.attachments.get().size > 0) || dataMessage.previews.isPresent) {
|
if (dataMessage.quote.isPresent || (dataMessage.attachments.isPresent && dataMessage.attachments.get().size > 0) || dataMessage.previews.isPresent) {
|
||||||
PushDecryptJob(context).handleSynchronizeSentMediaMessage(transcript)
|
PushDecryptJob(context).handleSynchronizeSentMediaMessage(transcript)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user