fix: closed group groupId is now PubKey only

pull/2971/head
William Grant 2 years ago
parent 01d04bd4d3
commit 40014544d1

@ -627,7 +627,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const chatMessageMediumGroup = new VisibleMessage(chatMessageParams);
const closedGroupVisibleMessage = new ClosedGroupVisibleMessage({
chatMessage: chatMessageMediumGroup,
groupId: destination,
groupId: destinationPubkey,
timestamp: sentAt,
});
// we need the return await so that errors are caught in the catch {}
@ -1921,7 +1921,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const chatMessageMediumGroup = new VisibleMessage(chatMessageParams);
const closedGroupVisibleMessage = new ClosedGroupVisibleMessage({
chatMessage: chatMessageMediumGroup,
groupId: destination,
groupId: destinationPubkey,
timestamp: sentAt,
expirationType: chatMessageParams.expirationType,
expireTimer: chatMessageParams.expireTimer,

@ -919,7 +919,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
const closedGroupVisibleMessage = new ClosedGroupVisibleMessage({
identifier: this.id,
groupId: this.get('conversationId'),
groupId: PubKey.cast(this.get('conversationId')),
timestamp,
chatMessage,
});

@ -1,15 +1,14 @@
import { SignalService } from '../../../../protobuf';
import { PubKey } from '../../../types';
import { StringUtils } from '../../../utils';
import { VisibleMessage } from './VisibleMessage';
import {
ClosedGroupMessage,
ClosedGroupMessageParams,
} from '../controlMessage/group/ClosedGroupMessage';
import { VisibleMessage } from './VisibleMessage';
interface ClosedGroupVisibleMessageParams extends ClosedGroupMessageParams {
// TODO Refactor closed groups typings so groupId is PubKey only
// groupId: PubKey;
groupId: PubKey;
chatMessage: VisibleMessage;
}

@ -9,22 +9,22 @@
import { randomBytes } from 'crypto';
import chai from 'chai';
import Sinon, * as sinon from 'sinon';
import { describe } from 'mocha';
import chaiAsPromised from 'chai-as-promised';
import { describe } from 'mocha';
import Sinon, * as sinon from 'sinon';
import { GroupUtils, PromiseUtils, UserUtils } from '../../../../session/utils';
import { TestUtils } from '../../../test-utils';
import { MessageQueue } from '../../../../session/sending/MessageQueue';
import { ContentMessage } from '../../../../session/messages/outgoing';
import { PubKey, RawMessage } from '../../../../session/types';
import { ClosedGroupMessage } from '../../../../session/messages/outgoing/controlMessage/group/ClosedGroupMessage';
import { MessageSender } from '../../../../session/sending';
import { MessageQueue } from '../../../../session/sending/MessageQueue';
import { PubKey, RawMessage } from '../../../../session/types';
import { GroupUtils, PromiseUtils, UserUtils } from '../../../../session/utils';
import { TestUtils } from '../../../test-utils';
import { PendingMessageCacheStub } from '../../../test-utils/stubs';
import { ClosedGroupMessage } from '../../../../session/messages/outgoing/controlMessage/group/ClosedGroupMessage';
import { SnodeNamespaces } from '../../../../session/apis/snode_api/namespaces';
import { MessageSentHandler } from '../../../../session/sending/MessageSentHandler';
import { stubData } from '../../../test-utils/utils';
import { SnodeNamespaces } from '../../../../session/apis/snode_api/namespaces';
chai.use(chaiAsPromised as any);
chai.should();
@ -209,7 +209,7 @@ describe('MessageQueue', () => {
describe('closed groups', () => {
it('can send to closed group', async () => {
const members = TestUtils.generateFakePubKeys(4).map(p => new PubKey(p.key));
const members = TestUtils.generateFakePubKeys(4);
Sinon.stub(GroupUtils, 'getGroupMembers').returns(members);
const send = Sinon.stub(messageQueueStub, 'sendToPubKey').resolves();

@ -16,6 +16,7 @@ import { ExpirationTimerUpdateMessage } from '../../../session/messages/outgoing
import { ClosedGroupVisibleMessage } from '../../../session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage';
import { OpenGroupVisibleMessage } from '../../../session/messages/outgoing/visibleMessage/OpenGroupVisibleMessage';
import { VisibleMessage } from '../../../session/messages/outgoing/visibleMessage/VisibleMessage';
import { PubKey } from '../../../session/types';
import { OpenGroupReaction } from '../../../types/Reaction';
import { generateFakePubKey } from './pubkey';
@ -91,7 +92,7 @@ export function generateClosedGroupMessage(
): ClosedGroupVisibleMessage {
return new ClosedGroupVisibleMessage({
identifier: uuid(),
groupId: groupId ?? generateFakePubKey().key,
groupId: groupId ? PubKey.cast(groupId) : generateFakePubKey(),
timestamp: timestamp || Date.now(),
chatMessage: generateVisibleMessage(),
});

Loading…
Cancel
Save