-
Notifications
You must be signed in to change notification settings - Fork 264
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
fix no sent mailbox configured #8311
base: main
Are you sure you want to change the base?
Changes from all commits
d05d43e
de9c8d9
48edd0e
40f8232
b598435
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 |
---|---|---|
|
@@ -127,7 +127,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' | ||
|
@@ -294,6 +294,51 @@ export default { | |
}, | ||
toHtml, | ||
plain, | ||
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) { | ||
await this.setSentMailboxAndResend(account, sentMailboxId, data) | ||
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. I'm missing a return or anything else that leaves this method after setting the existing mailbox |
||
} | ||
logger.info(`creating ${t('mail', 'Sent')} mailbox`) | ||
try { | ||
const newSentMailbox = await this.mainStore.createMailbox({ account, name: account.personalNamespace + t('mail', 'Sent') }) | ||
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. if the IMAP server supports it (likely) we should also set the specialuse attribute to |
||
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') | ||
} | ||
|
||
if (newSentMailboxId) { | ||
await this.setSentMailboxAndResend(account, newSentMailboxId, data) | ||
} else { | ||
showError(t('mail', 'Couldn\'t set sent default folder, please try manually before sending a new message')) | ||
this.$emit('close') | ||
} | ||
}, | ||
|
||
async setSentMailboxAndResend(account, id, data) { | ||
logger.debug('setting sent mailbox to ' + id) | ||
try { | ||
await this.mainStore.patchAccount({ | ||
account, | ||
data: { | ||
sentMailboxId: id, | ||
}, | ||
}) | ||
logger.debug('Resending message after new setting sent mailbox') | ||
this.onSend(data) | ||
showSuccess(t('mail', 'Sent folder set, resending message')) | ||
} catch (error) { | ||
showError(t('mail', 'Couldn\'t set sent default folder, please try manually before sending a new message')) | ||
logger.error('could not set sent mailbox', { error }) | ||
this.$emit('close') | ||
} | ||
}, | ||
/** | ||
* @param data Message data | ||
* @param {object=} opts Options | ||
|
@@ -392,6 +437,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) | ||
return | ||
} | ||
logger.debug('sending message', { data }) | ||
|
||
await this.attachmentsPromise | ||
|
@@ -495,7 +545,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.
nit. first look for the localized, then search for
Sent
. this ensures that the localized takes priority.