Skip to content

Commit

Permalink
feat(federations): intercept notifications regarding federation invites
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jan 10, 2024
1 parent 510898a commit 0400685
Showing 1 changed file with 38 additions and 17 deletions.
55 changes: 38 additions & 17 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -519,25 +519,38 @@ export default {
* @param {boolean} event.cancelAction Option to cancel the action so no page reload is happening
*/
interceptNotificationActions(event) {
if (event.notification.app !== 'spreed' || event.action.type !== 'WEB') {
if (event.notification.app !== 'spreed') {
return
}

const [, load] = event.action.url.split('/call/')
if (!load) {
return
}
switch (event.action.type) {
case 'WEB': {
const load = event.action.url.split('/call/').pop()
if (!load) {
return
}

const [token, hash] = load.split('#')
this.$router.push({
name: 'conversation',
hash: hash ? `#${hash}` : '',
params: {
token,
},
})
const [token, hash] = load.split('#')
this.$router.push({
name: 'conversation',
hash: hash ? `#${hash}` : '',
params: {
token,
},
})

event.cancelAction = true
break
}
case 'POST': {
if (event.notification.objectType === 'remote_talk_share') {
// Federation invitation handling
}
break
}
default: break
}

event.cancelAction = true
},

/**
Expand All @@ -552,7 +565,8 @@ export default {
return
}

if (event.notification.objectType === 'chat') {
switch (event.notification.objectType) {
case 'chat': {
if (event.notification.subjectRichParameters?.reaction) {
// Ignore reaction notifications in case of one-to-one and always-notify
return
Expand All @@ -561,12 +575,19 @@ export default {
this.$store.dispatch('updateConversationLastMessageFromNotification', {
notification: event.notification,
})
break
}

if (event.notification.objectType === 'call') {
case 'call': {
this.$store.dispatch('updateCallStateFromNotification', {
notification: event.notification,
})
break
}
case 'remote_talk_share': {
// Federation invitation handling
break
}
default: break
}
},

Expand Down

0 comments on commit 0400685

Please sign in to comment.