补齐收件回复入口并限制原邮件归属与类型

This commit is contained in:
smail 2026-09-27 20:51:16 +08:00
parent ec1481c99f
commit 0ef04823ab
6 changed files with 13 additions and 3 deletions

View File

@ -18,7 +18,7 @@ func applyReplyThread(ctx *context.Context, input sendRequest, message *parsemai
if id == 0 {
return nil
}
if id < 0 || ctx == nil || ctx.UserID <= 0 || db.Instance == nil || message == nil {
if id < 0 || ctx == nil || ctx.UserID <= 0 || db.Instance == nil {
return validation.ErrInvalidEmail
}
if input.DraftID > 0 {
@ -37,6 +37,7 @@ func applyReplyThread(ctx *context.Context, input sendRequest, message *parsemai
var original models.Email
found, err := db.Instance.ID(id).
Where("status <> ?", consts.EmailStatusDrafts).
And("type = ?", consts.EmailTypeReceive).
And("EXISTS (SELECT 1 FROM user_email WHERE email_id = ? AND user_id = ? AND is_deleted = 0)", id, ctx.UserID).
Get(&original)
if err != nil {

View File

@ -103,7 +103,6 @@ func buildEnvelope(email *response.EmailResponseData, traEmail *parsemail.Email)
Bcc: usersToAddresses(traEmail.Bcc),
MessageID: messageID,
InReplyTo: parsemail.ThreadMessageIDs(email.InReplyTo),
// InReplyTo 和 References 暂不支持
}
}

View File

@ -1,5 +1,6 @@
// 管理后台统一使用中文。
const lang = {
"mail_reply": "回复",
"mail_no_subject": "(无主题)",
"draft_save": "保存草稿",
"draft_saved": "草稿已保存",

View File

@ -23,6 +23,7 @@ const plainBody = message => {
}
export function prepareReply(message, identity) {
if (message.type !== 0) throw new Error(lang.fail)
const replyTo = readAddresses(message.reply_to)
const recipients = replyTo.length ? replyTo : [{EmailAddress: message.from_address, Name: message.from_name}]
if (!recipients.length || recipients.some(item => !item.EmailAddress || /[\r\n]/.test(item.EmailAddress))) {

View File

@ -93,7 +93,7 @@ export function usePage() {
const backToList = () => router.push({name: 'list'})
const handleReply = () => {
const id = Number(detailData.value.id)
if (loading.value || loadError.value || !Number.isSafeInteger(id) || id <= 0) return
if (loading.value || loadError.value || detailData.value.type !== 0 || !Number.isSafeInteger(id) || id <= 0) return
return router.push({name: 'editer', query: {reply: String(id)}})
}

View File

@ -5,6 +5,13 @@
<el-icon><Back /></el-icon>
</el-button>
<div v-if="!loading && !loadError" class="action-buttons">
<el-button
v-if="detailData.type === 0"
type="primary"
@click="handleReply"
>
{{ lang.mail_reply }}
</el-button>
<el-button plain @click="handleDelete" aria-label="删除邮件">
<el-icon><Delete /></el-icon>
</el-button>
@ -90,6 +97,7 @@
import { usePage, Back, Delete, Document, Download } from './EmailDetail.js'
const {
handleReply,
handleDelete,
loading,
loadError,