mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 06:12:45 +00:00
Move MakeJoin logic to GMSL (#3081)
This commit is contained in:
parent
0489d16f95
commit
67d6876857
80 changed files with 1158 additions and 494 deletions
|
@ -858,6 +858,49 @@ func (r *Queryer) QueryAuthChain(ctx context.Context, req *api.QueryAuthChainReq
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *Queryer) InvitePending(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (bool, error) {
|
||||
pending, _, _, _, err := helpers.IsInvitePending(ctx, r.DB, roomID.String(), userID.String())
|
||||
return pending, err
|
||||
}
|
||||
|
||||
func (r *Queryer) QueryRoomInfo(ctx context.Context, roomID spec.RoomID) (*types.RoomInfo, error) {
|
||||
return r.DB.RoomInfo(ctx, roomID.String())
|
||||
}
|
||||
|
||||
func (r *Queryer) CurrentStateEvent(ctx context.Context, roomID spec.RoomID, eventType string, stateKey string) (gomatrixserverlib.PDU, error) {
|
||||
return r.DB.GetStateEvent(ctx, roomID.String(), string(eventType), "")
|
||||
}
|
||||
|
||||
func (r *Queryer) UserJoinedToRoom(ctx context.Context, roomNID types.RoomNID, userID spec.UserID) (bool, error) {
|
||||
_, isIn, _, err := r.DB.GetMembership(ctx, roomNID, userID.String())
|
||||
return isIn, err
|
||||
}
|
||||
|
||||
func (r *Queryer) LocallyJoinedUsers(ctx context.Context, roomVersion gomatrixserverlib.RoomVersion, roomNID types.RoomNID) ([]gomatrixserverlib.PDU, error) {
|
||||
joinNIDs, err := r.DB.GetMembershipEventNIDsForRoom(ctx, roomNID, true, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
events, err := r.DB.Events(ctx, roomVersion, joinNIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// For each of the joined users, let's see if we can get a valid
|
||||
// membership event.
|
||||
joinedUsers := []gomatrixserverlib.PDU{}
|
||||
for _, event := range events {
|
||||
if event.Type() != spec.MRoomMember || event.StateKey() == nil {
|
||||
continue // shouldn't happen
|
||||
}
|
||||
|
||||
joinedUsers = append(joinedUsers, event)
|
||||
}
|
||||
|
||||
return joinedUsers, nil
|
||||
}
|
||||
|
||||
// nolint:gocyclo
|
||||
func (r *Queryer) QueryRestrictedJoinAllowed(ctx context.Context, req *api.QueryRestrictedJoinAllowedRequest, res *api.QueryRestrictedJoinAllowedResponse) error {
|
||||
// Look up if we know anything about the room. If it doesn't exist
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue