mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
fix(systemtags): emit assign and unassign bulk tagging events
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
a35f4b16ac
commit
8e81c1772b
2 changed files with 14 additions and 1 deletions
|
|
@ -286,7 +286,7 @@ class Provider implements IProvider {
|
|||
if ($tagData === null) {
|
||||
[$name, $status] = explode('|||', substr($parameter, 3, -3));
|
||||
$tagData = [
|
||||
'id' => '0',// No way to recover the ID
|
||||
'id' => '0', // No way to recover the ID
|
||||
'name' => $name,
|
||||
'assignable' => $status === 'assignable',
|
||||
'visible' => $status !== 'invisible',
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
|
|||
$currentObjectIds = $this->getObjectIdsForTags($tagId, $objectType);
|
||||
$removedObjectIds = array_diff($currentObjectIds, $objectIds);
|
||||
$addedObjectIds = array_diff($objectIds, $currentObjectIds);
|
||||
|
||||
$this->connection->beginTransaction();
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->delete(self::RELATION_TABLE)
|
||||
|
|
@ -324,6 +325,8 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
|
|||
|
||||
$this->updateEtagForTags([$tagId]);
|
||||
$this->connection->commit();
|
||||
|
||||
// Dispatch assign events for new object ids
|
||||
foreach ($addedObjectIds as $objectId) {
|
||||
$this->dispatcher->dispatch(MapperEvent::EVENT_ASSIGN, new MapperEvent(
|
||||
MapperEvent::EVENT_ASSIGN,
|
||||
|
|
@ -332,6 +335,16 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
|
|||
[(int)$tagId]
|
||||
));
|
||||
}
|
||||
|
||||
// Dispatch unassign events for removed object ids
|
||||
foreach ($removedObjectIds as $objectId) {
|
||||
$this->dispatcher->dispatch(MapperEvent::EVENT_UNASSIGN, new MapperEvent(
|
||||
MapperEvent::EVENT_UNASSIGN,
|
||||
$objectType,
|
||||
(string)$objectId,
|
||||
[(int)$tagId]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue