mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
Finish implementing retiring invites (#1166)
* Pass retired invites to the syncapi with the event ID of the invite * Implement retire invite streaming * Update whitelist
This commit is contained in:
parent
c1d2382e6d
commit
4897beabee
16 changed files with 204 additions and 81 deletions
|
@ -62,7 +62,7 @@ const insertInviteEventSQL = "" +
|
|||
" ON CONFLICT DO NOTHING"
|
||||
|
||||
const selectInviteActiveForUserInRoomSQL = "" +
|
||||
"SELECT sender_nid FROM roomserver_invites" +
|
||||
"SELECT invite_event_id, sender_nid FROM roomserver_invites" +
|
||||
" WHERE target_nid = $1 AND room_nid = $2" +
|
||||
" AND NOT retired"
|
||||
|
||||
|
@ -141,21 +141,24 @@ func (s *inviteStatements) UpdateInviteRetired(
|
|||
func (s *inviteStatements) SelectInviteActiveForUserInRoom(
|
||||
ctx context.Context,
|
||||
targetUserNID types.EventStateKeyNID, roomNID types.RoomNID,
|
||||
) ([]types.EventStateKeyNID, error) {
|
||||
) ([]types.EventStateKeyNID, []string, error) {
|
||||
rows, err := s.selectInviteActiveForUserInRoomStmt.QueryContext(
|
||||
ctx, targetUserNID, roomNID,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
defer internal.CloseAndLogIfError(ctx, rows, "selectInviteActiveForUserInRoom: rows.close() failed")
|
||||
var result []types.EventStateKeyNID
|
||||
var eventIDs []string
|
||||
for rows.Next() {
|
||||
var inviteEventID string
|
||||
var senderUserNID int64
|
||||
if err := rows.Scan(&senderUserNID); err != nil {
|
||||
return nil, err
|
||||
if err := rows.Scan(&inviteEventID, &senderUserNID); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
result = append(result, types.EventStateKeyNID(senderUserNID))
|
||||
eventIDs = append(eventIDs, inviteEventID)
|
||||
}
|
||||
return result, rows.Err()
|
||||
return result, eventIDs, rows.Err()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue