Skip to content

Commit

Permalink
fixup! fix no sent mailbox configured
Browse files Browse the repository at this point in the history
Signed-off-by: hamza221 <[email protected]>
  • Loading branch information
hamza221 committed May 8, 2023
1 parent 21d06b2 commit 4a463f6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 58 deletions.
19 changes: 0 additions & 19 deletions lib/Controller/MailboxesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,23 +295,4 @@ public function clearMailbox(int $id): JSONResponse {
$this->mailManager->clearMailbox($account, $mailbox);
return new JSONResponse();
}

/**
* @NoAdminRequired
*
* @param int $accountId
* @param string $name
*
* @return JSONResponse
* @throws ClientException
* @throws ServiceException
* @throws \OCP\AppFramework\Db\DoesNotExistException
*/
public function checkMailbox(int $accountId, string $name): JSONResponse {
$account = $this->accountService->find($this->currentUserId, $accountId);

$mailbox = $this->mailManager->getMailboxByName($account, $name);

return new JSONResponse($mailbox);
}
}
16 changes: 0 additions & 16 deletions lib/Service/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,6 @@ public function getMailboxes(Account $account): array {
return $this->mailboxMapper->findAll($account);
}

/**
* @param Account $account
* @param string $name
*
* @return Mailbox
* @throws ServiceException
*/
public function getMailboxByName(Account $account, string $name): int {
try {
$mailbox = $this->mailboxMapper->find($account, $name);
return $mailbox->getId();
} catch (DoesNotExistException $e) {
return -1;
}
}

/**
* @param Account $account
* @param string $name
Expand Down
18 changes: 4 additions & 14 deletions src/components/NewMessageModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ import { translate as t } from '@nextcloud/l10n'
import logger from '../logger'
import { toPlain, toHtml, plain } from '../util/text'
import { saveDraft } from '../service/MessageService'
import { getMailboxExists } from '../service/MailboxService'
import Composer from './Composer'
import { UNDO_DELAY } from '../store/constants'
import { matchError } from '../errors/match'
Expand Down Expand Up @@ -139,18 +138,9 @@ export default {
const account = this.$store.getters.getAccount(data.accountId)
showWarning(t('mail', 'Setting Sent default folder'))
this.creatingSentMailbox = true
// check if sent mailbox already exists
let sentMailboxId = await getMailboxExists(data.accountId, account.personalNamespace + 'Sent').catch((error) => {
this.creatingSentMailbox = false
showError(t('mail', 'Could not set Sent default folder, Please try manually'))
logger.error('could not find sent mailbox', { error })
this.$emit('close')
})
if (sentMailboxId < 0) {
sentMailboxId = await getMailboxExists(data.accountId, account.personalNamespace + t('mail', 'Sent'))
}
if (sentMailboxId > 0) {
const mailboxes = this.$store.getters.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)
return
}
Expand Down Expand Up @@ -187,7 +177,7 @@ export default {
}).then(() => {
logger.debug('Resending message after new setting sent mailbox')
this.onSend(data)
showSuccess(t('mail', 'New sent folder set, resending message'))
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'))
Expand Down
9 changes: 0 additions & 9 deletions src/service/MailboxService.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ export function getMailboxStatus(id) {
return axios.get(url).then((resp) => resp.data)
}

export function getMailboxExists(id, name) {
const url = generateUrl('/apps/mail/api/mailboxes/{id}/name/{name}', {
id,
name,
})

return axios.get(url).then((resp) => resp.data)
}

export function markMailboxRead(id) {
const url = generateUrl('/apps/mail/api/mailboxes/{id}/read', {
id,
Expand Down

0 comments on commit 4a463f6

Please sign in to comment.