feat(xep): Checked for the occupant-id directly.

Signed-off-by: Ikjot Singh Dhody <ikjotsd@gmail.com>
This commit is contained in:
Ikjot Singh Dhody 2023-06-11 23:29:17 +05:30
parent ac5bb9e461
commit fa11a3a384

View File

@ -39,6 +39,8 @@ class OccupantIdManager extends XmppManagerBase {
List<StanzaHandler> getIncomingStanzaHandlers() => [ List<StanzaHandler> getIncomingStanzaHandlers() => [
StanzaHandler( StanzaHandler(
stanzaTag: 'message', stanzaTag: 'message',
tagName: 'occupant-id',
tagXmlns: occupantIdXmlns,
callback: _onMessage, callback: _onMessage,
// Before the MessageManager // Before the MessageManager
priority: -99, priority: -99,
@ -52,15 +54,7 @@ class OccupantIdManager extends XmppManagerBase {
Stanza stanza, Stanza stanza,
StanzaHandlerData state, StanzaHandlerData state,
) async { ) async {
OccupantIdData? occupantId; state.extensions.set(OccupantIdData(stanza.attributes['id']! as String));
final occupantIdElement =
stanza.firstTag('occupant-id', xmlns: occupantIdXmlns);
// Process the occupant id
if (occupantIdElement != null) {
occupantId =
OccupantIdData(occupantIdElement.attributes['id']! as String);
state.extensions.set(occupantId);
}
return state; return state;
} }
} }