diff options
author | Tobias Fella <9750016+TobiasFella@users.noreply.github.com> | 2021-11-28 20:58:38 +0100 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2021-12-01 21:56:59 +0100 |
commit | 9217026e46d7ac0d761cc5206d7ef00978558c47 (patch) | |
tree | e703d58f0fef4559e759511989349fb6051ea7f9 /lib/events | |
parent | dcc4556a761f96ae6c71115bf6297feca32581bf (diff) | |
download | libquotient-9217026e46d7ac0d761cc5206d7ef00978558c47.tar.gz libquotient-9217026e46d7ac0d761cc5206d7ef00978558c47.zip |
Apply suggestions from code review
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
Diffstat (limited to 'lib/events')
-rw-r--r-- | lib/events/encryptedevent.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/events/encryptedevent.cpp b/lib/events/encryptedevent.cpp index c9257584..2e0d7387 100644 --- a/lib/events/encryptedevent.cpp +++ b/lib/events/encryptedevent.cpp @@ -38,17 +38,15 @@ RoomEventPtr EncryptedEvent::createDecrypted(const QString &decrypted) const eventObject["event_id"] = id(); eventObject["sender"] = senderId(); eventObject["origin_server_ts"] = originTimestamp().toMSecsSinceEpoch(); - if(contentJson().contains("m.relates_to")) { - auto relates = contentJson()["m.relates_to"].toObject(); + if (const auto relatesToJson = contentPart("m.relates_to"_ls); !relatesToJson.isUndefined()) { auto content = eventObject["content"].toObject(); - content["m.relates_to"] = relates; + content["m.relates_to"] = relatesToJson.toObject(); eventObject["content"] = content; } - if(unsignedJson().contains("redacts")) { - auto redacts = unsignedJson()["redacts"].toString(); + if (const auto redactsJson = unsignedPart("redacts"_ls); !redactsJson.isUndefined()) { auto unsign = eventObject["unsigned"].toObject(); - unsign["redacts"] = redacts; + unsign["redacts"] = redactsJson.toString(); eventObject["unsigned"] = unsign; } - return makeEvent<RoomMessageEvent>(eventObject); + return loadEvent<RoomEvent>(eventObject); } |