Commit d00e4fdf authored by Steven's avatar Steven

chore: retire telegram plugin

parent 9a2c4234
package telegram
// Animation represents an animation file.
type Animation struct {
FileID string `json:"file_id"` // FileID is the identifier for this file, which can be used to download or reuse the file
FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Width int `json:"width"` // Width video width as defined by sender
Height int `json:"height"` // Height video height as defined by sender
Duration int `json:"duration"` // Duration of the video in seconds as defined by sender
Thumbnail *PhotoSize `json:"thumb"` // Thumbnail animation thumbnail as defined by sender
FileName string `json:"file_name"` // FileName original animation filename as defined by sender
MimeType string `json:"mime_type"` // MimeType of the file as defined by sender
FileSize int `json:"file_size"`
}
package telegram
import (
"context"
"net/url"
)
// AnswerCallbackQuery make an answerCallbackQuery api request.
func (b *Bot) AnswerCallbackQuery(ctx context.Context, callbackQueryID, text string) error {
formData := url.Values{
"callback_query_id": {callbackQueryID},
"text": {text},
}
err := b.postForm(ctx, "/answerCallbackQuery", formData, nil)
if err != nil {
return err
}
return nil
}
package telegram
import (
"context"
"encoding/json"
"net/url"
"strconv"
"github.com/pkg/errors"
)
// EditMessage make an editMessageText api request.
func (b *Bot) EditMessage(ctx context.Context, chatID, messageID int64, text string, inlineKeyboards [][]InlineKeyboardButton) (*Message, error) {
formData := url.Values{
"message_id": {strconv.FormatInt(messageID, 10)},
"chat_id": {strconv.FormatInt(chatID, 10)},
"text": {text},
}
if len(inlineKeyboards) > 0 {
var markup struct {
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}
markup.InlineKeyboard = inlineKeyboards
data, err := json.Marshal(markup)
if err != nil {
return nil, errors.Wrap(err, "fail to encode inlineKeyboard")
}
formData.Set("reply_markup", string(data))
}
var result Message
err := b.postForm(ctx, "/editMessageText", formData, &result)
if err != nil {
return nil, err
}
return &result, nil
}
package telegram
import (
"context"
"net/url"
)
// GetFile get download info of File by fileID from Telegram.
func (b *Bot) GetFile(ctx context.Context, fileID string) (*File, error) {
formData := url.Values{
"file_id": {fileID},
}
var result File
err := b.postForm(ctx, "/getFile", formData, &result)
if err != nil {
return nil, err
}
return &result, nil
}
package telegram
import (
"context"
"net/url"
"strconv"
)
// GetUpdates make a getUpdates api request.
func (b *Bot) GetUpdates(ctx context.Context, offset int64) ([]Update, error) {
formData := url.Values{
"timeout": {"60"},
"offset": {strconv.FormatInt(offset, 10)},
}
var result []Update
err := b.postForm(ctx, "/getUpdates", formData, &result)
if err != nil {
return nil, err
}
return result, nil
}
package telegram
import (
"context"
"net/url"
"strconv"
)
// SendReplyMessage make a sendMessage api request.
func (b *Bot) SendReplyMessage(ctx context.Context, chatID, replyID int64, text string) (*Message, error) {
formData := url.Values{
"chat_id": {strconv.FormatInt(chatID, 10)},
"text": {text},
}
if replyID > 0 {
formData.Set("reply_to_message_id", strconv.FormatInt(replyID, 10))
}
var result Message
err := b.postForm(ctx, "/sendMessage", formData, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// SendMessage make a sendMessage api request.
func (b *Bot) SendMessage(ctx context.Context, chatID int64, text string) (*Message, error) {
return b.SendReplyMessage(ctx, chatID, 0, text)
}
package telegram
import (
"log/slog"
"path/filepath"
)
type Attachment struct {
FileName string
MimeType string
FileSize int64
Data []byte
}
var mimeTypes = map[string]string{
".jpg": "image/jpeg",
".png": "image/png",
".mp4": "video/mp4", // for video note
".oga": "audio/ogg", // for voice
}
func (b Attachment) GetMimeType() string {
if b.MimeType != "" {
return b.MimeType
}
mime, ok := mimeTypes[filepath.Ext(b.FileName)]
if !ok {
slog.Warn("Unknown file extension", slog.String("file", b.FileName))
return "application/octet-stream"
}
return mime
}
package telegram
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestGetMimeType(t *testing.T) {
tests := []struct {
mimeType string
fileName string
expected string
}{
{
fileName: "file.jpg",
mimeType: "image/jpeg",
expected: "image/jpeg",
},
{
fileName: "file.png",
mimeType: "image/png",
expected: "image/png",
},
{
fileName: "file.pdf",
mimeType: "application/pdf",
expected: "application/pdf",
},
{
fileName: "file.php",
mimeType: "application/x-php",
expected: "application/x-php",
},
{
fileName: "file.xlsx",
mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
expected: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
},
{
fileName: "file.oga",
mimeType: "audio/ogg",
expected: "audio/ogg",
},
{
fileName: "file.jpg",
expected: "image/jpeg",
},
{
fileName: "file.png",
expected: "image/png",
},
{
fileName: "file.mp4",
expected: "video/mp4",
},
{
fileName: "file.pdf",
expected: "application/octet-stream",
},
{
fileName: "file.oga",
expected: "audio/ogg",
},
{
fileName: "file.xlsx",
expected: "application/octet-stream",
},
{
fileName: "file.txt",
expected: "application/octet-stream",
},
}
for _, test := range tests {
attachment := Attachment{
FileName: test.fileName,
MimeType: test.mimeType,
}
require.Equal(t, test.expected, attachment.GetMimeType())
}
}
package telegram
// Audio represents an audio file to be treated as music by the Telegram clients.
type Audio struct {
FileID string `json:"file_id"` // FileID is an identifier for this file, which can be used to download or reuse the file
FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Duration int `json:"duration"` // Duration of the audio in seconds as defined by sender
Performer string `json:"performer"` // Performer of the audio as defined by sender or by audio tags
Title string `json:"title"` // Title of the audio as defined by sender or by audio tags
FileName string `json:"file_name"` // FileName is the original filename as defined by sender
MimeType string `json:"mime_type"` // MimeType of the file as defined by sender
FileSize int `json:"file_size"` // FileSize file size
Thumbnail *PhotoSize `json:"thumb"` // Thumbnail is the album cover to which the music file belongs
}
package telegram
import (
"context"
"errors"
"log/slog"
"strings"
"time"
)
type Handler interface {
BotToken(ctx context.Context) string
MessageHandle(ctx context.Context, bot *Bot, message Message, attachments []Attachment) error
CallbackQueryHandle(ctx context.Context, bot *Bot, callbackQuery CallbackQuery) error
}
type Bot struct {
handler Handler
}
// NewBotWithHandler create a telegram bot with specified handler.
func NewBotWithHandler(h Handler) *Bot {
return &Bot{handler: h}
}
const noTokenWait = 30 * time.Second
const errRetryWait = 10 * time.Second
// Start start a long polling using getUpdates to get Update, call r.MessageHandle while get new message updates.
func (b *Bot) Start(ctx context.Context) {
var offset int64
for {
updates, err := b.GetUpdates(ctx, offset)
if err == ErrInvalidToken {
time.Sleep(noTokenWait)
continue
}
if err != nil {
time.Sleep(errRetryWait)
continue
}
singleMessages := make([]Message, 0, len(updates))
groupMessages := make([]Message, 0, len(updates))
for _, update := range updates {
offset = update.UpdateID + 1
// handle CallbackQuery update
if update.CallbackQuery != nil {
err := b.handler.CallbackQueryHandle(ctx, b, *update.CallbackQuery)
if err != nil {
slog.Error("fail to handle callback query", err)
}
continue
}
// handle Message update
if update.Message != nil {
message := *update.Message
// skip unsupported message
if !message.IsSupported() {
_, err := b.SendReplyMessage(ctx, message.Chat.ID, message.MessageID, "Supported messages: animation, audio, text, document, photo, video, video note, voice, other messages with caption")
if err != nil {
slog.Error("fail to send reply message", err)
}
continue
}
// Group message need do more
if message.MediaGroupID != nil {
groupMessages = append(groupMessages, message)
continue
}
singleMessages = append(singleMessages, message)
continue
}
}
err = b.handleSingleMessages(ctx, singleMessages)
if err != nil {
slog.Error("fail to handle plain text message", err)
}
err = b.handleGroupMessages(ctx, groupMessages)
if err != nil {
slog.Error("fail to handle media group message", err)
}
}
}
var ErrInvalidToken = errors.New("token is invalid")
func (b *Bot) apiURL(ctx context.Context) (string, error) {
token := b.handler.BotToken(ctx)
if token == "" {
return "", ErrInvalidToken
}
if strings.HasPrefix(token, "http") {
return token, nil
}
return "https://api.telegram.org/bot" + token, nil
}
package telegram
// CallbackQuery represents an incoming callback query from a callback button in
// an inline keyboard (PUBLIC, PROTECTED, PRIVATE).
type CallbackQuery struct {
ID string `json:"id"`
From User `json:"from"`
Message *Message `json:"message"`
InlineMessageID string `json:"inline_message_id"`
ChatInstance string `json:"chat_instance"`
Data string `json:"data"`
GameShortName string `json:"game_short_name"`
}
package telegram
type ChatType string
const (
Private = "private"
Group = "group"
SuperGroup = "supergroup"
Channel = "channel"
)
type Chat struct {
ID int64 `json:"id"`
Title string `json:"title"` // Title for supergroups, channels and group chats
Type ChatType `json:"type"` // Type of chat, can be either “private”, “group”, “supergroup” or “channel”
FirstName string `json:"first_name"` // FirstName of the other party in a private chat
LastName string `json:"last_name"` // LastName of the other party in a private chat
UserName string `json:"username"` // UserName for private chats, supergroups and channels if available
}
package telegram
// Document represents a general file.
type Document struct {
FileID string `json:"file_id"` // FileID is an identifier for this file, which can be used to download or reuse the file
FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Thumbnail *PhotoSize `json:"thumb"` // Thumbnail document thumbnail as defined by sender
FileName string `json:"file_name"` // FileName original filename as defined by sender
MimeType string `json:"mime_type"` // MimeType of the file as defined by sender
FileSize int `json:"file_size"`
}
package telegram
import (
"context"
"io"
"net/http"
"strings"
"github.com/pkg/errors"
)
func (b *Bot) downloadAttachment(ctx context.Context, message *Message) (*Attachment, error) {
var fileID, fileName, mimeType string
switch {
case len(message.Photo) > 0:
fileID = message.GetMaxPhotoFileID()
case message.Animation != nil:
fileID = message.Animation.FileID
fileName = message.Animation.FileName
mimeType = message.Animation.MimeType
case message.Audio != nil:
fileID = message.Audio.FileID
fileName = message.Audio.FileName
mimeType = message.Audio.MimeType
case message.Document != nil:
fileID = message.Document.FileID
fileName = message.Document.FileName
mimeType = message.Document.MimeType
case message.Video != nil:
fileID = message.Video.FileID
fileName = message.Video.FileName
mimeType = message.Video.MimeType
case message.VideoNote != nil:
fileID = message.VideoNote.FileID
case message.Voice != nil:
fileID = message.Voice.FileID
mimeType = message.Voice.MimeType
}
if fileID == "" {
return nil, nil
}
attachment, err := b.downloadFileID(ctx, fileID)
if err != nil {
return nil, err
}
if fileName != "" {
attachment.FileName = fileName
}
if mimeType != "" {
attachment.MimeType = mimeType
}
return attachment, nil
}
// downloadFileId download file with fileID, return Blob struct.
func (b *Bot) downloadFileID(ctx context.Context, fileID string) (*Attachment, error) {
file, err := b.GetFile(ctx, fileID)
if err != nil {
return nil, err
}
data, err := b.downloadFilepath(ctx, file.FilePath)
if err != nil {
return nil, err
}
blob := &Attachment{
FileName: file.FilePath,
Data: data,
FileSize: file.FileSize,
}
return blob, nil
}
// downloadFilepath download file with filepath, you can get filepath by calling GetFile.
func (b *Bot) downloadFilepath(ctx context.Context, filePath string) ([]byte, error) {
apiURL, err := b.apiURL(ctx)
if err != nil {
return nil, err
}
idx := strings.LastIndex(apiURL, "/bot")
if idx < 0 {
return nil, ErrInvalidToken
}
fileURL := apiURL[:idx] + "/file" + apiURL[idx:]
resp, err := http.Get(fileURL + "/" + filePath)
if err != nil {
return nil, errors.Wrap(err, "fail to http.Get")
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "fail to io.ReadAll")
}
return body, nil
}
package telegram
type File struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
FileSize int64 `json:"file_size"`
FilePath string `json:"file_path"`
}
package telegram
import (
"context"
)
// handleSingleMessages handle single messages not belongs to group.
func (b *Bot) handleSingleMessages(ctx context.Context, messages []Message) error {
var attachments []Attachment
for _, message := range messages {
attachment, err := b.downloadAttachment(ctx, &message)
if err != nil {
return err
}
if attachment != nil {
attachments = append(attachments, *attachment)
}
err = b.handler.MessageHandle(ctx, b, message, attachments)
if err != nil {
return err
}
}
return nil
}
// handleGroupMessages handle a message belongs to group.
func (b *Bot) handleGroupMessages(ctx context.Context, groupMessages []Message) error {
captions := make(map[string]string, len(groupMessages))
messages := make(map[string]Message, len(groupMessages))
attachments := make(map[string][]Attachment, len(groupMessages))
// Group all captions, blobs and messages.
for _, message := range groupMessages {
groupID := *message.MediaGroupID
messages[groupID] = message
if message.Caption != nil {
captions[groupID] += *message.Caption
}
attachment, err := b.downloadAttachment(ctx, &message)
if err != nil {
return err
}
if attachment != nil {
attachments[groupID] = append(attachments[groupID], *attachment)
}
}
// Handle each group message.
for groupID, message := range messages {
// replace Caption with all Caption in the group.
caption := captions[groupID]
message.Caption = &caption
err := b.handler.MessageHandle(ctx, b, message, attachments[groupID])
if err != nil {
return err
}
}
return nil
}
package telegram
type InlineKeyboardButton struct {
Text string `json:"text"`
CallbackData string `json:"callback_data"`
}
package telegram
import "fmt"
type Message struct {
MessageID int64 `json:"message_id"` // MessageID is a unique message identifier inside this chat
From User `json:"from"` // From is a sender, empty for messages sent to channels;
Date int `json:"date"` // Date of the message was sent in Unix time
Text *string `json:"text"` // Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
Chat *Chat `json:"chat"` // Chat is the conversation the message belongs to
ForwardFromChat *Chat `json:"forward_from_chat"` // ForwardFromChat for messages forwarded from channels, information about the original channel;
ForwardFromMessageID int64 `json:"forward_from_message_id"` // ForwardFromMessageID for messages forwarded from channels, identifier of the original message in the channel;
MediaGroupID *string `json:"media_group_id"` // MediaGroupID is the unique identifier of a media message group this message belongs to;
Photo []PhotoSize `json:"photo"` // Photo message is a photo, available sizes of the photo;
Caption *string `json:"caption"` // Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
Entities []MessageEntity `json:"entities"` // Entities are for text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text;
CaptionEntities []MessageEntity `json:"caption_entities"` // CaptionEntities are for messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption;
Document *Document `json:"document"` // Document message is a general file, information about the file;
Video *Video `json:"video"` // Video message is a video, information about the video;
VideoNote *VideoNote `json:"video_note"` // VideoNote message is a video note, information about the video message;
Voice *Voice `json:"voice"` // Voice message is a voice message, information about the file;
Audio *Audio `json:"audio"` // Audio message is an audio file, information about the file;
Animation *Animation `json:"animation"` // Animation message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set;
}
func (m Message) GetMaxPhotoFileID() string {
var fileSize int64
var photoSize PhotoSize
for _, p := range m.Photo {
if p.FileSize > fileSize {
photoSize = p
}
}
return photoSize.FileID
}
func (m Message) GetMessageLink() string {
if m.ForwardFromChat != nil && m.ForwardFromChat.Type == Channel {
return fmt.Sprintf("https://t.me/%s/%d", m.ForwardFromChat.UserName, m.ForwardFromMessageID)
}
return ""
}
func (m Message) IsSupported() bool {
return m.Text != nil || m.Caption != nil || m.Document != nil || m.Photo != nil || m.Video != nil ||
m.Voice != nil || m.VideoNote != nil || m.Audio != nil || m.Animation != nil
}
package telegram
type MessageEntityType string
const (
Mention = "mention" // “mention” (@username)
Hashtag = "hashtag" // “hashtag” (#hashtag)
CashTag = "cashtag" // “cashtag” ($USD)
BotCommand = "bot_command" // “bot_command” (/start@jobs_bot)
URL = "url" // “url” (https://telegram.org)
Email = "email" // “email” (do-not-reply@telegram.org)
PhoneNumber = "phone_number" // “phone_number” (+1-212-555-0123)
Bold = "bold" // “bold” (bold text)
Italic = "italic" // “italic” (italic text)
Underline = "underline" // “underline” (underlined text)
Strikethrough = "strikethrough" // “strikethrough” (strikethrough text)
Code = "code" // “code” (monowidth string)
Pre = "pre" // “pre” (monowidth block)
Spoiler = "spoiler" // “spoiler” (hidden text)
TextLink = "text_link" // “text_link” (for clickable text URLs)
TextMention = "text_mention" // “text_mention” (for users without usernames)
)
// MessageEntity represents one special entity in a text message.
type MessageEntity struct {
Type MessageEntityType `json:"type"` // Type of the entity.
Offset int `json:"offset"` // Offset in UTF-16 code units to the start of the entity
Length int `json:"length"`
URL string `json:"url"` // URL for “text_link” only, url that will be opened after user taps on the text
User *User `json:"user"` // User for “text_mention” only, the mentioned user
Language string `json:"language"` // Language for “pre” only, the programming language of the entity text
}
package telegram
type PhotoSize struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
FileSize int64 `json:"file_size"`
Width int `json:"width"`
Height int `json:"height"`
}
package telegram
import (
"context"
"encoding/json"
"io"
"net/http"
"net/url"
"github.com/pkg/errors"
)
func (b *Bot) postForm(ctx context.Context, apiPath string, formData url.Values, result any) error {
apiURL, err := b.apiURL(ctx)
if err != nil {
return err
}
resp, err := http.PostForm(apiURL+apiPath, formData)
if err != nil {
return errors.Wrap(err, "fail to http.PostForm")
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return errors.Wrap(err, "fail to ioutil.ReadAll")
}
var respInfo struct {
Ok bool `json:"ok"`
ErrorCode int `json:"error_code"`
Description string `json:"description"`
Result any `json:"result"`
}
respInfo.Result = result
err = json.Unmarshal(body, &respInfo)
if err != nil {
return errors.Wrap(err, "fail to json.Unmarshal")
}
if !respInfo.Ok {
return errors.Errorf("api error: [%d]%s", respInfo.ErrorCode, respInfo.Description)
}
return nil
}
package telegram
type Update struct {
UpdateID int64 `json:"update_id"`
Message *Message `json:"message"`
CallbackQuery *CallbackQuery `json:"callback_query"`
}
package telegram
type User struct {
ID int64 `json:"id"`
}
package telegram
// Video represents a video file.
type Video struct {
FileID string `json:"file_id"` // FileID identifier for this file, which can be used to download or reuse
FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Width int `json:"width"` // Width video width as defined by sender
Height int `json:"height"` // Height video height as defined by sender
Duration int `json:"duration"` // Duration of the video in seconds as defined by sender
Thumbnail *PhotoSize `json:"thumb"` // Thumbnail video thumbnail
FileName string `json:"file_name"` // FileName is the original filename as defined by sender
MimeType string `json:"mime_type"` // MimeType of a file as defined by sender
FileSize int `json:"file_size"`
}
package telegram
// VideoNote object represents a video message.
type VideoNote struct {
FileID string `json:"file_id"` // FileID identifier for this file, which can be used to download or reuse the file
FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Length int `json:"length"` // Length video width and height (diameter of the video message) as defined by sender
Duration int `json:"duration"` // Duration of the video in seconds as defined by sender
Thumbnail *PhotoSize `json:"thumb,omitempty"` // Thumbnail video thumbnail
FileSize int `json:"file_size"`
}
package telegram
// Voice represents a voice note.
type Voice struct {
FileID string `json:"file_id"` // FileID identifier for this file, which can be used to download or reuse the file
FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Duration int `json:"duration"` // Duration of the audio in seconds as defined by sender
MimeType string `json:"mime_type"` // MimeType of the file as defined by sender
FileSize int `json:"file_size"`
}
...@@ -186,8 +186,6 @@ message UserSetting { ...@@ -186,8 +186,6 @@ message UserSetting {
string appearance = 3; string appearance = 3;
// The default visibility of the memo. // The default visibility of the memo.
string memo_visibility = 4; string memo_visibility = 4;
// The telegram user id of the user.
string telegram_user_id = 5;
} }
message GetUserSettingRequest { message GetUserSettingRequest {
......
...@@ -61,7 +61,6 @@ message WorkspaceSetting { ...@@ -61,7 +61,6 @@ message WorkspaceSetting {
WorkspaceGeneralSetting general_setting = 2; WorkspaceGeneralSetting general_setting = 2;
WorkspaceStorageSetting storage_setting = 3; WorkspaceStorageSetting storage_setting = 3;
WorkspaceMemoRelatedSetting memo_related_setting = 4; WorkspaceMemoRelatedSetting memo_related_setting = 4;
WorkspaceTelegramIntegrationSetting telegram_integration_setting = 5;
} }
} }
...@@ -116,8 +115,3 @@ message WorkspaceMemoRelatedSetting { ...@@ -116,8 +115,3 @@ message WorkspaceMemoRelatedSetting {
// display_with_update_time orders and displays memo with update time. // display_with_update_time orders and displays memo with update time.
bool display_with_update_time = 2; bool display_with_update_time = 2;
} }
message WorkspaceTelegramIntegrationSetting {
// bot_token is the telegram bot token.
string bot_token = 1;
}
...@@ -243,7 +243,6 @@ ...@@ -243,7 +243,6 @@
- [WorkspaceMemoRelatedSetting](#memos-api-v2-WorkspaceMemoRelatedSetting) - [WorkspaceMemoRelatedSetting](#memos-api-v2-WorkspaceMemoRelatedSetting)
- [WorkspaceSetting](#memos-api-v2-WorkspaceSetting) - [WorkspaceSetting](#memos-api-v2-WorkspaceSetting)
- [WorkspaceStorageSetting](#memos-api-v2-WorkspaceStorageSetting) - [WorkspaceStorageSetting](#memos-api-v2-WorkspaceStorageSetting)
- [WorkspaceTelegramIntegrationSetting](#memos-api-v2-WorkspaceTelegramIntegrationSetting)
- [WorkspaceStorageSetting.StorageType](#memos-api-v2-WorkspaceStorageSetting-StorageType) - [WorkspaceStorageSetting.StorageType](#memos-api-v2-WorkspaceStorageSetting-StorageType)
...@@ -804,7 +803,6 @@ Used internally for obfuscating the page token. ...@@ -804,7 +803,6 @@ Used internally for obfuscating the page token.
| locale | [string](#string) | | The preferred locale of the user. | | locale | [string](#string) | | The preferred locale of the user. |
| appearance | [string](#string) | | The preferred appearance of the user. | | appearance | [string](#string) | | The preferred appearance of the user. |
| memo_visibility | [string](#string) | | The default visibility of the memo. | | memo_visibility | [string](#string) | | The default visibility of the memo. |
| telegram_user_id | [string](#string) | | The telegram user id of the user. |
...@@ -3325,7 +3323,6 @@ Used internally for obfuscating the page token. ...@@ -3325,7 +3323,6 @@ Used internally for obfuscating the page token.
| general_setting | [WorkspaceGeneralSetting](#memos-api-v2-WorkspaceGeneralSetting) | | | | general_setting | [WorkspaceGeneralSetting](#memos-api-v2-WorkspaceGeneralSetting) | | |
| storage_setting | [WorkspaceStorageSetting](#memos-api-v2-WorkspaceStorageSetting) | | | | storage_setting | [WorkspaceStorageSetting](#memos-api-v2-WorkspaceStorageSetting) | | |
| memo_related_setting | [WorkspaceMemoRelatedSetting](#memos-api-v2-WorkspaceMemoRelatedSetting) | | | | memo_related_setting | [WorkspaceMemoRelatedSetting](#memos-api-v2-WorkspaceMemoRelatedSetting) | | |
| telegram_integration_setting | [WorkspaceTelegramIntegrationSetting](#memos-api-v2-WorkspaceTelegramIntegrationSetting) | | |
...@@ -3350,21 +3347,6 @@ Used internally for obfuscating the page token. ...@@ -3350,21 +3347,6 @@ Used internally for obfuscating the page token.
<a name="memos-api-v2-WorkspaceTelegramIntegrationSetting"></a>
### WorkspaceTelegramIntegrationSetting
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| bot_token | [string](#string) | | bot_token is the telegram bot token. |
<a name="memos-api-v2-WorkspaceStorageSetting-StorageType"></a> <a name="memos-api-v2-WorkspaceStorageSetting-StorageType"></a>
......
This diff is collapsed.
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
- [WorkspaceMemoRelatedSetting](#memos-store-WorkspaceMemoRelatedSetting) - [WorkspaceMemoRelatedSetting](#memos-store-WorkspaceMemoRelatedSetting)
- [WorkspaceSetting](#memos-store-WorkspaceSetting) - [WorkspaceSetting](#memos-store-WorkspaceSetting)
- [WorkspaceStorageSetting](#memos-store-WorkspaceStorageSetting) - [WorkspaceStorageSetting](#memos-store-WorkspaceStorageSetting)
- [WorkspaceTelegramIntegrationSetting](#memos-store-WorkspaceTelegramIntegrationSetting)
- [WorkspaceSettingKey](#memos-store-WorkspaceSettingKey) - [WorkspaceSettingKey](#memos-store-WorkspaceSettingKey)
- [WorkspaceStorageSetting.StorageType](#memos-store-WorkspaceStorageSetting-StorageType) - [WorkspaceStorageSetting.StorageType](#memos-store-WorkspaceStorageSetting-StorageType)
...@@ -437,7 +436,6 @@ ...@@ -437,7 +436,6 @@
| locale | [string](#string) | | | | locale | [string](#string) | | |
| appearance | [string](#string) | | | | appearance | [string](#string) | | |
| memo_visibility | [string](#string) | | | | memo_visibility | [string](#string) | | |
| telegram_user_id | [string](#string) | | |
...@@ -458,7 +456,6 @@ ...@@ -458,7 +456,6 @@
| USER_SETTING_LOCALE | 2 | The locale of the user. | | USER_SETTING_LOCALE | 2 | The locale of the user. |
| USER_SETTING_APPEARANCE | 3 | The appearance of the user. | | USER_SETTING_APPEARANCE | 3 | The appearance of the user. |
| USER_SETTING_MEMO_VISIBILITY | 4 | The visibility of the memo. | | USER_SETTING_MEMO_VISIBILITY | 4 | The visibility of the memo. |
| USER_SETTING_TELEGRAM_USER_ID | 5 | The telegram user id of the user. |
...@@ -560,7 +557,6 @@ ...@@ -560,7 +557,6 @@
| general_setting | [WorkspaceGeneralSetting](#memos-store-WorkspaceGeneralSetting) | | | | general_setting | [WorkspaceGeneralSetting](#memos-store-WorkspaceGeneralSetting) | | |
| storage_setting | [WorkspaceStorageSetting](#memos-store-WorkspaceStorageSetting) | | | | storage_setting | [WorkspaceStorageSetting](#memos-store-WorkspaceStorageSetting) | | |
| memo_related_setting | [WorkspaceMemoRelatedSetting](#memos-store-WorkspaceMemoRelatedSetting) | | | | memo_related_setting | [WorkspaceMemoRelatedSetting](#memos-store-WorkspaceMemoRelatedSetting) | | |
| telegram_integration_setting | [WorkspaceTelegramIntegrationSetting](#memos-store-WorkspaceTelegramIntegrationSetting) | | |
...@@ -585,21 +581,6 @@ ...@@ -585,21 +581,6 @@
<a name="memos-store-WorkspaceTelegramIntegrationSetting"></a>
### WorkspaceTelegramIntegrationSetting
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| bot_token | [string](#string) | | bot_token is the telegram bot token. |
<a name="memos-store-WorkspaceSettingKey"></a> <a name="memos-store-WorkspaceSettingKey"></a>
...@@ -614,7 +595,6 @@ ...@@ -614,7 +595,6 @@
| WORKSPACE_SETTING_GENERAL | 2 | WORKSPACE_SETTING_GENERAL is the key for general settings. | | WORKSPACE_SETTING_GENERAL | 2 | WORKSPACE_SETTING_GENERAL is the key for general settings. |
| WORKSPACE_SETTING_STORAGE | 3 | WORKSPACE_SETTING_STORAGE is the key for storage settings. | | WORKSPACE_SETTING_STORAGE | 3 | WORKSPACE_SETTING_STORAGE is the key for storage settings. |
| WORKSPACE_SETTING_MEMO_RELATED | 4 | WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings. | | WORKSPACE_SETTING_MEMO_RELATED | 4 | WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings. |
| WORKSPACE_SETTING_TELEGRAM_INTEGRATION | 5 | WORKSPACE_SETTING_TELEGRAM_INTEGRATION is the key for telegram integration settings. |
......
This diff is collapsed.
This diff is collapsed.
...@@ -14,8 +14,6 @@ enum UserSettingKey { ...@@ -14,8 +14,6 @@ enum UserSettingKey {
USER_SETTING_APPEARANCE = 3; USER_SETTING_APPEARANCE = 3;
// The visibility of the memo. // The visibility of the memo.
USER_SETTING_MEMO_VISIBILITY = 4; USER_SETTING_MEMO_VISIBILITY = 4;
// The telegram user id of the user.
USER_SETTING_TELEGRAM_USER_ID = 5;
} }
message UserSetting { message UserSetting {
...@@ -26,7 +24,6 @@ message UserSetting { ...@@ -26,7 +24,6 @@ message UserSetting {
string locale = 4; string locale = 4;
string appearance = 5; string appearance = 5;
string memo_visibility = 6; string memo_visibility = 6;
string telegram_user_id = 7;
} }
} }
......
...@@ -14,8 +14,6 @@ enum WorkspaceSettingKey { ...@@ -14,8 +14,6 @@ enum WorkspaceSettingKey {
WORKSPACE_SETTING_STORAGE = 3; WORKSPACE_SETTING_STORAGE = 3;
// WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings. // WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings.
WORKSPACE_SETTING_MEMO_RELATED = 4; WORKSPACE_SETTING_MEMO_RELATED = 4;
// WORKSPACE_SETTING_TELEGRAM_INTEGRATION is the key for telegram integration settings.
WORKSPACE_SETTING_TELEGRAM_INTEGRATION = 5;
} }
message WorkspaceSetting { message WorkspaceSetting {
...@@ -25,7 +23,6 @@ message WorkspaceSetting { ...@@ -25,7 +23,6 @@ message WorkspaceSetting {
WorkspaceGeneralSetting general_setting = 3; WorkspaceGeneralSetting general_setting = 3;
WorkspaceStorageSetting storage_setting = 4; WorkspaceStorageSetting storage_setting = 4;
WorkspaceMemoRelatedSetting memo_related_setting = 5; WorkspaceMemoRelatedSetting memo_related_setting = 5;
WorkspaceTelegramIntegrationSetting telegram_integration_setting = 6;
} }
} }
...@@ -85,8 +82,3 @@ message WorkspaceMemoRelatedSetting { ...@@ -85,8 +82,3 @@ message WorkspaceMemoRelatedSetting {
// display_with_update_time orders and displays memo with update time. // display_with_update_time orders and displays memo with update time.
bool display_with_update_time = 2; bool display_with_update_time = 2;
} }
message WorkspaceTelegramIntegrationSetting {
// bot_token is the telegram bot token.
string bot_token = 1;
}
This diff is collapsed.
...@@ -1035,8 +1035,6 @@ paths: ...@@ -1035,8 +1035,6 @@ paths:
$ref: '#/definitions/apiv2WorkspaceStorageSetting' $ref: '#/definitions/apiv2WorkspaceStorageSetting'
memoRelatedSetting: memoRelatedSetting:
$ref: '#/definitions/apiv2WorkspaceMemoRelatedSetting' $ref: '#/definitions/apiv2WorkspaceMemoRelatedSetting'
telegramIntegrationSetting:
$ref: '#/definitions/apiv2WorkspaceTelegramIntegrationSetting'
title: setting is the setting to update. title: setting is the setting to update.
tags: tags:
- WorkspaceSettingService - WorkspaceSettingService
...@@ -1861,9 +1859,6 @@ paths: ...@@ -1861,9 +1859,6 @@ paths:
memoVisibility: memoVisibility:
type: string type: string
description: The default visibility of the memo. description: The default visibility of the memo.
telegramUserId:
type: string
description: The telegram user id of the user.
tags: tags:
- UserService - UserService
/api/v2/{user.name}: /api/v2/{user.name}:
...@@ -2113,9 +2108,6 @@ definitions: ...@@ -2113,9 +2108,6 @@ definitions:
memoVisibility: memoVisibility:
type: string type: string
description: The default visibility of the memo. description: The default visibility of the memo.
telegramUserId:
type: string
description: The telegram user id of the user.
apiv2WorkspaceCustomProfile: apiv2WorkspaceCustomProfile:
type: object type: object
properties: properties:
...@@ -2173,8 +2165,6 @@ definitions: ...@@ -2173,8 +2165,6 @@ definitions:
$ref: '#/definitions/apiv2WorkspaceStorageSetting' $ref: '#/definitions/apiv2WorkspaceStorageSetting'
memoRelatedSetting: memoRelatedSetting:
$ref: '#/definitions/apiv2WorkspaceMemoRelatedSetting' $ref: '#/definitions/apiv2WorkspaceMemoRelatedSetting'
telegramIntegrationSetting:
$ref: '#/definitions/apiv2WorkspaceTelegramIntegrationSetting'
apiv2WorkspaceStorageSetting: apiv2WorkspaceStorageSetting:
type: object type: object
properties: properties:
...@@ -2206,12 +2196,6 @@ definitions: ...@@ -2206,12 +2196,6 @@ definitions:
- STORAGE_TYPE_DATABASE: STORAGE_TYPE_DATABASE is the database storage type. - STORAGE_TYPE_DATABASE: STORAGE_TYPE_DATABASE is the database storage type.
- STORAGE_TYPE_LOCAL: STORAGE_TYPE_LOCAL is the local storage type. - STORAGE_TYPE_LOCAL: STORAGE_TYPE_LOCAL is the local storage type.
- STORAGE_TYPE_EXTERNAL: STORAGE_TYPE_EXTERNAL is the external storage type. - STORAGE_TYPE_EXTERNAL: STORAGE_TYPE_EXTERNAL is the external storage type.
apiv2WorkspaceTelegramIntegrationSetting:
type: object
properties:
botToken:
type: string
description: bot_token is the telegram bot token.
googlerpcStatus: googlerpcStatus:
type: object type: object
properties: properties:
......
...@@ -266,8 +266,6 @@ func (s *APIV2Service) GetUserSetting(ctx context.Context, _ *apiv2pb.GetUserSet ...@@ -266,8 +266,6 @@ func (s *APIV2Service) GetUserSetting(ctx context.Context, _ *apiv2pb.GetUserSet
userSettingMessage.Appearance = setting.GetAppearance() userSettingMessage.Appearance = setting.GetAppearance()
} else if setting.Key == storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY { } else if setting.Key == storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY {
userSettingMessage.MemoVisibility = setting.GetMemoVisibility() userSettingMessage.MemoVisibility = setting.GetMemoVisibility()
} else if setting.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID {
userSettingMessage.TelegramUserId = setting.GetTelegramUserId()
} }
} }
return &apiv2pb.GetUserSettingResponse{ return &apiv2pb.GetUserSettingResponse{
...@@ -316,16 +314,6 @@ func (s *APIV2Service) UpdateUserSetting(ctx context.Context, request *apiv2pb.U ...@@ -316,16 +314,6 @@ func (s *APIV2Service) UpdateUserSetting(ctx context.Context, request *apiv2pb.U
}); err != nil { }); err != nil {
return nil, status.Errorf(codes.Internal, "failed to upsert user setting: %v", err) return nil, status.Errorf(codes.Internal, "failed to upsert user setting: %v", err)
} }
} else if field == "telegram_user_id" {
if _, err := s.Store.UpsertUserSetting(ctx, &storepb.UserSetting{
UserId: user.ID,
Key: storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID,
Value: &storepb.UserSetting_TelegramUserId{
TelegramUserId: request.Setting.TelegramUserId,
},
}); err != nil {
return nil, status.Errorf(codes.Internal, "failed to upsert user setting: %v", err)
}
} else { } else {
return nil, status.Errorf(codes.InvalidArgument, "invalid update path: %s", field) return nil, status.Errorf(codes.InvalidArgument, "invalid update path: %s", field)
} }
......
...@@ -88,10 +88,6 @@ func convertWorkspaceSettingFromStore(setting *storepb.WorkspaceSetting) *apiv2p ...@@ -88,10 +88,6 @@ func convertWorkspaceSettingFromStore(setting *storepb.WorkspaceSetting) *apiv2p
workspaceSetting.Value = &apiv2pb.WorkspaceSetting_MemoRelatedSetting{ workspaceSetting.Value = &apiv2pb.WorkspaceSetting_MemoRelatedSetting{
MemoRelatedSetting: convertWorkspaceMemoRelatedSettingFromStore(setting.GetMemoRelatedSetting()), MemoRelatedSetting: convertWorkspaceMemoRelatedSettingFromStore(setting.GetMemoRelatedSetting()),
} }
case *storepb.WorkspaceSetting_TelegramIntegrationSetting:
workspaceSetting.Value = &apiv2pb.WorkspaceSetting_TelegramIntegrationSetting{
TelegramIntegrationSetting: convertWorkspaceTelegramIntegrationSettingFromStore(setting.GetTelegramIntegrationSetting()),
}
} }
return workspaceSetting return workspaceSetting
} }
...@@ -117,10 +113,6 @@ func convertWorkspaceSettingToStore(setting *apiv2pb.WorkspaceSetting) *storepb. ...@@ -117,10 +113,6 @@ func convertWorkspaceSettingToStore(setting *apiv2pb.WorkspaceSetting) *storepb.
workspaceSetting.Value = &storepb.WorkspaceSetting_MemoRelatedSetting{ workspaceSetting.Value = &storepb.WorkspaceSetting_MemoRelatedSetting{
MemoRelatedSetting: convertWorkspaceMemoRelatedSettingToStore(setting.GetMemoRelatedSetting()), MemoRelatedSetting: convertWorkspaceMemoRelatedSettingToStore(setting.GetMemoRelatedSetting()),
} }
case storepb.WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION:
workspaceSetting.Value = &storepb.WorkspaceSetting_TelegramIntegrationSetting{
TelegramIntegrationSetting: convertWorkspaceTelegramIntegrationSettingToStore(setting.GetTelegramIntegrationSetting()),
}
} }
return workspaceSetting return workspaceSetting
} }
...@@ -214,21 +206,3 @@ func convertWorkspaceMemoRelatedSettingToStore(setting *apiv2pb.WorkspaceMemoRel ...@@ -214,21 +206,3 @@ func convertWorkspaceMemoRelatedSettingToStore(setting *apiv2pb.WorkspaceMemoRel
DisplayWithUpdateTime: setting.DisplayWithUpdateTime, DisplayWithUpdateTime: setting.DisplayWithUpdateTime,
} }
} }
func convertWorkspaceTelegramIntegrationSettingFromStore(setting *storepb.WorkspaceTelegramIntegrationSetting) *apiv2pb.WorkspaceTelegramIntegrationSetting {
if setting == nil {
return nil
}
return &apiv2pb.WorkspaceTelegramIntegrationSetting{
BotToken: setting.BotToken,
}
}
func convertWorkspaceTelegramIntegrationSettingToStore(setting *apiv2pb.WorkspaceTelegramIntegrationSetting) *storepb.WorkspaceTelegramIntegrationSetting {
if setting == nil {
return nil
}
return &storepb.WorkspaceTelegramIntegrationSetting{
BotToken: setting.BotToken,
}
}
...@@ -11,9 +11,7 @@ import ( ...@@ -11,9 +11,7 @@ import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/usememos/memos/plugin/telegram"
storepb "github.com/usememos/memos/proto/gen/store" storepb "github.com/usememos/memos/proto/gen/store"
"github.com/usememos/memos/server/integration"
"github.com/usememos/memos/server/profile" "github.com/usememos/memos/server/profile"
"github.com/usememos/memos/server/route/api/auth" "github.com/usememos/memos/server/route/api/auth"
apiv2 "github.com/usememos/memos/server/route/api/v2" apiv2 "github.com/usememos/memos/server/route/api/v2"
...@@ -31,9 +29,6 @@ type Server struct { ...@@ -31,9 +29,6 @@ type Server struct {
Secret string Secret string
Profile *profile.Profile Profile *profile.Profile
Store *store.Store Store *store.Store
// Asynchronous runners.
telegramBot *telegram.Bot
} }
func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store) (*Server, error) { func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store) (*Server, error) {
...@@ -46,9 +41,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store ...@@ -46,9 +41,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
e: e, e: e,
Store: store, Store: store,
Profile: profile, Profile: profile,
// Asynchronous runners.
telegramBot: telegram.NewBotWithHandler(integration.NewTelegramHandler(store)),
} }
// Register CORS middleware. // Register CORS middleware.
...@@ -102,7 +94,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store ...@@ -102,7 +94,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
func (s *Server) Start(ctx context.Context) error { func (s *Server) Start(ctx context.Context) error {
go versionchecker.NewVersionChecker(s.Store, s.Profile).Start(ctx) go versionchecker.NewVersionChecker(s.Store, s.Profile).Start(ctx)
go s.telegramBot.Start(ctx)
return s.e.Start(fmt.Sprintf("%s:%d", s.Profile.Addr, s.Profile.Port)) return s.e.Start(fmt.Sprintf("%s:%d", s.Profile.Addr, s.Profile.Port))
} }
......
...@@ -142,8 +142,6 @@ func convertUserSettingFromRaw(raw *UserSetting) (*storepb.UserSetting, error) { ...@@ -142,8 +142,6 @@ func convertUserSettingFromRaw(raw *UserSetting) (*storepb.UserSetting, error) {
userSetting.Value = &storepb.UserSetting_Appearance{Appearance: raw.Value} userSetting.Value = &storepb.UserSetting_Appearance{Appearance: raw.Value}
case storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY: case storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY:
userSetting.Value = &storepb.UserSetting_MemoVisibility{MemoVisibility: raw.Value} userSetting.Value = &storepb.UserSetting_MemoVisibility{MemoVisibility: raw.Value}
case storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID:
userSetting.Value = &storepb.UserSetting_TelegramUserId{TelegramUserId: raw.Value}
default: default:
return nil, errors.Errorf("unsupported user setting key: %v", raw.Key) return nil, errors.Errorf("unsupported user setting key: %v", raw.Key)
} }
...@@ -170,8 +168,6 @@ func convertUserSettingToRaw(userSetting *storepb.UserSetting) (*UserSetting, er ...@@ -170,8 +168,6 @@ func convertUserSettingToRaw(userSetting *storepb.UserSetting) (*UserSetting, er
raw.Value = userSetting.GetAppearance() raw.Value = userSetting.GetAppearance()
case storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY: case storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY:
raw.Value = userSetting.GetMemoVisibility() raw.Value = userSetting.GetMemoVisibility()
case storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID:
raw.Value = userSetting.GetTelegramUserId()
default: default:
return nil, errors.Errorf("unsupported user setting key: %v", userSetting.Key) return nil, errors.Errorf("unsupported user setting key: %v", userSetting.Key)
} }
......
...@@ -71,8 +71,6 @@ func (s *Store) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Wo ...@@ -71,8 +71,6 @@ func (s *Store) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Wo
valueBytes, err = protojson.Marshal(upsert.GetStorageSetting()) valueBytes, err = protojson.Marshal(upsert.GetStorageSetting())
} else if upsert.Key == storepb.WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED { } else if upsert.Key == storepb.WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED {
valueBytes, err = protojson.Marshal(upsert.GetMemoRelatedSetting()) valueBytes, err = protojson.Marshal(upsert.GetMemoRelatedSetting())
} else if upsert.Key == storepb.WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION {
valueBytes, err = protojson.Marshal(upsert.GetTelegramIntegrationSetting())
} else { } else {
return nil, errors.Errorf("unsupported workspace setting key: %v", upsert.Key) return nil, errors.Errorf("unsupported workspace setting key: %v", upsert.Key)
} }
...@@ -233,12 +231,6 @@ func convertWorkspaceSettingFromRaw(workspaceSettingRaw *WorkspaceSetting) (*sto ...@@ -233,12 +231,6 @@ func convertWorkspaceSettingFromRaw(workspaceSettingRaw *WorkspaceSetting) (*sto
return nil, err return nil, err
} }
workspaceSetting.Value = &storepb.WorkspaceSetting_MemoRelatedSetting{MemoRelatedSetting: memoRelatedSetting} workspaceSetting.Value = &storepb.WorkspaceSetting_MemoRelatedSetting{MemoRelatedSetting: memoRelatedSetting}
case storepb.WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION.String():
telegramIntegrationSetting := &storepb.WorkspaceTelegramIntegrationSetting{}
if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), telegramIntegrationSetting); err != nil {
return nil, err
}
workspaceSetting.Value = &storepb.WorkspaceSetting_TelegramIntegrationSetting{TelegramIntegrationSetting: telegramIntegrationSetting}
default: default:
return nil, errors.Errorf("unsupported workspace setting key: %v", workspaceSettingRaw.Name) return nil, errors.Errorf("unsupported workspace setting key: %v", workspaceSettingRaw.Name)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment