Skip to content

Commit

Permalink
fix(federation): show proxy avatars in InvitationHandler
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 Mar 12, 2024
1 parent f65db24 commit 04d51b3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/ConversationIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default {
if (this.item.isDummyConversation) {
// Prevent a 404 when trying to load an avatar before the conversation data is actually loaded
// Also used in new conversation / invitation handler dialog
const isFed = this.item.isFederatedConversation && 'icon-conversation-federation'
const isFed = this.item.remoteServer && 'icon-conversation-federation'
const type = this.item.type === CONVERSATION.TYPE.PUBLIC ? 'icon-conversation-public' : 'icon-conversation-group'
const theme = isDarkTheme ? 'dark' : 'bright'
return `${isFed || type} icon--dummy icon--${theme}`
Expand Down
33 changes: 20 additions & 13 deletions src/components/LeftSidebar/InvitationHandler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@
<span class="inbox__item-desc__name">
{{ item.roomName }}
</span>
<span class="inbox__item-desc__subname">
{{ t('spreed', 'From {user} at {remoteServer}', {
user: item.inviterDisplayName,
remoteServer: item.remoteServerUrl,
}) }}
</span>
<NcRichText class="inbox__item-desc__subname"
:text="t('spreed', 'From {user} at {remoteServer}', { remoteServer: item.remoteServer })"
:arguments="getRichParameters(item)"
:reference-limit="0" />
</div>
<NcButton type="tertiary"
:aria-label="t('spreed', 'Decline invitation')"
Expand Down Expand Up @@ -80,8 +78,10 @@ import CheckIcon from 'vue-material-design-icons/Check.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import NcRichText from '@nextcloud/vue/dist/Components/NcRichText.js'
import ConversationIcon from '../ConversationIcon.vue'
import Mention from '../MessagesList/MessagesGroup/Message/MessagePart/Mention.vue'
import { CONVERSATION } from '../../constants.js'
import { useFederationStore } from '../../stores/federation.ts'
Expand All @@ -90,6 +90,7 @@ export default {
name: 'InvitationHandler',
components: {
NcRichText,
ConversationIcon,
NcButton,
NcLoadingIcon,
Expand Down Expand Up @@ -119,12 +120,8 @@ export default {
invitations() {
const invitations = {}
for (const id in this.federationStore.pendingShares) {
invitations[id] = {
...this.federationStore.pendingShares[id],
type: CONVERSATION.TYPE.GROUP,
isFederatedConversation: true,
isDummyConversation: true,
}
const { localToken: token, remoteServerUrl: remoteServer, ...rest } = this.federationStore.pendingShares[id]
invitations[id] = { ...rest, token, remoteServer, type: CONVERSATION.TYPE.GROUP }
}
return invitations
},
Expand Down Expand Up @@ -158,7 +155,17 @@ export default {
if (Object.keys(this.invitations).length === 0) {
this.closeModal()
}
}
},
getRichParameters(item) {
const [id, server] = item.inviterCloudId.split('@')
return {
user: {
component: Mention,
props: { id, name: item.inviterDisplayName, server, token: item.token, type: 'user' }
}
}
},
},
}
</script>
Expand Down
5 changes: 3 additions & 2 deletions src/stores/__tests__/federation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('federationStore', () => {
id: 2,
userId: 'user0',
state: 0,
localRoomId: 10,
localToken: 'TOKEN_LOCAL_2',
remoteServerUrl: 'remote.nextcloud.com',
remoteToken: 'TOKEN_2',
remoteAttendeeId: 11,
Expand All @@ -28,7 +28,7 @@ describe('federationStore', () => {
id: 1,
userId: 'user0',
state: 1,
localRoomId: 9,
localToken: 'TOKEN_LOCAL_1',
remoteServerUrl: 'remote.nextcloud.com',
remoteToken: 'TOKEN_1',
remoteAttendeeId: 11,
Expand Down Expand Up @@ -158,6 +158,7 @@ describe('federationStore', () => {

const room = {
id: 10,
token: 'TOKEN_LOCAL_2'
}
const acceptResponse = generateOCSResponse({ payload: room })
acceptShare.mockResolvedValueOnce(acceptResponse)
Expand Down
4 changes: 2 additions & 2 deletions src/stores/federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const useFederationStore = defineStore('federation', {
const { id, name } = notification.messageRichParameters.user1
const invitation: FederationInvite = {
id: notification.objectId,
localRoomId: 0,
localToken: '',
localCloudId: notification.user + '@' + getBaseUrl().replace('https://', ''),
remoteAttendeeId: 0,
remoteServerUrl,
Expand All @@ -99,7 +99,7 @@ export const useFederationStore = defineStore('federation', {
Vue.delete(this.pendingShares[id], 'loading')
Vue.set(this.acceptedShares, id, {
...this.pendingShares[id],
localRoomId: conversation.id,
localToken: conversation.token,
state: FEDERATION.STATE.ACCEPTED,
})
Vue.delete(this.pendingShares, id)
Expand Down

0 comments on commit 04d51b3

Please sign in to comment.