Skip to content

Commit 5a0439f

Browse files
skjnldsvbackportbot[bot]
authored andcommitted
fix(systemtags): emit assign and unassign bulk tagging events
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent c23e4b3 commit 5a0439f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

apps/systemtags/lib/Activity/Provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ protected function getSystemTagParameter($parameter) {
286286
if ($tagData === null) {
287287
[$name, $status] = explode('|||', substr($parameter, 3, -3));
288288
$tagData = [
289-
'id' => '0',// No way to recover the ID
289+
'id' => '0', // No way to recover the ID
290290
'name' => $name,
291291
'assignable' => $status === 'assignable',
292292
'visible' => $status !== 'invisible',

lib/private/SystemTag/SystemTagObjectMapper.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ public function setObjectIdsForTag(string $tagId, string $objectType, array $obj
287287
$currentObjectIds = $this->getObjectIdsForTags($tagId, $objectType);
288288
$removedObjectIds = array_diff($currentObjectIds, $objectIds);
289289
$addedObjectIds = array_diff($objectIds, $currentObjectIds);
290+
290291
$this->connection->beginTransaction();
291292
$query = $this->connection->getQueryBuilder();
292293
$query->delete(self::RELATION_TABLE)
@@ -324,6 +325,8 @@ public function setObjectIdsForTag(string $tagId, string $objectType, array $obj
324325

325326
$this->updateEtagForTags([$tagId]);
326327
$this->connection->commit();
328+
329+
// Dispatch assign events for new object ids
327330
foreach ($addedObjectIds as $objectId) {
328331
$this->dispatcher->dispatch(MapperEvent::EVENT_ASSIGN, new MapperEvent(
329332
MapperEvent::EVENT_ASSIGN,
@@ -332,6 +335,16 @@ public function setObjectIdsForTag(string $tagId, string $objectType, array $obj
332335
[(int)$tagId]
333336
));
334337
}
338+
339+
// Dispatch unassign events for removed object ids
340+
foreach ($removedObjectIds as $objectId) {
341+
$this->dispatcher->dispatch(MapperEvent::EVENT_UNASSIGN, new MapperEvent(
342+
MapperEvent::EVENT_UNASSIGN,
343+
$objectType,
344+
(string)$objectId,
345+
[(int)$tagId]
346+
));
347+
}
335348
}
336349

337350
/**

0 commit comments

Comments
 (0)