Skip to content

Commit

Permalink
Revert "Don't update resource on webhook notifications if not needed"
Browse files Browse the repository at this point in the history
This reverts commit a090559.
  • Loading branch information
RandyCupic committed Oct 24, 2023
1 parent a090559 commit ec3356e
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions bundle/Controller/Callback/Cloudinary/Notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,26 +257,19 @@ private function handleTagsChanged(array $requestContent): void
continue;
}

$changed = false;

foreach ($resourceData['added'] ?? [] as $tag) {
$resource->addTag($tag);
$changed = true;
}

foreach ($resourceData['removed'] ?? [] as $tag) {
$resource->removeTag($tag);
$changed = true;
}

foreach ($resourceData['updated'] ?? [] as $tag) {
$resource->addTag($tag);
$changed = true;
}

if ($changed === true) {
$this->provider->store($resource);
}
$this->provider->store($resource);
}
}

Expand Down Expand Up @@ -312,10 +305,7 @@ private function handleContextChanged(array $requestContent): void
continue;
}

$changed = false;

foreach ($resourceData['added'] ?? [] as $value) {
$changed = true;
switch ($value['name']) {
case 'alt':
$resource->setAltText($value['value']);
Expand All @@ -335,7 +325,6 @@ private function handleContextChanged(array $requestContent): void
}

foreach ($resourceData['removed'] ?? [] as $value) {
$changed = true;
switch ($value['name']) {
case 'alt':
$resource->setAltText(null);
Expand All @@ -355,15 +344,13 @@ private function handleContextChanged(array $requestContent): void
}

foreach ($resourceData['updated'] ?? [] as $value) {
$changed = true;
switch ($value['name']) {
case 'alt':
$resource->setAltText($value['value']);
break;

case 'caption':
$resource->setCaption($value['value'])
$changed = true;
$resource->setCaption($value['value']);
break;

case 'original_filename':
Expand All @@ -375,9 +362,7 @@ private function handleContextChanged(array $requestContent): void
}
}

if ($changed === true) {
$this->provider->store($resource);
}
$this->provider->store($resource);
}
}

Expand Down

0 comments on commit ec3356e

Please sign in to comment.