Allow specifying participant on email resend API

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
Vincent Petry 2021-01-29 15:54:57 +01:00
Родитель 1b460b842f
Коммит 76543aadc7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E055D6A4D513575C
6 изменённых файлов: 43 добавлений и 8 удалений

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

@ -348,7 +348,7 @@ return [
'url' => '/api/{apiVersion}/room/{token}/participants/emails',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v(1|2|3)',
'apiVersion' => 'v3',
'token' => '^[a-z0-9]{4,30}$',
],
],

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

@ -172,6 +172,12 @@
* Method: `POST`
* Endpoint: `/room/{token}/participants/emails`
* Data:
field | type | Description
------|------|------------
`participant` | string or null | v3 | User for whom to resend email, or null to send to all email actors
* Response:
- Status code:
+ `200 OK`

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

@ -1816,10 +1816,22 @@ class RoomController extends AEnvironmentAwareController {
* @NoAdminRequired
* @RequireModeratorParticipant
*
* @param ?string $participant participant
* @return DataResponse
*/
public function resendEmails(): DataResponse {
$participants = $this->participantService->getParticipantsForRoom($this->room);
public function resendEmails(?string $participant): DataResponse {
$participants = [];
// targetting specific participant
if ($participantId !== null) {
try {
$participants[] = $this->room->getParticipant($participantId);
} catch (ParticipantNotFoundException $e) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}
} else {
$participants = $this->participantService->getParticipantsForRoom($this->room);
}
foreach ($participants as $participant) {
if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_EMAILS) {
// generate PIN if applicable

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

@ -230,7 +230,7 @@ export default {
async handleResendInvitations() {
this.isSendingInvitations = true
try {
await this.$store.dispatch('resendEmailInvitations', this.token)
await this.$store.dispatch('resendEmailInvitations', { token: this.token })
showSuccess(t('spreed', 'Email invitations have been sent'))
} catch (e) {
showError(t('spreed', 'Error occurred when sending email invitations'))

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

@ -251,8 +251,17 @@ const setGuestUserName = async(token, userName) => {
return response
}
const resendEmailInvitations = async(token) => {
await axios.post(generateOcsUrl('apps/spreed/api/v3/room', 2) + token + '/participants/emails')
/**
* Resends email invitations for the given conversation.
* If no userId is set, send to all applicable participants.
*
* @param {string} token conversation token
* @param {string} userId user id to target, or null for all
*/
const resendEmailInvitations = async(token, userId = null) => {
await axios.post(generateOcsUrl('apps/spreed/api/v3/room', 2) + token + '/participants/emails', {
participant: userId,
})
}
export {

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

@ -275,8 +275,16 @@ const actions = {
commit('updateParticipant', { token, index, updatedData })
},
async resendEmailInvitations(_, token) {
await resendEmailInvitations(token)
/**
* Resends email invitations for the given conversation.
* If no userId is set, send to all applicable participants.
*
* @param {Object} _ unused
* @param {string} token conversation token
* @param {string} userId user id to target, or null for all
*/
async resendEmailInvitations(_, { token, userId }) {
await resendEmailInvitations(token, userId)
},
}