diff --git a/src/App.vue b/src/App.vue index 484f0625b9b..858f33a1a6a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -543,6 +543,7 @@ export default { if (event.notification.objectType === 'remote_talk_share') { try { event.cancelAction = true + this.federationStore.addInvitationFromNotification(event.notification) const conversation = await this.federationStore.acceptShare(event.notification.objectId) if (conversation.token) { this.$store.dispatch('addConversation', conversation) @@ -559,7 +560,8 @@ export default { if (event.notification.objectType === 'remote_talk_share') { try { event.cancelAction = true - this.federationStore.rejectShare(event.notification.objectId) + this.federationStore.addInvitationFromNotification(event.notification) + await this.federationStore.rejectShare(event.notification.objectId) } catch (error) { console.error(error) } diff --git a/src/services/federationService.ts b/src/services/federationService.ts index ff76e6ffd56..754ae52755d 100644 --- a/src/services/federationService.ts +++ b/src/services/federationService.ts @@ -23,7 +23,7 @@ const getShares = async function(options?: object): getSharesResponse { * @param id invitation id; * @param [options] options; */ -const acceptShare = async function(id: number, options?: object): acceptShareResponse { +const acceptShare = async function(id: string | number, options?: object): acceptShareResponse { return axios.post(generateOcsUrl('apps/spreed/api/v1/federation/invitation/{id}', { id }, options), {}, options) } @@ -33,7 +33,7 @@ const acceptShare = async function(id: number, options?: object): acceptShareRes * @param id invitation id; * @param [options] options; */ -const rejectShare = async function(id: number, options?: object): rejectShareResponse { +const rejectShare = async function(id: string | number, options?: object): rejectShareResponse { return axios.delete(generateOcsUrl('apps/spreed/api/v1/federation/invitation/{id}', { id }, options), options) } diff --git a/src/stores/__tests__/federation.spec.js b/src/stores/__tests__/federation.spec.js index f9fa443f965..3aae72463e6 100644 --- a/src/stores/__tests__/federation.spec.js +++ b/src/stores/__tests__/federation.spec.js @@ -168,7 +168,7 @@ describe('federationStore', () => { // Assert expect(federationStore.pendingShares).toMatchObject({ [invites[0].id]: invites[0], - [notifications[1].objectId]: { id: notifications[1].objectId }, + [notifications[1].objectId]: { id: +notifications[1].objectId }, }) expect(federationStore.acceptedShares).toMatchObject({ [invites[1].id]: invites[1] }) expect(federationStore.pendingSharesCount).toBe(2) diff --git a/src/stores/federation.ts b/src/stores/federation.ts index c92a625f549..dbb9ae67788 100644 --- a/src/stores/federation.ts +++ b/src/stores/federation.ts @@ -62,7 +62,7 @@ export const useFederationStore = defineStore('federation', { const [remoteServerUrl, remoteToken] = notification.messageRichParameters.roomName.id.split('::') const { id, name } = notification.messageRichParameters.user1 const invitation: FederationInvite = { - id: notification.objectId, + id: +notification.objectId, localToken: '', localCloudId: notification.user + '@' + getBaseUrl().replace('https://', ''), remoteAttendeeId: 0, @@ -84,7 +84,7 @@ export const useFederationStore = defineStore('federation', { * @param id invitation id * @param conversation conversation object */ - markInvitationAccepted(id: number, conversation: Conversation) { + markInvitationAccepted(id: string | number, conversation: Conversation) { if (!this.pendingShares[id]) { return } @@ -102,7 +102,7 @@ export const useFederationStore = defineStore('federation', { * * @param id invitation id */ - async acceptShare(id: number): Promise { + async acceptShare(id: string | number): Promise { if (!this.pendingShares[id]) { return } @@ -128,7 +128,7 @@ export const useFederationStore = defineStore('federation', { * * @param id invitation id */ - async rejectShare(id: number) { + async rejectShare(id: string | number) { if (!this.pendingShares[id]) { return } diff --git a/src/types/index.ts b/src/types/index.ts index ec349372fed..71147a5dd9e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -33,7 +33,7 @@ export type Notification user: string, datetime: string, objectType: string, - objectId: number, + objectId: string, subject: string, message: string, link: string,