fix: update EffectiveUser cannot obtain the accurate user, use GetUserChat instead

This commit is contained in:
krau
2025-02-20 22:52:16 +08:00
parent 09a7c5597d
commit cbc2dc82d8
3 changed files with 9 additions and 5 deletions

View File

@@ -415,7 +415,7 @@ func AddToQueue(ctx *ext.Context, update *ext.Update) error {
ReplyMessageID: record.ReplyMessageID, ReplyMessageID: record.ReplyMessageID,
FileMessageID: record.MessageID, FileMessageID: record.MessageID,
ReplyChatID: record.ReplyChatID, ReplyChatID: record.ReplyChatID,
UserID: update.EffectiveUser().GetID(), UserID: update.GetUserChat().GetID(),
}) })
entityBuilder := entity.Builder{} entityBuilder := entity.Builder{}

View File

@@ -49,6 +49,9 @@ func getSelectStorageMarkup(userChatID int64, fileChatID, fileMessageID int) (*t
return nil, err return nil, err
} }
storages := storage.GetUserStorages(user.ChatID) storages := storage.GetUserStorages(user.ChatID)
if len(storages) == 0 {
return nil, ErrNoStorages
}
buttons := make([]tg.KeyboardButtonClass, 0) buttons := make([]tg.KeyboardButtonClass, 0)
for _, storage := range storages { for _, storage := range storages {
@@ -199,7 +202,7 @@ func ProvideSelectMessage(ctx *ext.Context, update *ext.Update, file *types.File
} else { } else {
text, entities = entityBuilder.Complete() text, entities = entityBuilder.Complete()
} }
markup, err := getSelectStorageMarkup(update.EffectiveUser().GetID(), int(chatID), fileMsgID) markup, err := getSelectStorageMarkup(update.GetUserChat().GetID(), int(chatID), fileMsgID)
if errors.Is(err, ErrNoStorages) { if errors.Is(err, ErrNoStorages) {
logger.L.Errorf("Failed to get select storage markup: %s", err) logger.L.Errorf("Failed to get select storage markup: %s", err)
ctx.EditMessage(update.EffectiveChat().GetID(), &tg.MessagesEditMessageRequest{ ctx.EditMessage(update.EffectiveChat().GetID(), &tg.MessagesEditMessageRequest{

View File

@@ -21,6 +21,7 @@ url = "socks5://127.0.0.1:7890"
name = "本机1" name = "本机1"
# 存储类型, 目前可用: local , alist , webdav # 存储类型, 目前可用: local , alist , webdav
type = "local" type = "local"
# 启用存储
enable = true enable = true
base_path = "./downloads" base_path = "./downloads"
@@ -33,7 +34,7 @@ base_path = "./downloads/2"
[[storages]] [[storages]]
name = "MyAlist" name = "MyAlist"
type = "alist" type = "alist"
enable = true enable = false
base_path = '/' base_path = '/'
url = 'https://alist.com' url = 'https://alist.com'
username = 'admin' username = 'admin'
@@ -48,7 +49,7 @@ token_exp = 86400
name = "MyWebdav" name = "MyWebdav"
type = "webdav" type = "webdav"
base_path = '/path/telegram' base_path = '/path/telegram'
enable = true enable = false
url = 'https://example.com/dav' url = 'https://example.com/dav'
username = 'username' username = 'username'
password = 'password' password = 'password'
@@ -59,7 +60,7 @@ password = 'password'
# user id # user id
id = 123456 id = 123456
# 存储名称过滤列表 # 存储名称过滤列表
storages = ["MyAlist", "本机1"] storages = ["本机1"]
# 开启黑名单模式, 过滤列表中的存储将无法使用, 默认为白名单模式 # 开启黑名单模式, 过滤列表中的存储将无法使用, 默认为白名单模式
blacklist = false blacklist = false