setMeta method
Update topic metadata
Implementation
Future<CtrlMessage> setMeta(SetParams params) async {
if (params.tags != null && params.tags!.isNotEmpty) {
params.tags = Tools.normalizeArray(params.tags!);
}
// Send Set message, handle async response.
var ctrl = await _tinodeService.setMeta(name ?? '', params);
if (ctrl.code! >= 300) {
// Not modified
return ctrl;
}
if (params.sub != null) {
params.sub!.topic = name;
if (ctrl.params != null && ctrl.params['acs'] != null) {
params.sub!.acs = AccessMode(ctrl.params['acs']);
params.sub!.updated = ctrl.ts;
}
if (params.sub!.user == null) {
// This is a subscription update of the current user.
// Assign user ID otherwise the update will be ignored by _processMetaSub.
params.sub!.user = _authService.userId;
params.desc ??= TopicDescription();
}
params.sub!.noForwarding = true;
processMetaSub([params.sub!]);
}
if (params.desc != null) {
if (ctrl.params != null && ctrl.params['acs'] != null) {
params.desc!.acs = AccessMode(ctrl.params['acs']);
params.desc!.updated = ctrl.ts;
}
processMetaDesc(params.desc!);
}
if (params.tags != null) {
processMetaTags(params.tags!);
}
if (params.cred != null) {
processMetaCreds([params.cred!], true);
}
return ctrl;
}