forked from GNUsocial/gnu-social
Do proper Activity-plugin based mention notification
This commit is contained in:
@@ -191,6 +191,18 @@ class FavoritePlugin extends ActivityHandlerPlugin
|
||||
}
|
||||
}
|
||||
|
||||
protected function notifyMentioned(Notice $stored, array &$mentioned_ids)
|
||||
{
|
||||
require_once INSTALLDIR.'/lib/mail.php';
|
||||
|
||||
foreach ($mentioned_ids as $id) {
|
||||
$mentioned = User::getKV('id', $id);
|
||||
if ($mentioned instanceof User && $mentioned->id != $stored->profile_id) {
|
||||
mail_notify_fave($mentioned, $stored->getProfile(), $stored->getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// API stuff
|
||||
|
||||
/**
|
||||
|
@@ -31,8 +31,6 @@
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
require_once INSTALLDIR.'/lib/mail.php';
|
||||
|
||||
/**
|
||||
* FavorAction class.
|
||||
*
|
||||
@@ -91,7 +89,6 @@ class FavorAction extends FormAction
|
||||
$stored = Notice::saveActivity($act, $this->scoped,
|
||||
array('uri'=>$act->id));
|
||||
|
||||
$this->notify($stored, $this->scoped->getUser());
|
||||
Fave::blowCacheForProfileId($this->scoped->id);
|
||||
|
||||
return _('Favorited the notice');
|
||||
@@ -104,24 +101,4 @@ class FavorAction extends FormAction
|
||||
$disfavor->show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies a user when their notice is favorited.
|
||||
*
|
||||
* @param class $notice favorited notice
|
||||
* @param class $user user declaring a favorite
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function notify($notice, $user)
|
||||
{
|
||||
$other = User::getKV('id', $notice->profile_id);
|
||||
if ($other && $other->id != $user->id) {
|
||||
if ($other->email && $other->emailnotifyfav) {
|
||||
mail_notify_fave($other, $user, $notice);
|
||||
}
|
||||
// XXX: notify by IM
|
||||
// XXX: notify by SMS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -324,6 +324,11 @@ class Fave extends Managed_DataObject
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function getAttentionArray() {
|
||||
// not all objects can/should carry attentions, so we don't require extending this
|
||||
// the format should be an array with URIs to mentioned profiles
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getTarget()
|
||||
{
|
||||
|
Reference in New Issue
Block a user