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);
|
$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();
|
(new LikeNotification($this->getOwner(false), $this, $user))->emit();
|
||||||
|
|
||||||
foreach($this->getChildren() as $attachment)
|
foreach($this->getChildren() as $attachment)
|
||||||
|
|
|
@ -97,8 +97,14 @@ abstract class Postable extends Attachable
|
||||||
"target" => $this->getRecord()->id,
|
"target" => $this->getRecord()->id,
|
||||||
])->page($page, $perPage);
|
])->page($page, $perPage);
|
||||||
|
|
||||||
foreach($sel as $like)
|
foreach($sel as $like) {
|
||||||
yield (new Users)->get($like->origin);
|
$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
|
function isAnonymous(): bool
|
||||||
|
|
|
@ -498,6 +498,7 @@ class User extends RowModel
|
||||||
"wall.write",
|
"wall.write",
|
||||||
"messages.write",
|
"messages.write",
|
||||||
"audios.read",
|
"audios.read",
|
||||||
|
"likes.read",
|
||||||
],
|
],
|
||||||
])->get($id);
|
])->get($id);
|
||||||
}
|
}
|
||||||
|
@ -1062,6 +1063,7 @@ class User extends RowModel
|
||||||
"wall.write",
|
"wall.write",
|
||||||
"messages.write",
|
"messages.write",
|
||||||
"audios.read",
|
"audios.read",
|
||||||
|
"likes.read",
|
||||||
],
|
],
|
||||||
])->set($id, $status)->toInteger());
|
])->set($id, $status)->toInteger());
|
||||||
}
|
}
|
||||||
|
@ -1338,6 +1340,11 @@ class User extends RowModel
|
||||||
return $this->getId();
|
return $this->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isPrivateLikes(): bool
|
||||||
|
{
|
||||||
|
return $this->getPrivacySetting("likes.read") == User::PRIVACY_NO_ONE;
|
||||||
|
}
|
||||||
|
|
||||||
function toVkApiStruct(?User $user = NULL, string $fields = ''): object
|
function toVkApiStruct(?User $user = NULL, string $fields = ''): object
|
||||||
{
|
{
|
||||||
$res = (object) [];
|
$res = (object) [];
|
||||||
|
|
|
@ -503,6 +503,7 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
"wall.write",
|
"wall.write",
|
||||||
"messages.write",
|
"messages.write",
|
||||||
"audios.read",
|
"audios.read",
|
||||||
|
"likes.read",
|
||||||
];
|
];
|
||||||
foreach($settings as $setting) {
|
foreach($settings as $setting) {
|
||||||
$input = $this->postParam(str_replace(".", "_", $setting));
|
$input = $this->postParam(str_replace(".", "_", $setting));
|
||||||
|
|
|
@ -395,6 +395,17 @@
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td width="120" valign="top">
|
<td width="120" valign="top">
|
||||||
<span class="nobold">{_profile_type}</span>
|
<span class="nobold">{_profile_type}</span>
|
||||||
|
|
|
@ -886,7 +886,7 @@ async function __uploadToTextarea(file, textareaNode) {
|
||||||
if(filetype == 'photo') {
|
if(filetype == 'photo') {
|
||||||
const temp_url = URL.createObjectURL(file)
|
const temp_url = URL.createObjectURL(file)
|
||||||
const rand = random_int(0, 1000)
|
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`, {
|
const res = await fetch(`/photos/upload`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
|
@ -698,6 +698,7 @@
|
||||||
"privacy_setting_write_wall" = "Who can publish posts on my wall";
|
"privacy_setting_write_wall" = "Who can publish posts on my wall";
|
||||||
"privacy_setting_write_messages" = "Who can write messages to me";
|
"privacy_setting_write_messages" = "Who can write messages to me";
|
||||||
"privacy_setting_view_audio" = "Who can see my audios";
|
"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" = "Anybody";
|
||||||
"privacy_value_anybody_dative" = "Anybody";
|
"privacy_value_anybody_dative" = "Anybody";
|
||||||
"privacy_value_users" = "OpenVK users";
|
"privacy_value_users" = "OpenVK users";
|
||||||
|
|
|
@ -671,6 +671,7 @@
|
||||||
"privacy_setting_write_wall" = "Кто может писать у меня на стене";
|
"privacy_setting_write_wall" = "Кто может писать у меня на стене";
|
||||||
"privacy_setting_write_messages" = "Кто может писать мне сообщения";
|
"privacy_setting_write_messages" = "Кто может писать мне сообщения";
|
||||||
"privacy_setting_view_audio" = "Кому видно мои аудиозаписи";
|
"privacy_setting_view_audio" = "Кому видно мои аудиозаписи";
|
||||||
|
"privacy_setting_see_likes" = "Кому видны мои лайки";
|
||||||
"privacy_value_anybody" = "Все желающие";
|
"privacy_value_anybody" = "Все желающие";
|
||||||
"privacy_value_anybody_dative" = "Всем желающим";
|
"privacy_value_anybody_dative" = "Всем желающим";
|
||||||
"privacy_value_users" = "Пользователям OpenVK";
|
"privacy_value_users" = "Пользователям OpenVK";
|
||||||
|
|
Loading…
Reference in a new issue