diff --git a/internal/payload/incoming/channel.go b/internal/payload/incoming/channel.go index ab0003970..71f7c5214 100644 --- a/internal/payload/incoming/channel.go +++ b/internal/payload/incoming/channel.go @@ -12,8 +12,8 @@ type ( } ChannelViewRecord struct { - ChannelID string `json:"channelID"` - LastMessageID string `json:"lastMessageID"` + ChannelID uint64 `json:"channelID,string,omitempty"` + LastMessageID uint64 `json:"lastMessageID,string,omitempty"` } ChannelCreate struct { diff --git a/sam/repository/channel_views.go b/sam/repository/channel_views.go index bf1654ea4..b5dd3f5af 100644 --- a/sam/repository/channel_views.go +++ b/sam/repository/channel_views.go @@ -14,7 +14,7 @@ type ( With(ctx context.Context, db *factory.DB) ChannelViewRepository Find(filter *types.ChannelViewFilter) (types.ChannelViewSet, error) - Record(channelID, userID, lastMessageID uint64, count uint32) error + Record(userID, channelID, lastMessageID uint64, count uint32) error Inc(channelID, userID uint64) error Dec(channelID, userID uint64) error } @@ -72,7 +72,7 @@ func (r *channelViews) Find(filter *types.ChannelViewFilter) (types.ChannelViewS } // Records channel view -func (r *channelViews) Record(channelID, userID, lastMessageID uint64, count uint32) error { +func (r *channelViews) Record(userID, channelID, lastMessageID uint64, count uint32) error { mod := &types.ChannelView{ ChannelID: channelID, UserID: userID, diff --git a/sam/service/channel.go b/sam/service/channel.go index 782a12167..bfc0d8860 100644 --- a/sam/service/channel.go +++ b/sam/service/channel.go @@ -50,7 +50,7 @@ type ( Archive(ID uint64) error Unarchive(ID uint64) error Delete(ID uint64) error - RecordView(channelID, userID, lastMessageID uint64) error + RecordView(userID, channelID, lastMessageID uint64) error } // channelSecurity interface { @@ -704,7 +704,7 @@ func (svc *channel) DeleteMember(channelID uint64, memberIDs ...uint64) (err err func (svc *channel) RecordView(channelID, userID, lastMessageID uint64) error { return svc.db.Transaction(func() (err error) { - return svc.cview.Record(channelID, userID, lastMessageID, 0) + return svc.cview.Record(userID, channelID, lastMessageID, 0) }) } diff --git a/sam/websocket/session_incoming_channel.go b/sam/websocket/session_incoming_channel.go index 74cb266fb..ad33ad43c 100644 --- a/sam/websocket/session_incoming_channel.go +++ b/sam/websocket/session_incoming_channel.go @@ -107,17 +107,9 @@ func (s *Session) channelUpdate(ctx context.Context, p *incoming.ChannelUpdate) } func (s *Session) channelViewRecord(ctx context.Context, p *incoming.ChannelViewRecord) error { - var ( - channelID = payload.ParseUInt64(p.ChannelID) - lastMessageID = payload.ParseUInt64(p.LastMessageID) - userID = auth.GetIdentityFromContext(ctx).Identity() - ) + var userID = auth.GetIdentityFromContext(ctx).Identity() - if channelID == 0 || lastMessageID == 0 { - return nil - } - - return s.svc.ch.With(ctx).RecordView(channelID, userID, lastMessageID) + return s.svc.ch.With(ctx).RecordView(userID, p.ChannelID, p.LastMessageID) } // Echoes received channel activity back to all subscribers