feat(messages): sync saved message tags
This commit is contained in:
parent
a785ae7491
commit
6b3eba6c5d
42 changed files with 1581 additions and 551 deletions
|
|
@ -1165,34 +1165,6 @@ func (s *Service) ClearRecentReactions(ctx context.Context, userID int64) error
|
|||
return s.channels.ClearRecentMessageReactions(ctx, userID)
|
||||
}
|
||||
|
||||
// SavedReactionTags returns account-level saved-message reaction tag titles.
|
||||
func (s *Service) SavedReactionTags(ctx context.Context, userID int64, limit int) ([]domain.SavedReactionTag, error) {
|
||||
if s == nil || s.channels == nil || userID == 0 {
|
||||
return nil, domain.ErrChannelInvalid
|
||||
}
|
||||
if limit <= 0 {
|
||||
return []domain.SavedReactionTag{}, nil
|
||||
}
|
||||
if limit > domain.MaxSavedReactionTags {
|
||||
limit = domain.MaxSavedReactionTags
|
||||
}
|
||||
return s.channels.ListSavedReactionTags(ctx, userID, limit)
|
||||
}
|
||||
|
||||
// UpdateSavedReactionTag stores the account-level custom title for one saved-message reaction tag.
|
||||
func (s *Service) UpdateSavedReactionTag(ctx context.Context, userID int64, tag domain.SavedReactionTag) error {
|
||||
if s == nil || s.channels == nil || userID == 0 {
|
||||
return domain.ErrChannelInvalid
|
||||
}
|
||||
if tag.UserID == 0 {
|
||||
tag.UserID = userID
|
||||
}
|
||||
if tag.UserID != userID || tag.Reaction.Type != domain.MessageReactionEmoji || tag.Reaction.Emoticon == "" {
|
||||
return domain.ErrChannelInvalid
|
||||
}
|
||||
return s.channels.UpsertSavedReactionTag(ctx, tag)
|
||||
}
|
||||
|
||||
// ReadMessageContents returns visible channel messages whose content-read state can be synced.
|
||||
func (s *Service) ReadMessageContents(ctx context.Context, userID int64, req domain.ReadChannelMessageContentsRequest) (domain.ReadChannelMessageContentsResult, error) {
|
||||
if s == nil || s.channels == nil || userID == 0 {
|
||||
|
|
|
|||
|
|
@ -433,6 +433,31 @@ func (s *Service) GetMessageReactions(ctx context.Context, userID int64, req dom
|
|||
return s.messages.GetMessageReactions(ctx, req)
|
||||
}
|
||||
|
||||
// SavedReactionTags returns the global or one-sub-dialog Saved Messages tag list.
|
||||
func (s *Service) SavedReactionTags(ctx context.Context, userID int64, savedPeer domain.Peer, limit int) ([]domain.SavedReactionTag, error) {
|
||||
if s == nil || s.messages == nil || userID == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
if limit <= 0 || limit > domain.MaxSavedReactionTags {
|
||||
limit = domain.MaxSavedReactionTags
|
||||
}
|
||||
return s.messages.ListSavedReactionTags(ctx, domain.SavedReactionTagsRequest{
|
||||
UserID: userID,
|
||||
SavedPeer: savedPeer,
|
||||
Limit: limit,
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateSavedReactionTag stores or removes the optional global title for one
|
||||
// tag that is currently assigned to at least one visible Saved Message.
|
||||
func (s *Service) UpdateSavedReactionTag(ctx context.Context, userID int64, tag domain.SavedReactionTag) error {
|
||||
if s == nil || s.messages == nil || userID == 0 || !tag.Reaction.Valid() {
|
||||
return domain.ErrReactionInvalid
|
||||
}
|
||||
tag.UserID = userID
|
||||
return s.messages.UpsertSavedReactionTag(ctx, tag)
|
||||
}
|
||||
|
||||
// EditMessage 编辑当前账号发出的私聊文本消息。
|
||||
func (s *Service) EditMessage(ctx context.Context, userID int64, req domain.EditMessageRequest) (domain.EditMessageResult, error) {
|
||||
if s == nil || s.messages == nil || userID == 0 {
|
||||
|
|
|
|||
|
|
@ -682,6 +682,14 @@ func (s projectionMessageStore) GetMessageReactions(context.Context, domain.Priv
|
|||
return domain.PrivateMessageReactionsResult{}, nil
|
||||
}
|
||||
|
||||
func (s projectionMessageStore) ListSavedReactionTags(context.Context, domain.SavedReactionTagsRequest) ([]domain.SavedReactionTag, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s projectionMessageStore) UpsertSavedReactionTag(context.Context, domain.SavedReactionTag) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s projectionMessageStore) VoteMessagePoll(context.Context, domain.VotePrivateMessagePollRequest) (domain.PrivateMessagePollResult, error) {
|
||||
return domain.PrivateMessagePollResult{}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,31 +400,9 @@ func (s *Service) PublishNewMessage(ctx context.Context, userID int64, msg domai
|
|||
}, true, 0, false)
|
||||
}
|
||||
|
||||
// RecordMessageReactions records a durable marker for message reaction changes.
|
||||
//
|
||||
// updateMessageReactions has no pts fields in Layer 225, but TDesktop still
|
||||
// needs getDifference to advance account pts and carry the latest reaction
|
||||
// aggregate for offline devices.
|
||||
func (s *Service) RecordMessageReactions(ctx context.Context, authKeyID [8]byte, userID int64, msg domain.Message) (domain.UpdateEvent, domain.UpdateState, error) {
|
||||
if userID == 0 {
|
||||
userID = msg.OwnerUserID
|
||||
}
|
||||
date := msg.Date
|
||||
if date == 0 {
|
||||
date = int(time.Now().Unix())
|
||||
}
|
||||
return s.recordEventWithoutState(ctx, userID, domain.UpdateEvent{
|
||||
Type: domain.UpdateEventMessageReactions,
|
||||
Date: date,
|
||||
Message: msg,
|
||||
Peer: msg.Peer,
|
||||
PtsCount: 1,
|
||||
})
|
||||
}
|
||||
|
||||
// RecordMessagePoll records a durable marker for message poll state changes
|
||||
// (vote / close). updateMessagePoll has no pts fields in Layer 225 — same
|
||||
// bookkeeping shape as RecordMessageReactions.
|
||||
// historical bookkeeping shape pending its own audit.
|
||||
func (s *Service) RecordMessagePoll(ctx context.Context, authKeyID [8]byte, userID int64, msg domain.Message) (domain.UpdateEvent, domain.UpdateState, error) {
|
||||
if userID == 0 {
|
||||
userID = msg.OwnerUserID
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue