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"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/util"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type getEventRequest struct {
|
||||
|
|
@ -79,10 +80,11 @@ func GetEvent(
|
|||
stateReq := api.QueryStateAfterEventsRequest{
|
||||
RoomID: r.requestedEvent.RoomID(),
|
||||
PrevEventIDs: r.requestedEvent.PrevEventIDs(),
|
||||
StateToFetch: []gomatrixserverlib.StateKeyTuple{{
|
||||
EventType: gomatrixserverlib.MRoomMember,
|
||||
StateKey: device.UserID,
|
||||
}},
|
||||
// XXX: Appservices require you to fetch the lot
|
||||
// StateToFetch: []gomatrixserverlib.StateKeyTuple{{
|
||||
// EventType: gomatrixserverlib.MRoomMember,
|
||||
// StateKey: device.UserID,
|
||||
// }},
|
||||
}
|
||||
var stateResp api.QueryStateAfterEventsResponse
|
||||
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"),
|
||||
}
|
||||
}
|
||||
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 {
|
||||
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
|
||||
}
|
||||
membership, err := stateEvent.Membership()
|
||||
|
|
|
|||
|
|
@ -241,6 +241,9 @@ type Device struct {
|
|||
LastSeenTS int64
|
||||
LastSeenIP 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.
|
||||
|
|
|
|||
|
|
@ -380,6 +380,7 @@ func (a *UserInternalAPI) queryAppServiceToken(ctx context.Context, token, appSe
|
|||
ID: types.AppServiceDeviceID,
|
||||
// AS dummy device has AS's token.
|
||||
AccessToken: token,
|
||||
AppserviceID: appService.ID,
|
||||
}
|
||||
|
||||
localpart, err := userutil.ParseUsernameParam(appServiceUserID, &a.ServerName)
|
||||
|
|
|
|||
Loading…
Reference in a new issue