diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-03-26 09:28:11 +0100 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-03-26 09:28:11 +0100 |
commit | 3ba2acce470407854bb38b2633675e916a51a904 (patch) | |
tree | a989dc7b92a46f5333ab6056cfa776513c82b87d /lib/events/roomcanonicalaliasevent.h | |
parent | ef59622e3506c7d234c1fff7dea1aa921f965e25 (diff) | |
download | libquotient-3ba2acce470407854bb38b2633675e916a51a904.tar.gz libquotient-3ba2acce470407854bb38b2633675e916a51a904.zip |
AliasesEventContent::toJson(): optimise generated JSON
Diffstat (limited to 'lib/events/roomcanonicalaliasevent.h')
-rw-r--r-- | lib/events/roomcanonicalaliasevent.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/events/roomcanonicalaliasevent.h b/lib/events/roomcanonicalaliasevent.h index 311a5959..5d680de7 100644 --- a/lib/events/roomcanonicalaliasevent.h +++ b/lib/events/roomcanonicalaliasevent.h @@ -37,10 +37,12 @@ namespace EventContent{ , altAliases(fromJson<QStringList>(json["alt_aliases"])) { } - QJsonObject toJson() const + auto toJson() const { - return { { "alias", Quotient::toJson(canonicalAlias) }, - { "alt_aliases", Quotient::toJson(altAliases) } }; + QJsonObject jo; + addParam<IfNotEmpty>(jo, QStringLiteral("alias"), canonicalAlias); + addParam<IfNotEmpty>(jo, QStringLiteral("alt_aliases"), altAliases); + return jo; } QString canonicalAlias; @@ -68,7 +70,6 @@ public: { } QString alias() const { return content().canonicalAlias; } - QStringList altAliases() const { return content().altAliases; } }; REGISTER_EVENT_TYPE(RoomCanonicalAliasEvent) |