Allow resending invitation emails

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
Vincent Petry 2021-01-29 15:13:40 +01:00
Родитель cfcbb39c52
Коммит bf2b8cfbda
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E055D6A4D513575C
7 изменённых файлов: 68 добавлений и 0 удалений

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

@ -343,6 +343,15 @@ return [
'token' => '^[a-z0-9]{4,30}$',
],
],
[
'name' => 'Room#resendEmails',
'url' => '/api/{apiVersion}/room/{token}/participants/emails',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v(1|2|3)',
'token' => '^[a-z0-9]{4,30}$',
],
],
[
'name' => 'Room#leaveRoom',
'url' => '/api/{apiVersion}/room/{token}/participants/active',

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

@ -168,6 +168,16 @@
`inCall` | int | Flags whether the conflicting session is in a potential call
`lastPing` | int | Timestamp of the last ping of the conflicting session
## Resend participant emails
* Method: `POST`
* Endpoint: `/room/{token}/participants/emails`
* Response:
- Status code:
+ `200 OK`
+ `403 Forbidden` When the current user is not a moderator or owner
+ `404 Not Found` When the conversation could not be found
## Leave a conversation (not available for call and chat anymore)
* Method: `DELETE`

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

@ -1811,4 +1811,20 @@ class RoomController extends AEnvironmentAwareController {
return new DataResponse($this->formatRoomV2andV3($this->room, $this->participant));
}
/**
* @NoAdminRequired
* @RequireModeratorParticipant
*
* @return DataResponse
*/
public function resendEmails(): DataResponse {
$participants = $this->participantService->getParticipantsForRoom($this->room);
foreach ($participants as $participant) {
if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_EMAILS) {
$this->guestManager->sendEmailInvitation($this->room, $participant);
}
}
return new DataResponse();
}
}

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

@ -26,6 +26,7 @@ namespace OCA\Talk;
use Doctrine\DBAL\Exception;
use OCA\Talk\Events\AddEmailEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Defaults;
@ -174,6 +175,9 @@ class GuestManager {
}
public function sendEmailInvitation(Room $room, Participant $participant): void {
if ($participant->getAttendee()->getActorType() !== Attendee::ACTOR_EMAILS) {
throw new \InvalidArgumentException('Cannot send email for non-email participant actor type');
}
$email = $participant->getAttendee()->getActorId();
$pin = $participant->getAttendee()->getPin();

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

@ -88,6 +88,13 @@
<span class="icon icon-clippy" />{{ t('spreed', 'Copy conversation link') }}
</button>
</div>
<div class="app-settings-subsection" v-if="isSharedPublicly">
<button
:disabled="isSendingInvitations"
@click.prevent="handleResendInvitations">
{{ t('spreed', 'Resend email invitations') }}
</button>
</div>
</div>
</template>
@ -109,6 +116,7 @@ export default {
// Switch for the password-editing operation
showPasswordField: false,
isSaving: false,
isSendingInvitations: false,
}
},
@ -218,6 +226,17 @@ export default {
// workaround for https://github.com/Inndy/vue-clipboard2/issues/105
this.$refs.copyLinkButton.focus()
},
async handleResendInvitations() {
this.isSendingInvitations = true
try {
await this.$store.dispatch('resendEmailInvitations', this.token)
showSuccess(t('spreed', 'Email invitations have been sent'))
} catch (e) {
showError(t('spreed', 'Error occurred when sending email invitations'))
}
this.isSendingInvitations = false
},
},
}
</script>

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

@ -251,6 +251,10 @@ const setGuestUserName = async(token, userName) => {
return response
}
const resendEmailInvitations = async(token) => {
await axios.post(generateOcsUrl('apps/spreed/api/v3/room', 2) + token + '/participants/emails')
}
export {
joinConversation,
rejoinConversation,
@ -265,4 +269,5 @@ export {
demoteFromModerator,
fetchParticipants,
setGuestUserName,
resendEmailInvitations,
}

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

@ -24,6 +24,7 @@ import {
promoteToModerator,
demoteFromModerator,
removeAttendeeFromConversation,
resendEmailInvitations,
} from '../services/participantsService'
import {
joinCall,
@ -273,6 +274,10 @@ const actions = {
}
commit('updateParticipant', { token, index, updatedData })
},
async resendEmailInvitations(_, token) {
await resendEmailInvitations(token)
},
}
export default { state, mutations, getters, actions }