diff --git a/Web/Models/Entities/Post.php b/Web/Models/Entities/Post.php index 0b210fb0..30c6eac3 100644 --- a/Web/Models/Entities/Post.php +++ b/Web/Models/Entities/Post.php @@ -301,7 +301,7 @@ class Post extends Postable { $liked = parent::toggleLike($user); - if($this->getOwner(false)->getId() !== $user->getId() && !($this->getOwner() instanceof Club) && !$this instanceof Comment) + if(!$user->isPrivateLikes() && $this->getOwner(false)->getId() !== $user->getId() && !($this->getOwner() instanceof Club) && !$this instanceof Comment) (new LikeNotification($this->getOwner(false), $this, $user))->emit(); foreach($this->getChildren() as $attachment) diff --git a/Web/Models/Entities/Postable.php b/Web/Models/Entities/Postable.php index 55e1adf7..fc6cb8ca 100644 --- a/Web/Models/Entities/Postable.php +++ b/Web/Models/Entities/Postable.php @@ -97,8 +97,14 @@ abstract class Postable extends Attachable "target" => $this->getRecord()->id, ])->page($page, $perPage); - foreach($sel as $like) - yield (new Users)->get($like->origin); + foreach($sel as $like) { + $user = (new Users)->get($like->origin); + if($user->isPrivateLikes() && OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"]) { + $user = (new Users)->get((int) OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["account"]); + } + + yield $user; + } } function isAnonymous(): bool diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 1e17dd82..a0574f3d 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -498,6 +498,7 @@ class User extends RowModel "wall.write", "messages.write", "audios.read", + "likes.read", ], ])->get($id); } @@ -1062,6 +1063,7 @@ class User extends RowModel "wall.write", "messages.write", "audios.read", + "likes.read", ], ])->set($id, $status)->toInteger()); } @@ -1338,6 +1340,11 @@ class User extends RowModel return $this->getId(); } + function isPrivateLikes(): bool + { + return $this->getPrivacySetting("likes.read") == User::PRIVACY_NO_ONE; + } + function toVkApiStruct(?User $user = NULL, string $fields = ''): object { $res = (object) []; diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index b64823fb..4c6bb0dd 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -503,6 +503,7 @@ final class UserPresenter extends OpenVKPresenter "wall.write", "messages.write", "audios.read", + "likes.read", ]; foreach($settings as $setting) { $input = $this->postParam(str_replace(".", "_", $setting)); diff --git a/Web/Presenters/templates/User/Settings.xml b/Web/Presenters/templates/User/Settings.xml index d34993e8..244c52c4 100644 --- a/Web/Presenters/templates/User/Settings.xml +++ b/Web/Presenters/templates/User/Settings.xml @@ -395,6 +395,17 @@ + + + {_privacy_setting_see_likes} + + + + + {_profile_type} diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 5a6e40f3..1a93898e 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -886,7 +886,7 @@ async function __uploadToTextarea(file, textareaNode) { if(filetype == 'photo') { const temp_url = URL.createObjectURL(file) const rand = random_int(0, 1000) - textareaNode.find('.post-horizontal').append(``) + textareaNode.find('.post-horizontal').append(``) const res = await fetch(`/photos/upload`, { method: 'POST', diff --git a/locales/en.strings b/locales/en.strings index 0056c076..5789074f 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -698,6 +698,7 @@ "privacy_setting_write_wall" = "Who can publish posts on my wall"; "privacy_setting_write_messages" = "Who can write messages to me"; "privacy_setting_view_audio" = "Who can see my audios"; +"privacy_setting_see_likes" = "Who can see my likes"; "privacy_value_anybody" = "Anybody"; "privacy_value_anybody_dative" = "Anybody"; "privacy_value_users" = "OpenVK users"; diff --git a/locales/ru.strings b/locales/ru.strings index cd1c4ddf..c06e7cde 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -671,6 +671,7 @@ "privacy_setting_write_wall" = "Кто может писать у меня на стене"; "privacy_setting_write_messages" = "Кто может писать мне сообщения"; "privacy_setting_view_audio" = "Кому видно мои аудиозаписи"; +"privacy_setting_see_likes" = "Кому видны мои лайки"; "privacy_value_anybody" = "Все желающие"; "privacy_value_anybody_dative" = "Всем желающим"; "privacy_value_users" = "Пользователям OpenVK";