Initial storage for Implementation of push notification

This commit is contained in:
Dan Peleg 2021-04-23 21:28:38 +03:00
parent d6e9b7b307
commit dd8b05c310
18 changed files with 537 additions and 0 deletions

View file

@ -29,6 +29,7 @@ import (
"github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/dendrite/userapi/storage/accounts"
"github.com/matrix-org/dendrite/userapi/storage/devices"
"github.com/matrix-org/dendrite/userapi/storage/pushers"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
"github.com/sirupsen/logrus"
@ -37,6 +38,7 @@ import (
type UserInternalAPI struct {
AccountDB accounts.Database
DeviceDB devices.Database
PusherDB pushers.Database
ServerName gomatrixserverlib.ServerName
// AppServices is the list of all registered AS
AppServices []config.ApplicationService
@ -306,6 +308,22 @@ func (a *UserInternalAPI) QueryDevices(ctx context.Context, req *api.QueryDevice
return nil
}
func (a *UserInternalAPI) QueryPushers(ctx context.Context, req *api.QueryPushersRequest, res *api.QueryPushersResponse) error {
local, domain, err := gomatrixserverlib.SplitID('@', req.UserID)
if err != nil {
return err
}
if domain != a.ServerName {
return fmt.Errorf("cannot query pushers of remote users: got %s want %s", domain, a.ServerName)
}
pushers, err := a.PusherDB.GetPushersByLocalpart(ctx, local)
if err != nil {
return err
}
res.Pushers = pushers
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 {