Skip to content

Commit f348c4d

Browse files
committed
fix(backend): use a more useful error message when performing message action and no special folder is configured
1 parent 5282a4a commit f348c4d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

modules/imap/handler_modules.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ public function process() {
11271127
foreach ($folders as $folder => $uids) {
11281128
$status['imap_'.$server.'_'.$folder] = $mailbox->get_folder_state();
11291129
$action_result = $this->perform_action($mailbox, $form['action_type'], $uids, $folder, $specials, $server_details);
1130-
if ($action_result['error']) {
1130+
if ($action_result['error'] && ! $action_result['folder_not_found_error']) {
11311131
$errs++;
11321132
} else {
11331133
$msgs += count($uids);
@@ -1197,7 +1197,14 @@ private function perform_action($mailbox, $action_type, $uids, $folder, $special
11971197
}
11981198
}
11991199
}
1200-
return ['error' => $error, 'moved' => $moved];
1200+
1201+
$folderNotFoundError = false;
1202+
if (!$special_folder && $action_type != 'read' && $action_type != 'unread' && $action_type != 'flag' && $action_type != 'unflag') {
1203+
Hm_Msgs::add(sprintf('No %s folder configured for %s. Please go to <a href="?page=folders&imap_server_id=%s">Folders seetting</a> and configure one', $action_type, $server_details['name'], $server_details['id']), empty($moved) ? 'danger' : 'warning');
1204+
$folderNotFoundError = true;
1205+
}
1206+
1207+
return ['error' => $error, 'moved' => $moved, 'folder_not_found_error' => $folderNotFoundError];
12011208
}
12021209

12031210
/**
@@ -1222,9 +1229,6 @@ private function get_special_folder($action_type, $specials, $server_details) {
12221229
} elseif ($action_type == 'junk' && array_key_exists('junk', $specials)) {
12231230
$folder = $specials['junk'];
12241231
}
1225-
if (!$folder && $action_type != 'read' && $action_type != 'unread' && $action_type != 'flag' && $action_type != 'unflag') {
1226-
Hm_Msgs::add(sprintf('ERRNo %s folder configured for %s', $action_type, $server_details['name']));
1227-
}
12281232
return $folder;
12291233
}
12301234
}

0 commit comments

Comments
 (0)