feat(xep): Move to JID
This commit is contained in:
parent
327f695a40
commit
925a46c0da
@ -56,17 +56,17 @@ 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().toString();
|
final from = JID.fromString(presence.from!).toBare();
|
||||||
final lastHash = _lastHash[from];
|
final lastHash = _lastHash[from];
|
||||||
if (lastHash != hash) {
|
if (lastHash != hash) {
|
||||||
_lastHash[from] = hash;
|
_lastHash[from.toString()] = hash;
|
||||||
final vcardResult = await requestVCard(from);
|
final vcardResult = await requestVCard(from);
|
||||||
|
|
||||||
if (vcardResult.isType<VCard>()) {
|
if (vcardResult.isType<VCard>()) {
|
||||||
final binval = vcardResult.get<VCard>().photo?.binval;
|
final binval = vcardResult.get<VCard>().photo?.binval;
|
||||||
if (binval != null) {
|
if (binval != null) {
|
||||||
getAttributes().sendEvent(
|
getAttributes().sendEvent(
|
||||||
VCardAvatarUpdatedEvent(JID.fromString(from), binval, hash),
|
VCardAvatarUpdatedEvent(from, binval, hash),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.warning('No avatar data found');
|
logger.warning('No avatar data found');
|
||||||
@ -98,11 +98,11 @@ class VCardManager extends XmppManagerBase {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Result<VCardError, VCard>> requestVCard(String jid) async {
|
Future<Result<VCardError, VCard>> requestVCard(JID jid) async {
|
||||||
final result = (await getAttributes().sendStanza(
|
final result = (await getAttributes().sendStanza(
|
||||||
StanzaDetails(
|
StanzaDetails(
|
||||||
Stanza.iq(
|
Stanza.iq(
|
||||||
to: jid,
|
to: jid.toString(),
|
||||||
type: 'get',
|
type: 'get',
|
||||||
children: [
|
children: [
|
||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
|
Loading…
Reference in New Issue
Block a user