Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: telegram callback query handler dereferencing nil pointer if memo not found (#3003)

ercd1ae9bf23a055
diff --git a/server/integration/telegram.go b/server/integration/telegram.go
index 2584418a2..4f04175ed 100644
--- a/server/integration/telegram.go
+++ b/server/integration/telegram.go
@@ -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,