diff --git a/ts/components/conversation/GroupInvitation.tsx b/ts/components/conversation/GroupInvitation.tsx index 7e4246bce..9ba71ee7b 100644 --- a/ts/components/conversation/GroupInvitation.tsx +++ b/ts/components/conversation/GroupInvitation.tsx @@ -1,12 +1,11 @@ import React from 'react'; import classNames from 'classnames'; -import { SessionButton, SessionButtonType } from '../session/SessionButton'; import { SessionIconButton, SessionIconSize, SessionIconType } from '../session/icon'; import { useTheme } from 'styled-components'; type Props = { - serverName: string; - serverAddress: string; + name: string; + url: string; direction: string; onJoinClick: () => void; }; @@ -32,9 +31,9 @@ export const GroupInvitation = (props: Props) => { onClick={props.onJoinClick} /> - {props.serverName} + {props.name} {openGroupInvitation} - {props.serverAddress} + {props.url} diff --git a/ts/components/conversation/InviteContactsDialog.tsx b/ts/components/conversation/InviteContactsDialog.tsx index e7b619ca2..21702bf46 100644 --- a/ts/components/conversation/InviteContactsDialog.tsx +++ b/ts/components/conversation/InviteContactsDialog.tsx @@ -116,8 +116,8 @@ const InviteContactsDialogInner = (props: Props) => { if (convo.isOpenGroupV2()) { const completeUrl = await getCompleteUrlForV2ConvoId(convo.id); const groupInvitation = { - serverAddress: completeUrl, - serverName: convo.getName(), + url: completeUrl, + name: convo.getName(), }; pubkeys.forEach(async pubkeyStr => { const privateConvo = await ConversationController.getInstance().getOrCreateAndWait( diff --git a/ts/interactions/messageInteractions.ts b/ts/interactions/messageInteractions.ts index 5103a2e28..f08dc67ef 100644 --- a/ts/interactions/messageInteractions.ts +++ b/ts/interactions/messageInteractions.ts @@ -8,7 +8,6 @@ import { ConversationController } from '../session/conversations'; import { PubKey } from '../session/types'; import { ToastUtils } from '../session/utils'; -import { useDispatch } from 'react-redux'; import { updateConfirmModal } from '../state/ducks/modalDialog'; export function banUser(userToBan: string, conversationId: string) { @@ -21,9 +20,8 @@ export function banUser(userToBan: string, conversationId: string) { return; } - const dispatch = useDispatch(); const onClickClose = () => { - dispatch(updateConfirmModal(null)); + window.inboxStore?.dispatch(updateConfirmModal(null)); }; const confirmationModalProps = { @@ -55,7 +53,7 @@ export function banUser(userToBan: string, conversationId: string) { }, }; - dispatch(updateConfirmModal(confirmationModalProps)); + window.inboxStore?.dispatch(updateConfirmModal(confirmationModalProps)); } /** @@ -77,8 +75,7 @@ export function unbanUser(userToUnBan: string, conversationId: string) { return; } - const dispatch = useDispatch(); - const onClickClose = () => dispatch(updateConfirmModal(null)); + const onClickClose = () => window.inboxStore?.dispatch(updateConfirmModal(null)); const onClickOk = async () => { const conversation = ConversationController.getInstance().get(conversationId); @@ -104,7 +101,7 @@ export function unbanUser(userToUnBan: string, conversationId: string) { } }; - dispatch( + window.inboxStore?.dispatch( updateConfirmModal({ title: window.i18n('unbanUser'), message: window.i18n('unbanUserConfirm'), @@ -168,13 +165,11 @@ export async function addSenderAsModerator(sender: string, convoId: string) { } const acceptOpenGroupInvitationV2 = (completeUrl: string, roomName?: string) => { - const dispatch = useDispatch(); - const onClickClose = () => { - dispatch(updateConfirmModal(null)); + window.inboxStore?.dispatch(updateConfirmModal(null)); }; - dispatch( + window.inboxStore?.dispatch( updateConfirmModal({ title: window.i18n('joinOpenGroupAfterInvitationConfirmationTitle', roomName), message: window.i18n('joinOpenGroupAfterInvitationConfirmationDesc', roomName), diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 076fcf1c1..7e7ea98ec 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -612,8 +612,8 @@ export class ConversationModel extends Backbone.Model { const groupInvitMessage = new GroupInvitationMessage({ identifier: id, timestamp: sentAt, - serverName: groupInvitation.serverName, - serverAddress: groupInvitation.serverAddress, + name: groupInvitation.name, + url: groupInvitation.url, expireTimer: this.get('expireTimer'), }); // we need the return await so that errors are caught in the catch {} diff --git a/ts/models/message.ts b/ts/models/message.ts index 5968c8b83..8d3ea07ae 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -314,18 +314,18 @@ export class MessageModel extends Backbone.Model { let serverAddress = ''; try { - const url = new URL(invitation.serverAddress); + const url = new URL(invitation.url); serverAddress = url.origin; } catch (e) { window?.log?.warn('failed to get hostname from opengroupv2 invitation', invitation); } return { - serverName: invitation.serverName, - serverAddress, + serverName: invitation.name, + url: serverAddress, direction, onJoinClick: () => { - acceptOpenGroupInvitation(invitation.serverAddress, invitation.serverName); + acceptOpenGroupInvitation(invitation.url, invitation.name); }, }; } diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index d2b3341ba..e5fe07924 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -295,8 +295,8 @@ async function handleRegularMessage( } } - if (dataMessage.groupInvitation) { - message.set({ groupInvitation: dataMessage.groupInvitation }); + if (dataMessage.openGroupInvitation) { + message.set({ groupInvitation: dataMessage.openGroupInvitation }); } handleLinkPreviews(dataMessage.body, dataMessage.preview, message); diff --git a/ts/session/messages/outgoing/visibleMessage/GroupInvitationMessage.ts b/ts/session/messages/outgoing/visibleMessage/GroupInvitationMessage.ts index 1140fe72f..3b9ef6356 100644 --- a/ts/session/messages/outgoing/visibleMessage/GroupInvitationMessage.ts +++ b/ts/session/messages/outgoing/visibleMessage/GroupInvitationMessage.ts @@ -4,29 +4,29 @@ import { SignalService } from '../../../../protobuf'; import { MessageParams } from '../Message'; interface GroupInvitationMessageParams extends MessageParams { - serverAddress: string; - serverName: string; + url: string; + name: string; // if there is an expire timer set for the conversation, we need to set it. // otherwise, it will disable the expire timer on the receiving side. expireTimer?: number; } export class GroupInvitationMessage extends DataMessage { - private readonly serverAddress: string; - private readonly serverName: string; + private readonly url: string; + private readonly name: string; private readonly expireTimer?: number; constructor(params: GroupInvitationMessageParams) { super({ timestamp: params.timestamp, identifier: params.identifier }); - this.serverAddress = params.serverAddress; - this.serverName = params.serverName; + this.url = params.url; + this.name = params.name; this.expireTimer = params.expireTimer; } public dataProto(): SignalService.DataMessage { const openGroupInvitation = new SignalService.DataMessage.OpenGroupInvitation({ - url: this.serverAddress, - name: this.serverName, + url: this.url, + name: this.name, }); return new SignalService.DataMessage({ diff --git a/ts/test/session/unit/messages/GroupInvitationMessage_test.ts b/ts/test/session/unit/messages/GroupInvitationMessage_test.ts index fb4689180..ba40c6d8a 100644 --- a/ts/test/session/unit/messages/GroupInvitationMessage_test.ts +++ b/ts/test/session/unit/messages/GroupInvitationMessage_test.ts @@ -8,23 +8,23 @@ import { GroupInvitationMessage } from '../../../../session/messages/outgoing/vi describe('GroupInvitationMessage', () => { let message: GroupInvitationMessage; const timestamp = Date.now(); - const serverAddress = 'http://localhost'; - const serverName = 'test'; + const url = 'http://localhost'; + const name = 'test'; beforeEach(() => { message = new GroupInvitationMessage({ timestamp, - serverAddress, - serverName, + url, + name, }); }); - it('dataMessage.groupInvitation has serverAddress, and serverName set', () => { + it('dataMessage.groupInvitation has url, and serverName set', () => { const plainText = message.plainTextBuffer(); const decoded = SignalService.Content.decode(plainText); - expect(decoded.dataMessage?.openGroupInvitation).to.have.property('url', serverAddress); - expect(decoded.dataMessage?.openGroupInvitation).to.have.property('name', serverName); + expect(decoded.dataMessage?.openGroupInvitation).to.have.property('url', url); + expect(decoded.dataMessage?.openGroupInvitation).to.have.property('name', name); }); it('correct ttl', () => {