mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 08:13:09 -06:00
Changes that I made a long time ago
This commit is contained in:
parent
a5ba01eb76
commit
1da0a21923
|
|
@ -23,6 +23,7 @@ import (
|
||||||
userapi "github.com/matrix-org/dendrite/userapi/api"
|
userapi "github.com/matrix-org/dendrite/userapi/api"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type getEventRequest struct {
|
type getEventRequest struct {
|
||||||
|
|
@ -79,10 +80,11 @@ func GetEvent(
|
||||||
stateReq := api.QueryStateAfterEventsRequest{
|
stateReq := api.QueryStateAfterEventsRequest{
|
||||||
RoomID: r.requestedEvent.RoomID(),
|
RoomID: r.requestedEvent.RoomID(),
|
||||||
PrevEventIDs: r.requestedEvent.PrevEventIDs(),
|
PrevEventIDs: r.requestedEvent.PrevEventIDs(),
|
||||||
StateToFetch: []gomatrixserverlib.StateKeyTuple{{
|
// XXX: Appservices require you to fetch the lot
|
||||||
EventType: gomatrixserverlib.MRoomMember,
|
// StateToFetch: []gomatrixserverlib.StateKeyTuple{{
|
||||||
StateKey: device.UserID,
|
// EventType: gomatrixserverlib.MRoomMember,
|
||||||
}},
|
// StateKey: device.UserID,
|
||||||
|
// }},
|
||||||
}
|
}
|
||||||
var stateResp api.QueryStateAfterEventsResponse
|
var stateResp api.QueryStateAfterEventsResponse
|
||||||
if err := rsAPI.QueryStateAfterEvents(req.Context(), &stateReq, &stateResp); err != nil {
|
if err := rsAPI.QueryStateAfterEvents(req.Context(), &stateReq, &stateResp); err != nil {
|
||||||
|
|
@ -102,9 +104,24 @@ func GetEvent(
|
||||||
JSON: jsonerror.NotFound("The event was not found or you do not have permission to read this event"),
|
JSON: jsonerror.NotFound("The event was not found or you do not have permission to read this event"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var appService *config.ApplicationService
|
||||||
|
if device.AppserviceID != "" {
|
||||||
|
for _, as := range cfg.Derived.ApplicationServices {
|
||||||
|
if as.ID == device.AppserviceID {
|
||||||
|
appService = &as
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, stateEvent := range stateResp.StateEvents {
|
for _, stateEvent := range stateResp.StateEvents {
|
||||||
if !stateEvent.StateKeyEquals(device.UserID) {
|
if stateEvent.Type() != gomatrixserverlib.MRoomMember {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// Allow appservices to fetch events
|
||||||
|
if appService != nil && !appService.IsInterestedInUserID(*stateEvent.StateKey()) {
|
||||||
|
continue
|
||||||
|
} else if stateEvent.StateKeyEquals(device.UserID) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
membership, err := stateEvent.Membership()
|
membership, err := stateEvent.Membership()
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,9 @@ type Device struct {
|
||||||
LastSeenTS int64
|
LastSeenTS int64
|
||||||
LastSeenIP string
|
LastSeenIP string
|
||||||
UserAgent string
|
UserAgent string
|
||||||
|
// If the device is for an appservice user,
|
||||||
|
// this is the appservice ID.
|
||||||
|
AppserviceID string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account represents a Matrix account on this home server.
|
// Account represents a Matrix account on this home server.
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,8 @@ func (a *UserInternalAPI) queryAppServiceToken(ctx context.Context, token, appSe
|
||||||
// Use AS dummy device ID
|
// Use AS dummy device ID
|
||||||
ID: types.AppServiceDeviceID,
|
ID: types.AppServiceDeviceID,
|
||||||
// AS dummy device has AS's token.
|
// AS dummy device has AS's token.
|
||||||
AccessToken: token,
|
AccessToken: token,
|
||||||
|
AppserviceID: appService.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
localpart, err := userutil.ParseUsernameParam(appServiceUserID, &a.ServerName)
|
localpart, err := userutil.ParseUsernameParam(appServiceUserID, &a.ServerName)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue