Do proper Activity-plugin based mention notification

This commit is contained in:
Mikael Nordfeldth
2014-07-06 16:37:26 +02:00
parent eda0e25147
commit 2eea7a2d4b
6 changed files with 67 additions and 36 deletions

View File

@@ -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
/**

View File

@@ -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
}
}
}

View File

@@ -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()
{