feat(xep): Add an event for when someone leaves the MUC
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
PapaTutuWawa 2023-09-26 23:42:49 +02:00
parent 7ca648c478
commit 6dbbf08be4
2 changed files with 18 additions and 0 deletions

View File

@ -24,6 +24,7 @@ class MemberJoinedEvent extends XmppEvent {
final RoomMember member;
}
/// Triggered when an entity changes their presence in the MUC.
class MemberChangedEvent extends XmppEvent {
MemberChangedEvent(this.roomJid, this.member);
@ -33,3 +34,14 @@ class MemberChangedEvent extends XmppEvent {
/// The new member.
final RoomMember member;
}
/// Triggered when an entity leaves the MUC.
class MemberLeftEvent extends XmppEvent {
MemberLeftEvent(this.roomJid, this.nick);
/// The JID of the room.
final JID roomJid;
/// The nick of the user who left.
final String nick;
}

View File

@ -326,6 +326,12 @@ class MUCManager extends XmppManagerBase {
'Should not receive unavailable with role="none" while joining',
);
room.members.remove(from.resource);
getAttributes().sendEvent(
MemberLeftEvent(
bareFrom,
from.resource,
),
);
} else {
final member = RoomMember(
from.resource,