Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Commit

Permalink
Handle incoming power level events and add EnsureInvited()
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Aug 30, 2018
1 parent 37d4449 commit fb75624
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,13 @@ func (intent *IntentAPI) SetAvatarURL(avatarURL string) error {
}
return intent.Client.SetAvatarURL(avatarURL)
}

func (intent *IntentAPI) EnsureInvited(roomID, userID string) error {
if !intent.as.StateStore.IsInvited(roomID, userID) {
_, err := intent.Client.InviteUser(roomID, &gomatrix.ReqInviteUser{
UserID: userID,
})
return err
}
return nil
}
2 changes: 2 additions & 0 deletions statestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func (as *AppService) UpdateState(evt *gomatrix.Event) {
switch evt.Type {
case gomatrix.StateMember:
as.StateStore.SetMembership(evt.RoomID, evt.GetStateKey(), evt.Content.Membership)
case gomatrix.StatePowerLevels:
as.StateStore.SetPowerLevels(evt.RoomID, &evt.Content.PowerLevels)
}
}

Expand Down

0 comments on commit fb75624

Please sign in to comment.