Change struct fields

This commit is contained in:
Till Faelligen 2021-11-19 21:54:49 +01:00
parent e0fdba5347
commit 7fd146b8e3
3 changed files with 9 additions and 6 deletions

View file

@ -50,7 +50,8 @@ func NewSyncStreamProviders(
},
PresenceDataStreamProvider: &PresenceStreamProvider{
StreamProvider: StreamProvider{DB: d},
UserAPI: userAPI,
userAPI: userAPI,
rsAPI: rsAPI,
},
DeviceListStreamProvider: &DeviceListStreamProvider{
PartitionedStreamProvider: PartitionedStreamProvider{DB: d},

View file

@ -5,6 +5,7 @@ import (
"encoding/json"
"time"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/syncapi/types"
userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib"
@ -12,14 +13,15 @@ import (
type PresenceStreamProvider struct {
StreamProvider
UserAPI userapi.UserInternalAPI
userAPI userapi.UserInternalAPI
rsAPI api.RoomserverInternalAPI
}
func (p *PresenceStreamProvider) Setup() {
p.StreamProvider.Setup()
res := userapi.QueryMaxPresenceIDResponse{}
if err := p.UserAPI.QueryMaxPresenceID(context.Background(), &userapi.QueryMaxPresenceIDRequest{}, &res); err != nil {
if err := p.userAPI.QueryMaxPresenceID(context.Background(), &userapi.QueryMaxPresenceIDRequest{}, &res); err != nil {
panic(err)
}
p.latest = types.StreamPosition(res.ID)
@ -39,7 +41,7 @@ type outputPresence struct {
func (p *PresenceStreamProvider) IncrementalSync(ctx context.Context, req *types.SyncRequest, from, to types.StreamPosition) types.StreamPosition {
res := userapi.QueryPresenceAfterResponse{}
if err := p.UserAPI.QueryPresenceAfter(ctx, &userapi.QueryPresenceAfterRequest{StreamPos: int64(from)}, &res); err != nil {
if err := p.userAPI.QueryPresenceAfter(ctx, &userapi.QueryPresenceAfterRequest{StreamPos: int64(from)}, &res); err != nil {
req.Log.WithError(err).Error("unable to fetch presence after")
return from
}

View file

@ -150,7 +150,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
activeSyncRequests.Inc()
defer activeSyncRequests.Dec()
rp.updatePresence(req, device)
defer rp.updatePresence(req, device)
rp.updateLastSeen(req, device)
waitingSyncRequests.Inc()
@ -273,7 +273,7 @@ func (rp *RequestPool) updatePresence(req *http.Request, device *userapi.Device)
Presence: types2.ToPresenceStatus(presence),
LastActiveTS: time.Now().Unix(),
}
go rp.userAPI.InputPresenceData(req.Context(), pReq, &userapi.InputPresenceResponse{}) // nolint:errcheck
rp.userAPI.InputPresenceData(req.Context(), pReq, &userapi.InputPresenceResponse{}) // nolint:errcheck
}