mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
refactor: migrate memo to apiv1 (#1907)
* refactor: migrate memo to apiv1 * chore: update * chore: update * chore: update * chore: upate * chore: update * chore: update
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/usememos/memos/api"
|
||||
apiv1 "github.com/usememos/memos/api/v1"
|
||||
"github.com/usememos/memos/common"
|
||||
"github.com/usememos/memos/plugin/telegram"
|
||||
@@ -61,20 +60,19 @@ func (t *telegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot,
|
||||
return err
|
||||
}
|
||||
|
||||
// create memo
|
||||
memoCreate := api.CreateMemoRequest{
|
||||
create := &store.Memo{
|
||||
CreatorID: creatorID,
|
||||
Visibility: api.Private,
|
||||
Visibility: store.Private,
|
||||
}
|
||||
|
||||
if message.Text != nil {
|
||||
memoCreate.Content = *message.Text
|
||||
create.Content = *message.Text
|
||||
}
|
||||
if blobs != nil && message.Caption != nil {
|
||||
memoCreate.Content = *message.Caption
|
||||
create.Content = *message.Caption
|
||||
}
|
||||
|
||||
memoMessage, err := t.store.CreateMemo(ctx, convertCreateMemoRequestToMemoMessage(&memoCreate))
|
||||
memoMessage, err := t.store.CreateMemo(ctx, create)
|
||||
if err != nil {
|
||||
_, err := bot.EditMessage(ctx, message.Chat.ID, reply.MessageID, fmt.Sprintf("failed to CreateMemo: %s", err), nil)
|
||||
return err
|
||||
@@ -90,7 +88,7 @@ func (t *telegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot,
|
||||
case ".png":
|
||||
mime = "image/png"
|
||||
}
|
||||
resource, err := t.store.CreateResourceV1(ctx, &store.Resource{
|
||||
resource, err := t.store.CreateResource(ctx, &store.Resource{
|
||||
CreatorID: creatorID,
|
||||
Filename: filename,
|
||||
Type: mime,
|
||||
@@ -103,7 +101,7 @@ func (t *telegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot,
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = t.store.UpsertMemoResource(ctx, &api.MemoResourceUpsert{
|
||||
_, err = t.store.UpsertMemoResource(ctx, &store.UpsertMemoResource{
|
||||
MemoID: memoMessage.ID,
|
||||
ResourceID: resource.ID,
|
||||
})
|
||||
@@ -126,7 +124,7 @@ func (t *telegramHandler) CallbackQueryHandle(ctx context.Context, bot *telegram
|
||||
return bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("fail to parse callbackQuery.Data %s", callbackQuery.Data))
|
||||
}
|
||||
|
||||
update := store.UpdateMemoMessage{
|
||||
update := store.UpdateMemo{
|
||||
ID: memoID,
|
||||
Visibility: &visibility,
|
||||
}
|
||||
|
Reference in New Issue
Block a user