Skip to content

Commit 31671b4

Browse files
Merge pull request #5688 from nextcloud/fix/talk/no-guest-participants
fix(talk): Only invite guest accounts to open Talk conversations
2 parents 4dfc104 + e6e8c2a commit 31671b4

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/services/talkService.js

+18-17
Original file line numberDiff line numberDiff line change
@@ -78,43 +78,44 @@ export async function updateTalkParticipants(eventComponent) {
7878
return
7979
}
8080
try {
81+
const { data: { ocs: { data: room } } } = await HTTPClient.get(generateOcsUrl('apps/spreed/api/' + apiVersion + '/', 2) + 'room/' + token)
8182
const participantsResponse = await HTTPClient.get(generateOcsUrl('apps/spreed/api/' + apiVersion + '/', 2) + 'room/' + token + '/participants')
8283
// Ignore if the actor isn't owner of the conversation
8384
if (!participantsResponse.data.ocs.data.some(participant => participant.actorId === getCurrentUser().uid && participant.participantType <= 2)) {
8485
logger.debug('Current user is not a moderator or owner', { currentUser: getCurrentUser().uid, conversation: participantsResponse.data.ocs.data })
8586
return
8687
}
88+
console.info('room', room)
8789

8890
for (const attendee of eventComponent.getAttendeeIterator()) {
8991
logger.debug('Processing attendee', { attendee })
9092
if (['GROUP', 'RESOURCE', 'ROOM'].includes(attendee.userType)) {
9193
continue
9294
}
9395

94-
let participantId = removeMailtoPrefix(attendee.email)
95-
let attendeeSource = 'emails'
96+
const participantId = removeMailtoPrefix(attendee.email)
9697
try {
9798
// Map attendee email to Nextcloud user uid
9899
const searchResult = await HTTPClient.get(generateOcsUrl('core/autocomplete/', 2) + 'get?search=' + encodeURIComponent(participantId) + '&itemType=&itemId=%20&shareTypes[]=0&limit=2')
99-
// Only map if there is exactly one result. Use email if there are none or more results.
100-
if (searchResult.data.ocs.data.length === 1) {
101-
participantId = searchResult.data.ocs.data[0].id
102-
attendeeSource = 'users'
100+
// Only map if there is exactly one result
101+
if (searchResult.data.ocs.data.length === 1 && searchResult.data.ocs.data[0].id !== getCurrentUser().uid) {
102+
await HTTPClient.post(generateOcsUrl('apps/spreed/api/' + apiVersion + '/', 2) + 'room/' + token + '/participants', {
103+
newParticipant: searchResult.data.ocs.data[0].id,
104+
source: 'users',
105+
})
106+
} else if (searchResult.data.ocs.data[0]?.id === getCurrentUser().uid) {
107+
logger.debug('Skipping organizer ' + searchResult.data.ocs.data[0].id)
108+
} else if (room.type === 3) {
109+
await HTTPClient.post(generateOcsUrl('apps/spreed/api/' + apiVersion + '/', 2) + 'room/' + token + '/participants', {
110+
newParticipant: participantId,
111+
source: 'emails',
112+
})
103113
} else {
104-
logger.debug('Attendee ' + participantId + ' is not a Nextcloud user')
114+
logger.debug('Attendee ' + participantId + ' ignored as Talk participant')
105115
}
106116
} catch (error) {
107-
logger.info('Could not find user data for attendee ' + participantId, { error })
117+
logger.info('Could not add attendee ' + participantId + ' as Talk participant', { error })
108118
}
109-
110-
if (attendeeSource === 'users' && participantId === getCurrentUser().uid) {
111-
logger.debug('Skipping organizer')
112-
continue
113-
}
114-
await HTTPClient.post(generateOcsUrl('apps/spreed/api/' + apiVersion + '/', 2) + 'room/' + token + '/participants', {
115-
newParticipant: participantId,
116-
source: attendeeSource,
117-
})
118119
}
119120
} catch (error) {
120121
logger.warn('Could not update Talk room attendees', { error })

0 commit comments

Comments
 (0)