From 72f684dc97af89f8241edbe1c08615bfd51a8ac9 Mon Sep 17 00:00:00 2001 From: Fasutoa Date: Fri, 27 Jun 2025 19:15:17 +0500 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B0=D0=BB=D1=8C=D0=B1=D0=BE=D0=BC=D0=B0=20+=20?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=B1=D0=BE=D0=BC=D0=B0=20=D0=BF=D1=80=D0=B8=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B8=20(=D0=9E=D0=91=D0=AF=D0=97.=20=D0=9F=D0=A0?= =?UTF-8?q?=D0=9E=D0=A2=D0=95=D0=A1=D0=A2=D0=98=20=D0=A3=D0=94=D0=90=D0=9B?= =?UTF-8?q?=D0=95=D0=9D=D0=98=D0=95=20=D0=9F=D0=A0=D0=98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Jobs/UpdateVkPostJob.php | 14 ++++++-------- app/Services/VK/VkService.php | 11 ++++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/Jobs/UpdateVkPostJob.php b/app/Jobs/UpdateVkPostJob.php index 16463fb..af2f9b9 100644 --- a/app/Jobs/UpdateVkPostJob.php +++ b/app/Jobs/UpdateVkPostJob.php @@ -55,14 +55,12 @@ class UpdateVkPostJob implements ShouldQueue $vk_post = $wallService->getPostById($this->post_id); - // доделать - if ($vk_post['attachments']) { - Log::info($vk_post); - if ($this->getAlbumAttachment($vk_post['attachments'])) { - Log::info('вход в аттачментс вк'); - $album = $this->getAlbumAttachment($vk_post['attachments']); - Log::info($album); - $albumService->deleteAlbum($album['album']['id'], $this->public_id); + if ($vk_post['attachments']) { + $pattern = '/\[https:\/\/vk.com\/album-?[0-9]+_([0-9]+)\|.*\]/'; + preg_match($pattern, $vk_post['text'], $matches); + if (isset($matches[1])) { + $album_id = $matches[1]; + $albumService->deleteAlbum($album_id, $this->public_id); } } diff --git a/app/Services/VK/VkService.php b/app/Services/VK/VkService.php index 9baf425..f6fd0b6 100644 --- a/app/Services/VK/VkService.php +++ b/app/Services/VK/VkService.php @@ -102,7 +102,16 @@ class VkService $postRelation = DB::table('posts_vk_posts')->select()->where('post_id', $post_id)->first(); $post_id = $postRelation->vk_post_id; $vk_post = $this->getPostById($post_id); - $this->wallService->deletePost($vk_post['id']); + + $pattern = '/\[https:\/\/vk.com\/album-?[0-9]+_([0-9]+)\|.*\]/'; + preg_match($pattern, $vk_post['text'], $matches); + if (isset($matches[1])) { + $album_id = $matches[1]; + $this->albumService->deleteAlbum($album_id, $this->public_id); + $this->wallService->deletePost($vk_post['id']); + } else { + $this->wallService->deletePost($vk_post['id']); + } } public function createAlbum(string $title, $images)