fix: Fix user avatar update being triggered for every PubSub event

This commit is contained in:
PapaTutuWawa 2023-01-02 17:35:47 +01:00
parent 596693c206
commit 2a3449d0f2

View File

@ -52,6 +52,14 @@ class UserAvatarManager extends XmppManagerBase {
@override @override
Future<void> onXmppEvent(XmppEvent event) async { Future<void> onXmppEvent(XmppEvent event) async {
if (event is PubSubNotificationEvent) { if (event is PubSubNotificationEvent) {
if (event.item.node != userAvatarDataXmlns) return;
if (event.item.payload.tag != 'data' ||
event.item.payload.attributes['xmlns'] != userAvatarDataXmlns) {
logger.warning('Received avatar update from ${event.from} but the payload is invalid. Ignoring...');
return;
}
getAttributes().sendEvent( getAttributes().sendEvent(
AvatarUpdatedEvent( AvatarUpdatedEvent(
jid: event.from, jid: event.from,