aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-12-09 18:31:59 +0300
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-12-11 20:00:27 +0300
commit6b2847de2325f2b818dc336c9339d50de58604ea (patch)
tree14b51a29c519c86199a73d917320557a1e754212 /lib/room.cpp
parent4b56d47284500ab61f8e0c5cd7c807c58e1b53cb (diff)
downloadlibquotient-6b2847de2325f2b818dc336c9339d50de58604ea.tar.gz
libquotient-6b2847de2325f2b818dc336c9339d50de58604ea.zip
Pass action scope to Room::setTags
The tags can now be applied not only to the current room but also propagated to its predecessors and successors.
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 41a8888c..60b9a684 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -948,12 +948,27 @@ void Room::removeTag(const QString& name)
<< "not found, nothing to remove";
}
-void Room::setTags(TagsMap newTags)
+void Room::setTags(TagsMap newTags, ActionScope applyOn)
{
+ bool propagate = applyOn != ActionScope::ThisRoomOnly;
+ auto joinStates =
+ applyOn == ActionScope::WithinSameState ? joinState() :
+ applyOn == ActionScope::OmitLeftState ? JoinState::Join|JoinState::Invite :
+ JoinState::Join|JoinState::Invite|JoinState::Leave;
+ if (propagate) {
+ for (auto* r = this; (r = r->predecessor(joinStates));)
+ r->setTags(newTags, ActionScope::ThisRoomOnly);
+ }
+
d->setTags(move(newTags));
connection()->callApi<SetAccountDataPerRoomJob>(
localUser()->id(), id(), TagEvent::matrixTypeId(),
TagEvent(d->tags).contentJson());
+
+ if (propagate) {
+ for (auto* r = this; (r = r->successor(joinStates));)
+ r->setTags(newTags, ActionScope::ThisRoomOnly);
+ }
}
void Room::Private::setTags(TagsMap newTags)