Browse Source

Remove participant list API's sessionId

The sessionId is now removed from the participant list API response in
favor of the sessionIds array.

The frontend code has been adjusted to accomodate for the new structure.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
pull/5482/head
Vincent Petry 5 years ago
parent
commit
a9731a2d00
No known key found for this signature in database GPG Key ID: E055D6A4D513575C
  1. 1
      docs/participant.md
  2. 3
      lib/Controller/RoomController.php
  3. 18
      src/components/RightSidebar/Participants/CurrentParticipants/CurrentParticipants.vue
  4. 20
      src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue
  5. 14
      src/store/callViewStore.js

1
docs/participant.md

@ -34,7 +34,6 @@
`participantType` | int | * | Permissions level of the participant (see [constants list](constants.md#participant-types))
`lastPing` | int | * | Timestamp of the last ping of the user (should be used for sorting)
`inCall` | int | * | Call flags the user joined with (see [constants list](constants.md#participant-in-call-flag))
`sessionId` | string | * | `'0'` if not connected, otherwise a 512 character long string
`sessionIds` | array | * | array of session ids, each are 512 character long strings, or empty if no session
`status` | string | * | Optional: Only available with `includeStatus=true`, for users with a set status and when there are less than 100 participants in the conversation
`statusIcon` | string | * | Optional: Only available with `includeStatus=true`, for users with a set status and when there are less than 100 participants in the conversation

3
lib/Controller/RoomController.php

@ -921,7 +921,6 @@ class RoomController extends AEnvironmentAwareController {
// Combine the session values: All inCall bit flags, newest lastPing and any sessionId (for online checking)
$results[$attendeeId]['inCall'] |= $session->getInCall();
$results[$attendeeId]['lastPing'] = max($results[$attendeeId]['lastPing'], $session->getLastPing());
$results[$attendeeId]['sessionId'] = $results[$attendeeId]['sessionId'] !== '0' ? $results[$attendeeId]['sessionId'] : $session->getSessionId();
$results[$attendeeId]['sessionIds'][] = $session->getSessionId();
continue;
}
@ -929,7 +928,6 @@ class RoomController extends AEnvironmentAwareController {
$result = [
'inCall' => Participant::FLAG_DISCONNECTED,
'lastPing' => 0,
'sessionId' => '0', // FIXME empty string or null?
'sessionIds' => [],
'participantType' => $participant->getAttendee()->getParticipantType(),
'attendeeId' => $attendeeId,
@ -951,7 +949,6 @@ class RoomController extends AEnvironmentAwareController {
if ($participant->getSession() instanceof Session) {
$result['inCall'] = $participant->getSession()->getInCall();
$result['lastPing'] = $participant->getSession()->getLastPing();
$result['sessionId'] = $participant->getSession()->getSessionId();
$result['sessionIds'] = [$participant->getSession()->getSessionId()];
}

18
src/components/RightSidebar/Participants/CurrentParticipants/CurrentParticipants.vue

@ -145,19 +145,19 @@ export default {
return p2IsGroup ? -1 : 1
}
let session1 = participant1.sessionId
let session2 = participant2.sessionId
let hasSessions1 = !!participant1.sessionIds.length
let hasSessions2 = !!participant2.sessionIds.length
if (participant1.status === 'offline') {
session1 = '0'
hasSessions1 = false
}
if (participant2.status === 'offline') {
session2 = '0'
hasSessions2 = false
}
if (session1 === '0') {
if (session2 !== '0') {
if (!hasSessions1) {
if (hasSessions2) {
return 1
}
} else if (session2 === '0') {
} else if (!hasSessions2) {
return -1
}
@ -167,8 +167,8 @@ export default {
return p1inCall ? -1 : 1
}
const p1HandRaised = this.$store.getters.getParticipantRaisedHand(session1)
const p2HandRaised = this.$store.getters.getParticipantRaisedHand(session2)
const p1HandRaised = this.$store.getters.getParticipantRaisedHand(participant1.sessionIds)
const p2HandRaised = this.$store.getters.getParticipantRaisedHand(participant2.sessionIds)
if (p1HandRaised.state !== p2HandRaised.state) {
return p1HandRaised.state ? -1 : 1
}

20
src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue

@ -305,20 +305,12 @@ export default {
return this.participant.label
},
isHandRaised() {
let aggregatedState = false
if (this.isSearched || this.participant.inCall === PARTICIPANT.CALL_FLAG.DISCONNECTED) {
return false
}
// show hand icon if at least one session has a raised hand
this.participant.sessionIds.forEach((sessionId) => {
const state = this.$store.getters.isParticipantRaisedHand(sessionId)
if (state === true) {
aggregatedState = true
}
})
return aggregatedState
const raisedState = this.$store.getters.getParticipantRaisedHand(this.participant.sessionIds)
return raisedState.state
},
callIcon() {
if (this.isSearched || this.participant.inCall === PARTICIPANT.CALL_FLAG.DISCONNECTED) {
@ -352,8 +344,8 @@ export default {
participantType() {
return this.participant.participantType
},
sessionId() {
return this.participant.sessionId
sessionIds() {
return this.participant.sessionIds || []
},
lastPing() {
return this.participant.lastPing
@ -383,14 +375,14 @@ export default {
}
// Guest
return this.sessionId !== '0' && this.sessionId === this.currentParticipant.sessionId
return this.sessionIds.length && this.sessionIds.indexOf(this.currentParticipant.sessionId) >= 0
},
selfIsModerator() {
return this.participantTypeIsModerator(this.currentParticipant.participantType)
},
isOffline() {
return /* this.participant.status === 'offline' || */ this.sessionId === '0'
return /* this.participant.status === 'offline' || */ !this.sessionIds.length
},
isGuest() {
return [PARTICIPANT.TYPE.GUEST, PARTICIPANT.TYPE.GUEST_MODERATOR].indexOf(this.participantType) !== -1

14
src/store/callViewStore.js

@ -46,11 +46,15 @@ const getters = {
selectedVideoPeerId: (state) => {
return state.selectedVideoPeerId
},
getParticipantRaisedHand: (state) => (sessionId) => {
return state.participantRaisedHands[sessionId] || { state: false, timestamp: null }
},
isParticipantRaisedHand: (state) => (sessionId) => {
return state.participantRaisedHands[sessionId]?.state
getParticipantRaisedHand: (state) => (sessionIds) => {
for (let i = 0; i < sessionIds.length; i++) {
if (state.participantRaisedHands[sessionIds[i]]) {
// note: only the raised states are stored, so no need to confirm
return state.participantRaisedHands[sessionIds[i]]
}
}
return { state: false, timestamp: null }
},
getCachedBackgroundImageAverageColor: (state) => (videoBackgroundId) => {
return state.backgroundImageAverageColorCache[videoBackgroundId]

Loading…
Cancel
Save