Compare commits

...

2 Commits

Author SHA1 Message Date
5bd2466c54 feat(xep): Parse the room info from the extended disco info
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-09-26 14:00:27 +02:00
14b62cef96 fix(xep): Fix crash for messages with no id 2023-09-26 13:59:51 +02:00
3 changed files with 17 additions and 0 deletions

View File

@ -13,6 +13,7 @@ const subscriptionPreApprovalXmlns = 'urn:xmpp:features:pre-approval';
// XEP-0004
const dataFormsXmlns = 'jabber:x:data';
const formVarFormType = 'FORM_TYPE';
// XEP-0030
const discoInfoXmlns = 'http://jabber.org/protocol/disco#info';
@ -23,6 +24,7 @@ const extendedAddressingXmlns = 'http://jabber.org/protocol/address';
// XEP-0045
const mucXmlns = 'http://jabber.org/protocol/muc';
const roomInfoFormType = 'http://jabber.org/protocol/muc#roominfo';
// XEP-0054
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/namespaces.dart';
import 'package:moxxmpp/src/xeps/xep_0004.dart';
import 'package:moxxmpp/src/xeps/xep_0030/types.dart';
class RoomInformation {
@ -7,6 +10,7 @@ class RoomInformation {
required this.jid,
required this.features,
required this.name,
this.roomInfo,
});
/// Constructs a [RoomInformation] object from a [DiscoInfo] object.
@ -21,6 +25,11 @@ class RoomInformation {
name: discoInfo.identities
.firstWhere((i) => i.category == 'conference')
.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.
@ -31,6 +40,9 @@ class RoomInformation {
/// The name or title of the Multi-User Chat (MUC) room.
final String name;
/// The data form containing room information.
final DataForm? roomInfo;
}
/// The used message-id and an optional origin-id.

View File

@ -282,6 +282,9 @@ class MUCManager extends XmppManagerBase {
}
// Check if this is the message reflection.
if (message.id == null) {
return state;
}
final pending =
(message.id!, state.extensions.get<StableIdData>()?.originId);
if (fromJid.resource == roomState.nick &&