mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 13:52:46 +00:00
Make syncapi use userapi (#1136)
* Make syncapi use userapi * Unbreak things * Fix tests * Lint
This commit is contained in:
parent
1942928ee5
commit
83391da0e0
9 changed files with 106 additions and 28 deletions
|
@ -73,6 +73,39 @@ func (a *UserInternalAPI) QueryDevices(ctx context.Context, req *api.QueryDevice
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *UserInternalAPI) QueryAccountData(ctx context.Context, req *api.QueryAccountDataRequest, res *api.QueryAccountDataResponse) error {
|
||||
local, domain, err := gomatrixserverlib.SplitID('@', req.UserID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if domain != a.ServerName {
|
||||
return fmt.Errorf("cannot query account data of remote users: got %s want %s", domain, a.ServerName)
|
||||
}
|
||||
if req.DataType != "" {
|
||||
var event *gomatrixserverlib.ClientEvent
|
||||
event, err = a.AccountDB.GetAccountDataByType(ctx, local, req.RoomID, req.DataType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if event != nil {
|
||||
if req.RoomID != "" {
|
||||
res.RoomAccountData = make(map[string][]gomatrixserverlib.ClientEvent)
|
||||
res.RoomAccountData[req.RoomID] = []gomatrixserverlib.ClientEvent{*event}
|
||||
} else {
|
||||
res.GlobalAccountData = append(res.GlobalAccountData, *event)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
global, rooms, err := a.AccountDB.GetAccountData(ctx, local)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.RoomAccountData = rooms
|
||||
res.GlobalAccountData = global
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *UserInternalAPI) QueryAccessToken(ctx context.Context, req *api.QueryAccessTokenRequest, res *api.QueryAccessTokenResponse) error {
|
||||
if req.AppServiceUserID != "" {
|
||||
appServiceDevice, err := a.queryAppServiceToken(ctx, req.AccessToken, req.AppServiceUserID)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue