diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-02-15 12:19:38 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-02-15 12:19:38 +0900 |
commit | 0f4368a19e344c8e3d74d97d4c9de171e723a9a1 (patch) | |
tree | 2ac5f32360da1264ed6735de747202902d998b21 /lib | |
parent | f3ec748689db531df787d19bcfe76b0a40665b67 (diff) | |
download | libquotient-0f4368a19e344c8e3d74d97d4c9de171e723a9a1.tar.gz libquotient-0f4368a19e344c8e3d74d97d4c9de171e723a9a1.zip |
Disallow sending events to rooms that have been upgraded
This concludes the mandatory part of #235.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/room.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index e1625478..6b9702cd 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -252,11 +252,17 @@ class Room::Private const QString& txnId, BaseJob* call = nullptr); template <typename EvT> - auto requestSetState(const QString& stateKey, const EvT& event) + SetRoomStateWithKeyJob* requestSetState(const QString& stateKey, + const EvT& event) { - // TODO: Queue up state events sending (see #133). - return connection->callApi<SetRoomStateWithKeyJob>( + if (q->successorId().isEmpty()) + { + // TODO: Queue up state events sending (see #133). + return connection->callApi<SetRoomStateWithKeyJob>( id, EvT::matrixTypeId(), stateKey, event.contentJson()); + } + qCWarning(MAIN) << q << "has been upgraded, state won't be set"; + return nullptr; } template <typename EvT> @@ -1332,7 +1338,11 @@ RoomEvent* Room::Private::addAsPending(RoomEventPtr&& event) QString Room::Private::sendEvent(RoomEventPtr&& event) { - return doSendEvent(addAsPending(std::move(event))); + if (q->successorId().isEmpty()) + return doSendEvent(addAsPending(std::move(event))); + + qCWarning(MAIN) << q << "has been upgraded, event won't be sent"; + return {}; } QString Room::Private::doSendEvent(const RoomEvent* pEvent) |