-
Notifications
You must be signed in to change notification settings - Fork 314
fix no sent mailbox configured #8311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3503feb
3f66fea
c19736e
79f9ef3
ee751f7
d56d453
2ac98f8
a9cbe36
047169b
5a3ab61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,7 +118,7 @@ import { | |
| NcEmptyContent as EmptyContent, | ||
| NcModal as Modal, | ||
| } from '@nextcloud/vue' | ||
| import { showError, showSuccess } from '@nextcloud/dialogs' | ||
| import { showError, showSuccess, showWarning } from '@nextcloud/dialogs' | ||
| import { translate as t } from '@nextcloud/l10n' | ||
|
|
||
| import logger from '../logger.js' | ||
|
|
@@ -286,6 +286,57 @@ export default { | |
| handleShow(element) { | ||
| this.additionalTrapElements.push(element) | ||
| }, | ||
| async onNewSentMailbox(data, account) { | ||
| showWarning(t('mail', 'Setting Sent default folder...')) | ||
| let newSentMailboxId = null | ||
| const mailboxes = this.mainStore.getMailboxes(data.accountId) | ||
| const sentMailboxId = mailboxes.find((mailbox) => (mailbox.name === (account.personalNamespace ?? '') + 'Sent') || (mailbox.name === (account.personalNamespace ?? '') + t('mail', 'Sent')))?.databaseId | ||
| if (sentMailboxId) { | ||
| try { | ||
| await this.setSentMailboxAndResend(account, sentMailboxId, data) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the method takes to params. |
||
| showSuccess(t('mail', 'Default sent folder set')) | ||
| this.onSend(data) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||
|
|
||
| } catch (error) { | ||
| logger.error('could not set sent mailbox', { error }) | ||
| showError(t('mail', 'Couldn\'t set sent default folder, please try manually before sending a new message')) | ||
| } | ||
| return | ||
|
|
||
| } | ||
| logger.info(`creating ${t('mail', 'Sent')} mailbox`) | ||
| try { | ||
| const newSentMailbox = await this.mainStore.createMailbox({ account, name: (account.personalNamespace ?? '') + t('mail', 'Sent'), specialUseAttributes: ['\\Sent'] }) | ||
|
Comment on lines
+307
to
+309
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: extract new mailbox name into a variable for code readability and to have the actual mailbox name logged, not just the translation
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| showSuccess(t('mail', 'Default sent folder set')) | ||
| logger.info(`mailbox ${(account.personalNamespace ?? '') + t('mail', 'Sent')} created`) | ||
| newSentMailboxId = newSentMailbox.databaseId | ||
| } catch (error) { | ||
| showError(t('mail', 'Could not create new mailbox, please try setting a sent mailbox manually')) | ||
| logger.error('could not create mailbox', { error }) | ||
| this.$emit('close') | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| await this.setSentMailboxAndResend(account, newSentMailboxId, data) | ||
| this.onSend(data) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing |
||
| } catch (error) { | ||
| logger.error('could not set sent mailbox', { error }) | ||
| showError(t('mail', 'Couldn\'t set sent default folder, please try manually before sending a new message')) | ||
| this.$emit('close') | ||
| } | ||
|
|
||
| }, | ||
|
|
||
| async setSentMailboxAndResend(account, id) { | ||
| logger.debug('setting sent mailbox to ' + id) | ||
| await this.mainStore.patchAccount({ | ||
| account, | ||
| data: { | ||
| sentMailboxId: id, | ||
| }, | ||
| }) | ||
| }, | ||
| /** | ||
| * @param data Message data | ||
| * @param {object=} opts Options | ||
|
|
@@ -385,6 +436,11 @@ export default { | |
| .catch((error) => logger.error('could not upload attachments', { error })) | ||
| }, | ||
| async onSend(data, force = false) { | ||
| const account = this.mainStore.getAccount(data.accountId) | ||
| if (!account?.sentMailboxId) { | ||
| this.onNewSentMailbox(data, account) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing |
||
| return | ||
| } | ||
| logger.debug('sending message', { data }) | ||
|
|
||
| if (this.sending) { | ||
|
|
@@ -498,7 +554,6 @@ export default { | |
| } | ||
|
|
||
| // Sync sent mailbox when it's currently open | ||
| const account = this.mainStore.getAccount(data.accountId) | ||
| if (account && parseInt(this.$route.params.mailboxId, 10) === account.sentMailboxId) { | ||
| setTimeout(() => { | ||
| this.mainStore.syncEnvelopes({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ see Psalm. Missing an import