Refactor duplicate code for parsing photo URL

This commit is contained in:
Matthew Exon 2020-01-09 21:41:35 +01:00 committed by Matthew Exon
parent a5895f8623
commit 95e65e37ee
2 changed files with 26 additions and 13 deletions

View file

@ -215,12 +215,10 @@ class Mail
$images = $match[1];
if (count($images)) {
foreach ($images as $image) {
if (!stristr($image, DI::baseUrl() . '/photo/')) {
continue;
$image_rid = Photo::ridFromURI($image);
if ($image_rid) {
Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => local_user()]);
}
$image_uri = substr($image, strrpos($image, '/') + 1);
$image_uri = substr($image_uri, 0, strpos($image_uri, '-'));
Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_uri, 'album' => 'Wall Photos', 'uid' => local_user()]);
}
}
}