Use gomatrixserverlib.Timestamp

This commit is contained in:
Till Faelligen 2022-07-07 15:39:42 +02:00
parent bca42478b6
commit 41d666317b
3 changed files with 6 additions and 6 deletions

View file

@ -157,12 +157,12 @@ func (s *PresenceConsumer) onMessage(ctx context.Context, msg *nats.Msg) bool {
// already checked, so no need to check error // already checked, so no need to check error
p, _ := types.PresenceFromString(presence) p, _ := types.PresenceFromString(presence)
s.EmitPresence(ctx, userID, p, statusMsg, ts, fromSync) s.EmitPresence(ctx, userID, p, statusMsg, gomatrixserverlib.Timestamp(ts), fromSync)
return true return true
} }
func (s *PresenceConsumer) EmitPresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, ts int64, fromSync bool) { func (s *PresenceConsumer) EmitPresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, ts gomatrixserverlib.Timestamp, fromSync bool) {
pos, err := s.db.UpdatePresence(ctx, userID, presence, statusMsg, gomatrixserverlib.Timestamp(ts), fromSync) pos, err := s.db.UpdatePresence(ctx, userID, presence, statusMsg, ts, fromSync)
if err != nil { if err != nil {
logrus.WithError(err).WithField("user", userID).WithField("presence", presence).Warn("failed to updated presence for user") logrus.WithError(err).WithField("user", userID).WithField("presence", presence).Warn("failed to updated presence for user")
return return

View file

@ -61,7 +61,7 @@ type PresencePublisher interface {
} }
type PresenceConsumer interface { type PresenceConsumer interface {
EmitPresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, ts int64, fromSync bool) EmitPresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, ts gomatrixserverlib.Timestamp, fromSync bool)
} }
// NewRequestPool makes a new RequestPool // NewRequestPool makes a new RequestPool
@ -171,7 +171,7 @@ func (rp *RequestPool) updatePresence(db storage.Presence, presence string, user
// the /sync response else we may not return presence: online immediately. // the /sync response else we may not return presence: online immediately.
rp.consumer.EmitPresence( rp.consumer.EmitPresence(
context.Background(), userID, presenceID, newPresence.ClientFields.StatusMsg, context.Background(), userID, presenceID, newPresence.ClientFields.StatusMsg,
int64(gomatrixserverlib.AsTimestamp(time.Now())), true, gomatrixserverlib.AsTimestamp(time.Now()), true,
) )
} }

View file

@ -40,7 +40,7 @@ func (d dummyDB) MaxStreamPositionForPresence(ctx context.Context) (types.Stream
type dummyConsumer struct{} type dummyConsumer struct{}
func (d dummyConsumer) EmitPresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, ts int64, fromSync bool) { func (d dummyConsumer) EmitPresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, ts gomatrixserverlib.Timestamp, fromSync bool) {
} }