fix(xep): Do not automatically request vCards
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
PapaTutuWawa 2023-09-26 14:16:41 +02:00
parent 5bd2466c54
commit 814f99436b
4 changed files with 10 additions and 25 deletions

View File

@ -22,6 +22,7 @@
- *BREAKING*: Rename `UserAvatarManager`'s `getUserAvatar` to `getUserAvatarData`. It now also requires the id of the avatar to fetch - *BREAKING*: Rename `UserAvatarManager`'s `getUserAvatar` to `getUserAvatarData`. It now also requires the id of the avatar to fetch
- *BREAKING*: `UserAvatarManager`'s `getAvatarId` with `getLatestMetadata`. - *BREAKING*: `UserAvatarManager`'s `getAvatarId` with `getLatestMetadata`.
- The `PubSubManager` now supports PubSub's `max_items` in `getItems`. - The `PubSubManager` now supports PubSub's `max_items` in `getItems`.
- *BREAKING*: `vCardManager`'s `VCardAvatarUpdatedEvent` no longer automatically requests the newest VCard avatar.
## 0.3.1 ## 0.3.1

View File

@ -184,16 +184,12 @@ class UserAvatarUpdatedEvent extends XmppEvent {
class VCardAvatarUpdatedEvent extends XmppEvent { class VCardAvatarUpdatedEvent extends XmppEvent {
VCardAvatarUpdatedEvent( VCardAvatarUpdatedEvent(
this.jid, this.jid,
this.base64,
this.hash, this.hash,
); );
/// The JID of the entity that updated their avatar. /// The JID of the entity that updated their avatar.
final JID jid; final JID jid;
/// The base64-encoded avatar data.
final String base64;
/// The SHA-1 hash of the avatar. /// The SHA-1 hash of the avatar.
final String hash; final String hash;
} }

View File

@ -129,7 +129,8 @@ class MUCManager extends XmppManagerBase {
); );
return Result(roomInformation); return Result(roomInformation);
} catch (e) { } catch (e) {
return Result(InvalidDiscoInfoResponse); logger.warning('Invalid disco information: $e');
return Result(InvalidDiscoInfoResponse());
} }
} }

View File

@ -56,26 +56,13 @@ class VCardManager extends XmppManagerBase {
final x = presence.firstTag('x', xmlns: vCardTempUpdate)!; final x = presence.firstTag('x', xmlns: vCardTempUpdate)!;
final hash = x.firstTag('photo')!.innerText(); final hash = x.firstTag('photo')!.innerText();
final from = JID.fromString(presence.from!).toBare(); // TODO(Unknown): Use the presence manager interface.
final lastHash = _lastHash[from];
if (lastHash != hash) {
_lastHash[from.toString()] = hash;
final vcardResult = await requestVCard(from);
if (vcardResult.isType<VCard>()) {
final binval = vcardResult.get<VCard>().photo?.binval;
if (binval != null) {
getAttributes().sendEvent( getAttributes().sendEvent(
VCardAvatarUpdatedEvent(from, binval, hash), VCardAvatarUpdatedEvent(
JID.fromString(presence.from!),
hash,
),
); );
} else {
logger.warning('No avatar data found');
}
} else {
logger.warning('Failed to retrieve vCard for $from');
}
}
return state..done = true; return state..done = true;
} }