aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-12-09 18:30:36 +0300
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-12-09 18:35:23 +0300
commit3e81ba0da47278f383ce8c329010602f84a50482 (patch)
treef7ab4e3a69ffa60527cd963b22db0767ebb3fc65 /lib/room.cpp
parent608e252bae9cf8cf763e05363bfacf5e1760134f (diff)
downloadlibquotient-3e81ba0da47278f383ce8c329010602f84a50482.tar.gz
libquotient-3e81ba0da47278f383ce8c329010602f84a50482.zip
Room::predecessor() and Room::successor()
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index fe50aa9a..41a8888c 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -387,11 +387,31 @@ QString Room::predecessorId() const
return d->getCurrentState<RoomCreateEvent>()->predecessor().roomId;
}
+Room* Room::predecessor(JoinStates statesFilter) const
+{
+ if (const auto& predId = predecessorId(); !predId.isEmpty())
+ if (auto* r = connection()->room(predId, statesFilter);
+ r && r->successorId() == id())
+ return r;
+
+ return nullptr;
+}
+
QString Room::successorId() const
{
return d->getCurrentState<RoomTombstoneEvent>()->successorRoomId();
}
+Room* Room::successor(JoinStates statesFilter) const
+{
+ if (const auto& succId = successorId(); !succId.isEmpty())
+ if (auto* r = connection()->room(succId, statesFilter);
+ r && r->predecessorId() == id())
+ return r;
+
+ return nullptr;
+}
+
const Room::Timeline& Room::messageEvents() const { return d->timeline; }
const Room::PendingEvents& Room::pendingEvents() const