mirror of
https://github.com/openvk/openvk
synced 2025-04-23 08:33:02 +03:00
Add notifications of new suggestion posts
This commit is contained in:
parent
cd546621b3
commit
61205f64d9
6 changed files with 50 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
namespace openvk\VKAPI\Handlers;
|
namespace openvk\VKAPI\Handlers;
|
||||||
use openvk\Web\Models\Entities\User;
|
use openvk\Web\Models\Entities\User;
|
||||||
use openvk\Web\Models\Entities\Notifications\{WallPostNotification, RepostNotification, CommentNotification};
|
use openvk\Web\Models\Entities\Notifications\{WallPostNotification, NewSuggestedPostsNotification, RepostNotification, CommentNotification};
|
||||||
use openvk\Web\Models\Repositories\Users as UsersRepo;
|
use openvk\Web\Models\Repositories\Users as UsersRepo;
|
||||||
use openvk\Web\Models\Entities\Club;
|
use openvk\Web\Models\Entities\Club;
|
||||||
use openvk\Web\Models\Repositories\Clubs as ClubsRepo;
|
use openvk\Web\Models\Repositories\Clubs as ClubsRepo;
|
||||||
|
@ -537,6 +537,18 @@ final class Wall extends VKAPIRequestHandler
|
||||||
(new WallPostNotification($wallOwner, $post, $this->user->identity))->emit();
|
(new WallPostNotification($wallOwner, $post, $this->user->identity))->emit();
|
||||||
|
|
||||||
if($owner_id < 0 && !$wallOwner->canBeModifiedBy($this->getUser()) && $wallOwner->getWallType() == 2) {
|
if($owner_id < 0 && !$wallOwner->canBeModifiedBy($this->getUser()) && $wallOwner->getWallType() == 2) {
|
||||||
|
$suggsCount = (new PostsRepo)->getSuggestedPostsCount($wallOwner->getId());
|
||||||
|
|
||||||
|
if($suggsCount % 10 == 0) {
|
||||||
|
$managers = $wallOwner->getManagers();
|
||||||
|
$owner = $wallOwner->getOwner();
|
||||||
|
(new NewSuggestedPostsNotification($owner, $wallOwner))->emit();
|
||||||
|
|
||||||
|
foreach($managers as $manager) {
|
||||||
|
(new NewSuggestedPostsNotification($manager->getUser(), $wallOwner))->emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (object)["post_id" => "on_view"];
|
return (object)["post_id" => "on_view"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
namespace openvk\Web\Models\Entities\Notifications;
|
||||||
|
use openvk\Web\Models\Entities\{User, Club};
|
||||||
|
|
||||||
|
final class NewSuggestedPostsNotification extends Notification
|
||||||
|
{
|
||||||
|
protected $actionCode = 7;
|
||||||
|
|
||||||
|
function __construct(User $owner, Club $group)
|
||||||
|
{
|
||||||
|
parent::__construct($owner, $owner, $group, time(), "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
namespace openvk\Web\Presenters;
|
namespace openvk\Web\Presenters;
|
||||||
use openvk\Web\Models\Exceptions\TooMuchOptionsException;
|
use openvk\Web\Models\Exceptions\TooMuchOptionsException;
|
||||||
use openvk\Web\Models\Entities\{Poll, Post, Photo, Video, Club, User};
|
use openvk\Web\Models\Entities\{Poll, Post, Photo, Video, Club, User};
|
||||||
use openvk\Web\Models\Entities\Notifications\{MentionNotification, RepostNotification, WallPostNotification};
|
use openvk\Web\Models\Entities\Notifications\{MentionNotification, NewSuggestedPostsNotification, RepostNotification, WallPostNotification};
|
||||||
use openvk\Web\Models\Repositories\{Posts, Users, Clubs, Albums, Notes};
|
use openvk\Web\Models\Repositories\{Posts, Users, Clubs, Albums, Notes};
|
||||||
use Chandler\Database\DatabaseConnection;
|
use Chandler\Database\DatabaseConnection;
|
||||||
use Nette\InvalidStateException as ISE;
|
use Nette\InvalidStateException as ISE;
|
||||||
|
@ -341,6 +341,20 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
(new MentionNotification($mentionee, $post, $post->getOwner(), strip_tags($post->getText())))->emit();
|
(new MentionNotification($mentionee, $post, $post->getOwner(), strip_tags($post->getText())))->emit();
|
||||||
|
|
||||||
if($wall < 0 && !$wallOwner->canBeModifiedBy($this->user->identity) && $wallOwner->getWallType() == 2) {
|
if($wall < 0 && !$wallOwner->canBeModifiedBy($this->user->identity) && $wallOwner->getWallType() == 2) {
|
||||||
|
$suggsCount = $this->posts->getSuggestedPostsCount($wallOwner->getId());
|
||||||
|
|
||||||
|
# Возможно, это заебёт админов групп, но так они хотя бы про паблик вспомнят
|
||||||
|
# Мб рандома добавить?
|
||||||
|
if($suggsCount % 10 == 0) {
|
||||||
|
$managers = $wallOwner->getManagers();
|
||||||
|
$owner = $wallOwner->getOwner();
|
||||||
|
(new NewSuggestedPostsNotification($owner, $wallOwner))->emit();
|
||||||
|
|
||||||
|
foreach($managers as $manager) {
|
||||||
|
(new NewSuggestedPostsNotification($manager->getUser(), $wallOwner))->emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->redirect("/club".$wallOwner->getId()."/suggested");
|
$this->redirect("/club".$wallOwner->getId()."/suggested");
|
||||||
} else {
|
} else {
|
||||||
$this->redirect($wallOwner->getURL());
|
$this->redirect($wallOwner->getURL());
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{var $club = $notification->getModel(1)}
|
||||||
|
|
||||||
|
{_nt_in_club}
|
||||||
|
<a href="{$club->getURL()}/suggested/all"><b>{$club->getName()}</b></a>
|
||||||
|
{_nt_new_suggested_posts}
|
|
@ -712,6 +712,8 @@
|
||||||
"nt_commented_yours" = "commented";
|
"nt_commented_yours" = "commented";
|
||||||
"nt_written_on_your_wall" = "wrote on your wall";
|
"nt_written_on_your_wall" = "wrote on your wall";
|
||||||
"nt_accepted_your_post" = "accepted your suggested";
|
"nt_accepted_your_post" = "accepted your suggested";
|
||||||
|
"nt_in_club" = "In group";
|
||||||
|
"nt_new_suggested_posts" = "new posts in suggestions";
|
||||||
"nt_made_you_admin" = "appointed you in the community";
|
"nt_made_you_admin" = "appointed you in the community";
|
||||||
|
|
||||||
"nt_from" = "from";
|
"nt_from" = "from";
|
||||||
|
|
|
@ -671,6 +671,8 @@
|
||||||
"nt_commented_yours" = "оставил(а) комментарий под";
|
"nt_commented_yours" = "оставил(а) комментарий под";
|
||||||
"nt_written_on_your_wall" = "написал(а) на вашей стене";
|
"nt_written_on_your_wall" = "написал(а) на вашей стене";
|
||||||
"nt_accepted_your_post" = "опубликовало вашу предложенную";
|
"nt_accepted_your_post" = "опубликовало вашу предложенную";
|
||||||
|
"nt_in_club" = "В сообществе";
|
||||||
|
"nt_new_suggested_posts" = "новые записи в предложке";
|
||||||
"nt_made_you_admin" = "назначил(а) вас руководителем сообщества";
|
"nt_made_you_admin" = "назначил(а) вас руководителем сообщества";
|
||||||
"nt_from" = "от";
|
"nt_from" = "от";
|
||||||
"nt_yours_adjective" = "вашим";
|
"nt_yours_adjective" = "вашим";
|
||||||
|
|
Loading…
Reference in a new issue