mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-30 09:16:35 +00:00
Improved notification system
This commit is contained in:
parent
3954a0b64c
commit
19516e3a5e
@ -35,33 +35,34 @@ class notificationComponent {
|
|||||||
if($infos_post['visibility_level'] == Posts::VISIBILITY_USER){
|
if($infos_post['visibility_level'] == Posts::VISIBILITY_USER){
|
||||||
|
|
||||||
//Push the notification only to the user, and only if it is not him
|
//Push the notification only to the user, and only if it is not him
|
||||||
if($notification->get_from_user_id() == $infos_post['userID'])
|
if($notification->get_from_user_id() == $infos_post['user_page_id'])
|
||||||
return false; //Nothing to be done
|
return false; //Nothing to be done
|
||||||
|
|
||||||
//Set the target user
|
//Set the target user
|
||||||
$notification->set_dest_user_id($infos_post['user_page_id']);
|
$notification->set_dest_user_id($infos_post['user_page_id']);
|
||||||
|
|
||||||
//Push the notification
|
//Push the notification
|
||||||
return $notification->push_private($notification);
|
return $this->push_private($notification);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
//Get the list of friends of the user
|
//Get the list of friends of the user
|
||||||
$friendslist = components()->friends->getList($infos_post['user_page_id']);
|
$friendslist = components()->friends->getList($notification->get_from_user_id());
|
||||||
|
|
||||||
//Generate the list of target users
|
//Generate the list of target users
|
||||||
$target_users = array();
|
$target_users = array();
|
||||||
foreach($friendslist as $friend){
|
foreach($friendslist as $friend){
|
||||||
|
|
||||||
|
//Check if target user and page owner are friends
|
||||||
|
if(!components()->friends->are_friend($friend->getFriendID(), $notification->get_from_container_id())
|
||||||
|
AND $friend->getFriendID() != $notification->get_from_container_id())
|
||||||
|
continue;
|
||||||
|
|
||||||
//Check if the friend is following his friend
|
//Check if the friend is following his friend
|
||||||
if(!components()->friends->is_following($friend->getFriendID(), $notification->get_from_user_id())){
|
if(!components()->friends->is_following($friend->getFriendID(), $notification->get_from_user_id())){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if target user and page owner are friends
|
|
||||||
if(!components()->friends->are_friend($friend->getFriendID(), $notification->get_from_container_id()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//Add the user to the list
|
//Add the user to the list
|
||||||
$target_users[] = $friend->getFriendID();
|
$target_users[] = $friend->getFriendID();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user