fromEvent static method
Implementation
static Future<Nip51Set?> fromEvent(
Nip01Event event, EventSigner? signer) async {
String? name = event.getDtag();
if (name == null || event.kind != Nip51List.RELAY_SET) {
return null;
}
Nip51Set set = Nip51Set(
pubKey: event.pubKey,
name: name,
createdAt: event.createdAt,
elements: []);
set.id = event.id;
if (Helpers.isNotBlank(event.content) &&
signer != null &&
signer.canSign()) {
try {
var json = await signer.decrypt(event.content, signer.getPublicKey());
List<dynamic> tags = jsonDecode(json ?? '');
set.parseTags(tags, private: true);
set.parseSetTags(tags);
} catch (e) {
set.name = "<invalid encrypted content>";
Logger.log.d(e);
}
} else {
set.parseTags(event.tags, private: false);
set.parseSetTags(event.tags);
}
return set;
}