mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Review comments
This commit is contained in:
parent
2cc70193df
commit
def03e976a
|
|
@ -186,7 +186,7 @@ type Database interface {
|
|||
}
|
||||
|
||||
type Presence interface {
|
||||
GetPresences(ctx context.Context, userID []string) ([]*types.PresenceInternal, error)
|
||||
GetPresences(ctx context.Context, userIDs []string) ([]*types.PresenceInternal, error)
|
||||
UpdatePresence(ctx context.Context, userID string, presence types.Presence, statusMsg *string, lastActiveTS gomatrixserverlib.Timestamp, fromSync bool) (types.StreamPosition, error)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,11 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/syncapi/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
||||
const presenceSchema = `
|
||||
|
|
@ -120,7 +121,8 @@ func (p *presenceStatements) UpsertPresence(
|
|||
return
|
||||
}
|
||||
|
||||
// GetPresenceForUsers returns the current presence of a user.
|
||||
// GetPresenceForUsers returns the current presence for a list of users.
|
||||
// If the user doesn't have a presence status yet, it is omitted from the response.
|
||||
func (p *presenceStatements) GetPresenceForUsers(
|
||||
ctx context.Context, txn *sql.Tx,
|
||||
userIDs []string,
|
||||
|
|
@ -131,6 +133,7 @@ func (p *presenceStatements) GetPresenceForUsers(
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer internal.CloseAndLogIfError(ctx, rows, "GetPresenceForUsers: rows.close() failed")
|
||||
|
||||
for rows.Next() {
|
||||
presence := &types.PresenceInternal{}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,11 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/syncapi/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
||||
const presenceSchema = `
|
||||
|
|
@ -135,7 +136,8 @@ func (p *presenceStatements) UpsertPresence(
|
|||
return
|
||||
}
|
||||
|
||||
// GetPresenceForUsers returns the current presence of a user.
|
||||
// GetPresenceForUsers returns the current presence for a list of users.
|
||||
// If the user doesn't have a presence status yet, it is omitted from the response.
|
||||
func (p *presenceStatements) GetPresenceForUsers(
|
||||
ctx context.Context, txn *sql.Tx,
|
||||
userIDs []string,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package streams
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
|
@ -72,6 +73,7 @@ func (p *PresenceStreamProvider) IncrementalSync(
|
|||
|
||||
getPresenceForUsers, err := p.getNeededUsersFromRequest(ctx, req, presences)
|
||||
if err != nil {
|
||||
req.Log.WithError(err).Error("getNeededUsersFromRequest failed")
|
||||
return from
|
||||
}
|
||||
|
||||
|
|
@ -167,8 +169,7 @@ func (p *PresenceStreamProvider) getNeededUsersFromRequest(ctx context.Context,
|
|||
|
||||
// TODO: Check if this is working better than before.
|
||||
if err := p.notifier.LoadRooms(ctx, p.DB, newlyJoined); err != nil {
|
||||
req.Log.WithError(err).Error("unable to refresh notifier lists")
|
||||
return getPresenceForUsers, err
|
||||
return getPresenceForUsers, fmt.Errorf("unable to refresh notifier lists: %w", err)
|
||||
}
|
||||
for _, roomID := range newlyJoined {
|
||||
roomUsers := p.notifier.JoinedUsers(roomID)
|
||||
|
|
|
|||
Loading…
Reference in a new issue