feat(telegram): 移除评论删除功能,仅保留批准操作
- 移除 Telegram 通知中的“删除”按钮,仅保留“批准”按钮以简化审核流程 - 更新 Telegram webhook 回调处理,不再支持 delete 动作,并返回提示信息 - 同步更新相关文档,删除关于“删除”操作的描述 - 新增图标资源文件
This commit is contained in:
@@ -267,9 +267,6 @@ export const postComment = async (c: Context<{ Bindings: Bindings }>) => {
|
||||
|
||||
if (defaultStatus === 'pending') {
|
||||
buttons.push({ text: "批准", callback_data: `approve:${commentId}` });
|
||||
buttons.push({ text: "删除", callback_data: `delete:${commentId}` });
|
||||
} else {
|
||||
buttons.push({ text: "删除", callback_data: `delete:${commentId}` });
|
||||
}
|
||||
|
||||
const message = `
|
||||
@@ -283,11 +280,14 @@ ${contentText}
|
||||
#ID:${commentId}
|
||||
`.trim();
|
||||
|
||||
await sendTelegramMessage(tgSettings.botToken, tgSettings.chatId, message, {
|
||||
reply_markup: {
|
||||
const options: any = {};
|
||||
if (buttons.length > 0) {
|
||||
options.reply_markup = {
|
||||
inline_keyboard: [buttons]
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
await sendTelegramMessage(tgSettings.botToken, tgSettings.chatId, message, options);
|
||||
}
|
||||
} catch (tgError) {
|
||||
console.error('Telegram Notification Failed:', tgError);
|
||||
|
||||
@@ -44,11 +44,7 @@ async function handleCallbackQuery(c: Context<{ Bindings: Bindings }>, token: st
|
||||
const newText = message.text + '\n\n✅ 已批准 (Approved)';
|
||||
await editMessageText(token, chatId, messageId, newText);
|
||||
await answerCallbackQuery(token, id, '评论已批准');
|
||||
} else if (action === 'delete') {
|
||||
await c.env.CWD_DB.prepare('DELETE FROM Comment WHERE id = ?').bind(commentId).run();
|
||||
|
||||
const newText = message.text + '\n\n🗑️ 已删除 (Deleted)';
|
||||
await editMessageText(token, chatId, messageId, newText);
|
||||
await answerCallbackQuery(token, id, '评论已删除');
|
||||
} else {
|
||||
await answerCallbackQuery(token, id, '当前仅支持审核操作');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user