publishUserAvatarMetadata method
- UserAvatarMetadata metadata,
- bool public
Publish avatar metadata metadata
to the User Avatar's metadata node. If public
is true, then the node will be set to an 'open' access model. If public
is false,
then the node will be set to an 'roster' access model.
Implementation
Future<Result<AvatarError, bool>> publishUserAvatarMetadata(
UserAvatarMetadata metadata,
bool public,
) async {
final pubsub = _getPubSubManager();
final result = await pubsub.publish(
getAttributes().getFullJID().toBare(),
userAvatarMetadataXmlns,
XMLNode.xmlns(
tag: 'metadata',
xmlns: userAvatarMetadataXmlns,
children: [
XMLNode(
tag: 'info',
attributes: <String, String>{
'bytes': metadata.length.toString(),
'height': metadata.height.toString(),
'width': metadata.width.toString(),
'type': metadata.type,
'id': metadata.id,
},
),
],
),
id: metadata.id,
options: PubSubPublishOptions(
accessModel: public ? 'open' : 'roster',
),
);
if (result.isType<PubSubError>()) return Result(UnknownAvatarError());
return const Result(true);
}