From f46b64a17d6605f66e3360fd1e9e21af950c64ab Mon Sep 17 00:00:00 2001 From: WonSeok Date: Mon, 4 Mar 2024 12:24:09 +0900 Subject: [PATCH] fix: check disallow public memo in Telegram(#3036) (#3037) --- server/integration/telegram.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/integration/telegram.go b/server/integration/telegram.go index efb6d978..98730d0a 100644 --- a/server/integration/telegram.go +++ b/server/integration/telegram.go @@ -3,6 +3,7 @@ package integration import ( "bytes" "context" + "encoding/json" "fmt" "path/filepath" "strconv" @@ -144,6 +145,23 @@ func (t *TelegramHandler) CallbackQueryHandle(ctx context.Context, bot *telegram return bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("Memo %d not found, possibly deleted elsewhere", memoID)) } + var disablePublicMemo bool + setting, err := t.store.GetWorkspaceSetting(ctx, &store.FindWorkspaceSetting{ + Name: apiv1.SystemSettingDisablePublicMemosName.String(), + }) + if err != nil { + return bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("Failed to get workspace setting %s", err)) + } + + err = json.Unmarshal([]byte(setting.Value), &disablePublicMemo) + if err != nil { + return bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("Failed to get workspace setting %s", err)) + } + + if disablePublicMemo && visibility == store.Public { + return bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("Failed to changing Memo %d to %s\n(workspace disallowed public memo)", memoID, visibility)) + } + update := store.UpdateMemo{ ID: memoID, Visibility: &visibility,