Skip to content

Commit

Permalink
fixup! fix: show e-mail in subline of e-mail guests for moderators
Browse files Browse the repository at this point in the history
- refactor resendInvitations

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Oct 28, 2024
1 parent 595510a commit d2516d1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 22 deletions.
7 changes: 1 addition & 6 deletions src/components/ConversationSettings/LinkShareSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,7 @@ export default {

async handleResendInvitations() {
this.isSendingInvitations = true
try {
await this.$store.dispatch('resendInvitations', { token: this.token })
showSuccess(t('spreed', 'Invitations sent'))
} catch (e) {
showError(t('spreed', 'Error occurred when sending invitations'))
}
await this.$store.dispatch('resendInvitations', { token: this.token })
this.isSendingInvitations = false
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/components/RightSidebar/Participants/Participant.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ describe('Participant.vue', () => {
test('allows moderators to resend invitations for email participants', async () => {
conversation.participantType = PARTICIPANT.TYPE.MODERATOR
participant.actorType = ATTENDEE.ACTOR_TYPE.EMAILS
participant.invitedActorId = '[email protected]'
const wrapper = mountParticipant(participant)
const actionButton = findNcActionButton(wrapper, 'Resend invitation')
expect(actionButton.exists()).toBe(true)
Expand All @@ -535,6 +536,7 @@ describe('Participant.vue', () => {
expect(resendInvitationsAction).toHaveBeenCalledWith(expect.anything(), {
token: 'current-token',
attendeeId: 'alice-attendee-id',
actorId: '[email protected]',
})
})

Expand Down
14 changes: 5 additions & 9 deletions src/components/RightSidebar/Participants/Participant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -819,15 +819,11 @@ export default {
},

async resendInvitation() {
try {
await this.$store.dispatch('resendInvitations', {
token: this.token,
attendeeId: this.attendeeId,
})
showSuccess(t('spreed', 'Invitation was sent to {actorId}', { actorId: this.participant.invitedActorId }))
} catch (error) {
showError(t('spreed', 'Could not send invitation to {actorId}', { actorId: this.participant.invitedActorId }))
}
await this.$store.dispatch('resendInvitations', {
token: this.token,
attendeeId: this.attendeeId,
actorId: this.participant.invitedActorId ?? this.participant.actorId,
})
},

async sendCallNotification() {
Expand Down
5 changes: 4 additions & 1 deletion src/components/RightSidebar/Participants/ParticipantsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import { ref, toRefs } from 'vue'

import IconInformationOutline from 'vue-material-design-icons/InformationOutline.vue'

import { showError } from '@nextcloud/dialogs'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { t } from '@nextcloud/l10n'

Expand Down Expand Up @@ -311,6 +311,9 @@ export default {
async addParticipants(item) {
try {
await addParticipant(this.token, item.id, item.source)
if (item.source === ATTENDEE.ACTOR_TYPE.EMAILS) {
showSuccess(t('spreed', 'Invitation was sent to {actorId}', { actorId: item.id }))
}
this.abortSearch()
this.cancelableGetParticipants()
} catch (exception) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/participantsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ const setGuestUserName = async (token, userName) => {
* If no userId is set, send to all applicable participants.
*
* @param {string} token conversation token
* @param {number} attendeeId attendee id to target, or null for all
* @param {number|null} [attendeeId] attendee id to target, or null for all
*/
const resendInvitations = async (token, { attendeeId = null }) => {
const resendInvitations = async (token, attendeeId = null) => {
await axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/participants/resend-invitations', { token }), {
attendeeId,
})
Expand Down
22 changes: 19 additions & 3 deletions src/store/participantsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,10 +883,26 @@ const actions = {
* @param {object} _ - unused.
* @param {object} data - the wrapping object.
* @param {string} data.token - conversation token.
* @param {number} data.attendeeId - attendee id to target, or null for all.
* @param {number} [data.attendeeId] - attendee id to target, or null for all.
* @param {number} [data.actorId] - attendee id to target, or null for all.
*/
async resendInvitations(_, { token, attendeeId }) {
await resendInvitations(token, { attendeeId })
async resendInvitations(_, { token, attendeeId, actorId }) {
if (attendeeId) {
try {
await resendInvitations(token, attendeeId)
showSuccess(t('spreed', 'Invitation was sent to {actorId}', { actorId }))
} catch (error) {
showError(t('spreed', 'Could not send invitation to {actorId}', { actorId }))
}
} else {
try {
await resendInvitations(token)
showSuccess(t('spreed', 'Invitations sent'))
} catch (e) {
showError(t('spreed', 'Error occurred when sending invitations'))
}
}

},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/store/participantsStore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ describe('participantsStore', () => {
attendeeId: 1,
})

expect(resendInvitations).toHaveBeenCalledWith(TOKEN, { attendeeId: 1 })
expect(resendInvitations).toHaveBeenCalledWith(TOKEN, 1)
})

describe('joining conversation', () => {
Expand Down

0 comments on commit d2516d1

Please sign in to comment.