@@ -78,43 +78,44 @@ export async function updateTalkParticipants(eventComponent) {
78
78
return
79
79
}
80
80
try {
81
+ const { data : { ocs : { data : room } } } = await HTTPClient . get ( generateOcsUrl ( 'apps/spreed/api/' + apiVersion + '/' , 2 ) + 'room/' + token )
81
82
const participantsResponse = await HTTPClient . get ( generateOcsUrl ( 'apps/spreed/api/' + apiVersion + '/' , 2 ) + 'room/' + token + '/participants' )
82
83
// Ignore if the actor isn't owner of the conversation
83
84
if ( ! participantsResponse . data . ocs . data . some ( participant => participant . actorId === getCurrentUser ( ) . uid && participant . participantType <= 2 ) ) {
84
85
logger . debug ( 'Current user is not a moderator or owner' , { currentUser : getCurrentUser ( ) . uid , conversation : participantsResponse . data . ocs . data } )
85
86
return
86
87
}
88
+ console . info ( 'room' , room )
87
89
88
90
for ( const attendee of eventComponent . getAttendeeIterator ( ) ) {
89
91
logger . debug ( 'Processing attendee' , { attendee } )
90
92
if ( [ 'GROUP' , 'RESOURCE' , 'ROOM' ] . includes ( attendee . userType ) ) {
91
93
continue
92
94
}
93
95
94
- let participantId = removeMailtoPrefix ( attendee . email )
95
- let attendeeSource = 'emails'
96
+ const participantId = removeMailtoPrefix ( attendee . email )
96
97
try {
97
98
// Map attendee email to Nextcloud user uid
98
99
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
+ } )
103
113
} else {
104
- logger . debug ( 'Attendee ' + participantId + ' is not a Nextcloud user ' )
114
+ logger . debug ( 'Attendee ' + participantId + ' ignored as Talk participant ' )
105
115
}
106
116
} 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 } )
108
118
}
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
- } )
118
119
}
119
120
} catch ( error ) {
120
121
logger . warn ( 'Could not update Talk room attendees' , { error } )
0 commit comments