Skip to content

Commit

Permalink
fixup! fix: bring back too many recipients check
Browse files Browse the repository at this point in the history
  • Loading branch information
miaulalala committed Mar 20, 2024
1 parent 71c2d48 commit 7eefdee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
6 changes: 0 additions & 6 deletions lib/Service/DraftsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ public function saveMessage(Account $account, LocalMessage $message, array $to,
$message = $this->mapper->saveWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients);

$this->recipientsService->checkNumberOfRecipients($account, $message);
if($message->getStatus() === LocalMessage::STATUS_TOO_MANY_RECIPIENTS && $message->getForce() === false) {
throw new ManyRecipientsException();
}

if ($attachments === []) {
$message->setAttachments($attachments);
Expand Down Expand Up @@ -161,9 +158,6 @@ public function updateMessage(Account $account, LocalMessage $message, array $to
$message = $this->mapper->updateWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients);

$this->recipientsService->checkNumberOfRecipients($account, $message);
if($message->getStatus() === LocalMessage::STATUS_TOO_MANY_RECIPIENTS && $message->getForce() === false) {
throw new ManyRecipientsException();
}

if ($attachments === []) {
$message->setAttachments($this->attachmentService->updateLocalMessageAttachments($account->getUserId(), $message, []));
Expand Down
5 changes: 5 additions & 0 deletions src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,10 @@ export default {
type: Array,
required: true,
},
status: {

Check warning on line 617 in src/components/Composer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Prop 'status' requires default value to be set
type: Number,
required: false,
}

Check warning on line 620 in src/components/Composer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing trailing comma
},
data() {
// Set default custom date time picker value to now + 1 hour
Expand Down Expand Up @@ -1065,6 +1069,7 @@ export default {
smimeSign: this.shouldSmimeSign,
smimeEncrypt: this.shouldSmimeEncrypt,
smimeCertificateId: this.smimeCertificateForCurrentAlias?.id,
status: this.status,
}
},
saveDraft() {
Expand Down
29 changes: 24 additions & 5 deletions src/components/NewMessageModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
:is-first-open="modalFirstOpen"
:request-mdn="composerData.requestMdn"
:accounts="accounts"
:tooManyRecipients="tooManyRecipients"
:force="force"
@update:from-account="patchComposerData({ accountId: $event })"
@update:from-alias="patchComposerData({ aliasId: $event })"
@update:to="patchComposerData({ to: $event })"
Expand Down Expand Up @@ -160,6 +162,8 @@ export default {
canSaveDraft: true,
savingDraft: false,
draftSaved: false,
tooManyRecipients: false,
force: false,
uploadingAttachments: false,
sending: false,
error: undefined,
Expand Down Expand Up @@ -257,18 +261,24 @@ export default {
let idToReturn
const dataForServer = this.getDataForServer(data, true)
if (!id) {
const { id } = await saveDraft(dataForServer)
dataForServer.id = id
await this.$store.dispatch('patchComposerData', { id, draftId: dataForServer.draftId })
const message = await saveDraft(dataForServer)
debugger;

Check failure on line 265 in src/components/NewMessageModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected 'debugger' statement

Check failure on line 265 in src/components/NewMessageModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Extra semicolon
dataForServer.id = message.id
await this.$store.dispatch('patchComposerData', { id, draftId: dataForServer.draftId, status: message.status })
this.canSaveDraft = true
this.draftSaved = true
this.tooManyRecipients = message.status === 8
idToReturn = id
} else {
dataForServer.id = id
await updateDraft(dataForServer)
const message = await updateDraft(dataForServer)
debugger;

Check failure on line 276 in src/components/NewMessageModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected 'debugger' statement

Check failure on line 276 in src/components/NewMessageModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Extra semicolon
await this.$store.dispatch('patchComposerData', { id, status: message.status })
this.canSaveDraft = true
this.draftSaved = true
this.tooManyRecipients = message.status === 8
idToReturn = id
}
Expand Down Expand Up @@ -319,6 +329,7 @@ export default {
inReplyToMessageId: data.inReplyToMessageId,
sendAt: data.sendAt,
draftId: this.composerData?.draftId,
status: this.composerData?.status,
}
},
onAttachmentUploading(done, data) {
Expand Down Expand Up @@ -365,6 +376,11 @@ export default {
}
}
debugger;

Check failure on line 379 in src/components/NewMessageModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected 'debugger' statement

Check failure on line 379 in src/components/NewMessageModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Extra semicolon
if(!force && dataForServer.status === 8) {

Check failure on line 380 in src/components/NewMessageModal.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected space(s) after "if"
throw new ManyRecipientsError()
}
if (!this.composerData.id) {
// This is a new message
const { id } = await saveDraft(dataForServer)
Expand Down Expand Up @@ -407,7 +423,7 @@ export default {
return t('mail', 'No sent mailbox configured. Please pick one in the account settings.')
},
[ManyRecipientsError.getName()]() {
return t('mail', 'You are trying to send to many recipients in To and/or Cc. Consider using Bcc to hide recipient addresses.')
return t('mail', 'Too many recipients. Send anyway?')
},
// eslint-disable-next-line n/handle-callback-err
default(error) {
Expand All @@ -418,6 +434,9 @@ export default {
[AttachmentMissingError.getName()]() {
return t('mail', 'You mentioned an attachment. Did you forget to add it?')
},
[ManyRecipientsError.getName()]() {
return t('mail', 'Too many recipients. Send anyway?')
},
// eslint-disable-next-line n/handle-callback-err
default(error) {
return undefined
Expand Down

0 comments on commit 7eefdee

Please sign in to comment.