mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
feat(privacy): add ability to hide your like
This commit is contained in:
parent
6007a81546
commit
e4a79a8ffb
8 changed files with 31 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) [];
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -395,6 +395,17 @@
|
|||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="120" valign="top">
|
||||
<span class="nobold">{_privacy_setting_see_likes}</span>
|
||||
</td>
|
||||
<td>
|
||||
<select name="likes.read", style="width: 164px;">
|
||||
<option value="2" {if $user->getPrivacySetting('likes.read') == 2}selected{/if}>{_privacy_value_anybody}</option>
|
||||
<option value="0" {if $user->getPrivacySetting('likes.read') == 0}selected{/if}>{_privacy_value_only_me_dative}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="120" valign="top">
|
||||
<span class="nobold">{_profile_type}</span>
|
||||
|
|
|
@ -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(`<a id='temp_filler${rand}' class="upload-item"><img src='${temp_url}'></a>`)
|
||||
textareaNode.find('.post-horizontal').append(`<a id='temp_filler${rand}' class="upload-item lagged"><img src='${temp_url}'></a>`)
|
||||
|
||||
const res = await fetch(`/photos/upload`, {
|
||||
method: 'POST',
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue