diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-01-05 13:58:47 +0100 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-05-08 17:43:58 +0200 |
commit | 4070706fcc91cd46054b00c5f3a267a9d8c44fb7 (patch) | |
tree | 982d14ed069580596af9b690d83b950b8700781e /lib/events/roommemberevent.cpp | |
parent | d271a171dbec4068e43e8f711d5d2e966a2072ac (diff) | |
download | libquotient-4070706fcc91cd46054b00c5f3a267a9d8c44fb7.tar.gz libquotient-4070706fcc91cd46054b00c5f3a267a9d8c44fb7.zip |
Event content: provide toJson() instead of deriving from EC::Base
EventContent::Base has been made primarily for the sake of dynamic
polymorphism needed within RoomMessageEvent content (arguably, it might
not be really needed even there, but that's a bigger matter for another
time). When that polymorphism is not needed, it's easier for reading
and maintenance to have toJson() member function (or even specialise
JsonConverter<> outside of the content structure) instead of deriving
from EC::Base and then still having fillJson() member function. This
commit removes EventContent::Base dependency where it's not beneficial.
Diffstat (limited to 'lib/events/roommemberevent.cpp')
-rw-r--r-- | lib/events/roommemberevent.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp index 55da5809..c3be0e00 100644 --- a/lib/events/roommemberevent.cpp +++ b/lib/events/roommemberevent.cpp @@ -4,8 +4,6 @@ #include "roommemberevent.h" -#include "logging.h" - #include <QtCore/QtAlgorithms> namespace Quotient { @@ -43,8 +41,9 @@ MemberEventContent::MemberEventContent(const QJsonObject& json) displayName = sanitized(*displayName); } -void MemberEventContent::fillJson(QJsonObject& o) const +QJsonObject MemberEventContent::toJson() const { + QJsonObject o; if (membership != Membership::Invalid) o.insert(QStringLiteral("membership"), MembershipStrings[qCountTrailingZeroBits( @@ -55,6 +54,7 @@ void MemberEventContent::fillJson(QJsonObject& o) const o.insert(QStringLiteral("avatar_url"), avatarUrl->toString()); if (!reason.isEmpty()) o.insert(QStringLiteral("reason"), reason); + return o; } bool RoomMemberEvent::changesMembership() const |