mirror of
https://github.com/usememos/memos.git
synced 2024-12-25 14:42:55 +08:00
fix: telegram callback query handler dereferencing nil pointer if memo not found (#3003)
* fix: telegram callback query handler dereferencing nil pointer if memo not found * chore: add an answer to callback query if memo not found
This commit is contained in:
parent
51a7934616
commit
1ae9bf23a0
1 changed files with 14 additions and 0 deletions
|
@ -130,6 +130,20 @@ func (t *TelegramHandler) CallbackQueryHandle(ctx context.Context, bot *telegram
|
|||
return bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("Failed to parse callbackQuery.Data %s", callbackQuery.Data))
|
||||
}
|
||||
|
||||
memo, err := t.store.GetMemo(ctx, &store.FindMemo{
|
||||
ID: &memoID,
|
||||
})
|
||||
if err != nil {
|
||||
return bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("Failed to call FindMemo %s", err))
|
||||
}
|
||||
if memo == nil {
|
||||
_, err = bot.EditMessage(ctx, callbackQuery.Message.Chat.ID, callbackQuery.Message.MessageID, fmt.Sprintf("Memo %d not found", memoID), nil)
|
||||
if err != nil {
|
||||
return bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("Failed to EditMessage %s", err))
|
||||
}
|
||||
return bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("Memo %d not found, possibly deleted elsewhere", memoID))
|
||||
}
|
||||
|
||||
update := store.UpdateMemo{
|
||||
ID: memoID,
|
||||
Visibility: &visibility,
|
||||
|
|
Loading…
Reference in a new issue