Cleanup record-view func signatures & types
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user