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