fix: use unique timestamps for batch request

because android still needs them to be uniq
pull/3281/head
Audric Ackermann 4 months ago
parent 624134ccc9
commit cd6fd475e3
No known key found for this signature in database

@ -1,5 +1,5 @@
import { UserGroupsGet } from 'libsession_util_nodejs'; import { UserGroupsGet } from 'libsession_util_nodejs';
import { compact, isEmpty } from 'lodash'; import { compact, isEmpty, uniqBy } from 'lodash';
import { SignalService } from '../../../../protobuf'; import { SignalService } from '../../../../protobuf';
import { MetaGroupWrapperActions } from '../../../../webworker/workers/browser/libsession_worker_interface'; import { MetaGroupWrapperActions } from '../../../../webworker/workers/browser/libsession_worker_interface';
import { GroupUpdateInfoChangeMessage } from '../../../messages/outgoing/controlMessage/group_v2/to_group/GroupUpdateInfoChangeMessage'; import { GroupUpdateInfoChangeMessage } from '../../../messages/outgoing/controlMessage/group_v2/to_group/GroupUpdateInfoChangeMessage';
@ -40,6 +40,13 @@ async function makeGroupMessageSubRequest(
throw new Error('makeGroupMessageSubRequest: not all messages are for the same destination'); throw new Error('makeGroupMessageSubRequest: not all messages are for the same destination');
} }
const allTimestamps = uniqBy(compactedMessages, m => m.createAtNetworkTimestamp);
if (allTimestamps.length !== compactedMessages.length) {
throw new Error(
'tried to send batch request with messages having the same timestamp, and some platformn do not support this.'
);
}
const messagesToEncrypt: Array<StoreGroupExtraData> = compactedMessages.map(updateMessage => { const messagesToEncrypt: Array<StoreGroupExtraData> = compactedMessages.map(updateMessage => {
const wrapped = MessageWrapper.wrapContentIntoEnvelope( const wrapped = MessageWrapper.wrapContentIntoEnvelope(
SignalService.Envelope.Type.CLOSED_GROUP_MESSAGE, SignalService.Envelope.Type.CLOSED_GROUP_MESSAGE,

@ -695,7 +695,7 @@ async function leaveClosedGroup(groupPk: PubkeyType | GroupPubkeyType, fromSyncM
const createAtNetworkTimestamp = NetworkTime.now(); const createAtNetworkTimestamp = NetworkTime.now();
// Send the update to the 03 group // Send the update to the 03 group
const ourLeavingMessage = new GroupUpdateMemberLeftMessage({ const ourLeavingMessage = new GroupUpdateMemberLeftMessage({
createAtNetworkTimestamp, createAtNetworkTimestamp: createAtNetworkTimestamp + 1, // we just need it to be different than the one of ourLeavingNotificationMessage
groupPk, groupPk,
expirationType: null, // we keep that one **not** expiring expirationType: null, // we keep that one **not** expiring
expireTimer: null, expireTimer: null,

Loading…
Cancel
Save