From 4070706fcc91cd46054b00c5f3a267a9d8c44fb7 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Wed, 5 Jan 2022 13:58:47 +0100 Subject: 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. --- lib/events/roommemberevent.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/events/roommemberevent.cpp') 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 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 -- cgit v1.2.3