feat(xep): Parse the room info from the extended disco info
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
PapaTutuWawa 2023-09-26 14:00:27 +02:00
parent 14b62cef96
commit 5bd2466c54
2 changed files with 14 additions and 0 deletions

View File

@ -13,6 +13,7 @@ const subscriptionPreApprovalXmlns = 'urn:xmpp:features:pre-approval';
// XEP-0004 // XEP-0004
const dataFormsXmlns = 'jabber:x:data'; const dataFormsXmlns = 'jabber:x:data';
const formVarFormType = 'FORM_TYPE';
// XEP-0030 // XEP-0030
const discoInfoXmlns = 'http://jabber.org/protocol/disco#info'; const discoInfoXmlns = 'http://jabber.org/protocol/disco#info';
@ -23,6 +24,7 @@ const extendedAddressingXmlns = 'http://jabber.org/protocol/address';
// XEP-0045 // XEP-0045
const mucXmlns = 'http://jabber.org/protocol/muc'; const mucXmlns = 'http://jabber.org/protocol/muc';
const roomInfoFormType = 'http://jabber.org/protocol/muc#roominfo';
// XEP-0054 // XEP-0054
const vCardTempXmlns = 'vcard-temp'; const vCardTempXmlns = 'vcard-temp';

View File

@ -1,4 +1,7 @@
import 'package:collection/collection.dart';
import 'package:moxxmpp/src/jid.dart'; import 'package:moxxmpp/src/jid.dart';
import 'package:moxxmpp/src/namespaces.dart';
import 'package:moxxmpp/src/xeps/xep_0004.dart';
import 'package:moxxmpp/src/xeps/xep_0030/types.dart'; import 'package:moxxmpp/src/xeps/xep_0030/types.dart';
class RoomInformation { class RoomInformation {
@ -7,6 +10,7 @@ class RoomInformation {
required this.jid, required this.jid,
required this.features, required this.features,
required this.name, required this.name,
this.roomInfo,
}); });
/// Constructs a [RoomInformation] object from a [DiscoInfo] object. /// Constructs a [RoomInformation] object from a [DiscoInfo] object.
@ -21,6 +25,11 @@ class RoomInformation {
name: discoInfo.identities name: discoInfo.identities
.firstWhere((i) => i.category == 'conference') .firstWhere((i) => i.category == 'conference')
.name!, .name!,
roomInfo: discoInfo.extendedInfo.firstWhereOrNull((form) {
final field = form.getFieldByVar(formVarFormType);
return field?.type == 'hidden' &&
field?.values.first == roomInfoFormType;
}),
); );
/// The JID of the Multi-User Chat (MUC) room. /// The JID of the Multi-User Chat (MUC) room.
@ -31,6 +40,9 @@ class RoomInformation {
/// The name or title of the Multi-User Chat (MUC) room. /// The name or title of the Multi-User Chat (MUC) room.
final String name; final String name;
/// The data form containing room information.
final DataForm? roomInfo;
} }
/// The used message-id and an optional origin-id. /// The used message-id and an optional origin-id.