Add StartNoticeWhoGets, EndNoticeWhoGets events to allow upcoming TagSub plugin to do extra inbox delivery.
This commit is contained in:
parent
9e9cbdf505
commit
b66250c6aa
@ -1131,3 +1131,11 @@ StartActivityObjectOutputJson: Called at start of JSON output generation for Act
|
|||||||
EndActivityObjectOutputJson: Called at end of JSON output generation for ActivityObject chunks: the array has not yet been filled out.
|
EndActivityObjectOutputJson: Called at end of JSON output generation for ActivityObject chunks: the array has not yet been filled out.
|
||||||
- $obj ActivityObject
|
- $obj ActivityObject
|
||||||
- &$out: array to be serialized; you're free to modify it
|
- &$out: array to be serialized; you're free to modify it
|
||||||
|
|
||||||
|
StartNoticeWhoGets: Called at start of inbox delivery prep; plugins can schedule notices to go to particular profiles that would otherwise not have reached them. Canceling will take over the entire addressing operation. Be aware that output can be cached or used several times, so should remain idempotent.
|
||||||
|
- $notice Notice
|
||||||
|
- &$ni: in/out array mapping profile IDs to constants: NOTICE_INBOX_SOURCE_SUB etc
|
||||||
|
|
||||||
|
EndNoticeWhoGets: Called at end of inbox delivery prep; plugins can filter out profiles from receiving inbox delivery here. Be aware that output can be cached or used several times, so should remain idempotent.
|
||||||
|
- $notice Notice
|
||||||
|
- &$ni: in/out array mapping profile IDs to constants: NOTICE_INBOX_SOURCE_SUB etc
|
||||||
|
@ -812,41 +812,48 @@ class Notice extends Memcached_DataObject
|
|||||||
|
|
||||||
$ni = array();
|
$ni = array();
|
||||||
|
|
||||||
foreach ($users as $id) {
|
// Give plugins a chance to add folks in at start...
|
||||||
$ni[$id] = NOTICE_INBOX_SOURCE_SUB;
|
if (Event::handle('StartNoticeWhoGets', array($this, &$ni))) {
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($groups as $group) {
|
|
||||||
$users = $group->getUserMembers();
|
|
||||||
foreach ($users as $id) {
|
foreach ($users as $id) {
|
||||||
if (!array_key_exists($id, $ni)) {
|
$ni[$id] = NOTICE_INBOX_SOURCE_SUB;
|
||||||
$ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
|
}
|
||||||
|
|
||||||
|
foreach ($groups as $group) {
|
||||||
|
$users = $group->getUserMembers();
|
||||||
|
foreach ($users as $id) {
|
||||||
|
if (!array_key_exists($id, $ni)) {
|
||||||
|
$ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($recipients as $recipient) {
|
foreach ($recipients as $recipient) {
|
||||||
if (!array_key_exists($recipient, $ni)) {
|
if (!array_key_exists($recipient, $ni)) {
|
||||||
$ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
|
$ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Exclude any deleted, non-local, or blocking recipients.
|
// Exclude any deleted, non-local, or blocking recipients.
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
$originalProfile = null;
|
$originalProfile = null;
|
||||||
if ($this->repeat_of) {
|
if ($this->repeat_of) {
|
||||||
// Check blocks against the original notice's poster as well.
|
// Check blocks against the original notice's poster as well.
|
||||||
$original = Notice::staticGet('id', $this->repeat_of);
|
$original = Notice::staticGet('id', $this->repeat_of);
|
||||||
if ($original) {
|
if ($original) {
|
||||||
$originalProfile = $original->getProfile();
|
$originalProfile = $original->getProfile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
foreach ($ni as $id => $source) {
|
||||||
foreach ($ni as $id => $source) {
|
$user = User::staticGet('id', $id);
|
||||||
$user = User::staticGet('id', $id);
|
if (empty($user) || $user->hasBlocked($profile) ||
|
||||||
if (empty($user) || $user->hasBlocked($profile) ||
|
($originalProfile && $user->hasBlocked($originalProfile))) {
|
||||||
($originalProfile && $user->hasBlocked($originalProfile))) {
|
unset($ni[$id]);
|
||||||
unset($ni[$id]);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Give plugins a chance to filter out...
|
||||||
|
Event::handle('EndNoticeWhoGets', array($this, &$ni));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($c)) {
|
if (!empty($c)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user