Make post request to add participants

Signed-off-by: Marco Ambrosini <marcoambrosini@pm.me>
This commit is contained in:
Marco Ambrosini 2019-11-12 13:35:41 +01:00
Родитель a517e34a09
Коммит 47dc885239
3 изменённых файлов: 33 добавлений и 4 удалений

Просмотреть файл

@ -171,8 +171,10 @@ export default {
},
methods: {
handleClick(event) {
this.$emit('clickParticipant', event)
handleClick() {
if (this.isSearched) {
this.$emit('clickParticipant', this.participant)
}
},
participantTypeIsModerator(participantType) {
return [PARTICIPANT.TYPE.OWNER, PARTICIPANT.TYPE.MODERATOR, PARTICIPANT.TYPE.GUEST_MODERATOR].indexOf(participantType) !== -1

Просмотреть файл

@ -34,6 +34,7 @@
<script>
import Participant from './Participant/Participant'
import { addParticipant } from '../../../../services/participantsService'
export default {
name: 'ParticipantsList',
@ -54,12 +55,20 @@ export default {
computed: {
CurrentConversationParticipants() {
return this.$store.getters.participantsList
},
token() {
return this.$route.params.token
}
},
methods: {
handleClickParticipant(event) {
console.debug(event)
handleClickParticipant(participant) {
try {
const response = addParticipant(this.token, participant.id, participant.source)
console.debug(response)
} catch (exeption) {
console.debug(exeption)
}
},
},
}

Просмотреть файл

@ -52,6 +52,23 @@ const leaveConversation = async function(token) {
}
}
/**
* Add a participant to a conversation.
* @param {token} token the conversation token.
* @param {string} newParticipant the id of the new participant
* @param {string} source the source Source of the participant as returned by the autocomplete suggestion endpoint (default is users)
*/
const addParticipant = async function(token, newParticipant, source) {
debugger
const response = await axios.post(generateOcsUrl('apps/spreed/api/v1', 2) + `room/${token}/participants`, {
params: {
newParticipant,
source,
}
})
return response
}
/**
* Removes the the current user from the conversation specified with the token.
*
@ -112,6 +129,7 @@ const fetchParticipants = async(token) => {
export {
joinConversation,
leaveConversation,
addParticipant,
removeCurrentUserFromConversation,
removeUserFromConversation,
removeGuestFromConversation,