ShowUnsupportedAttachmentRepresentation: Attachment representation, full file (or in rare cases thumbnails/previews).
- $out: HTMLOutputter class to use for outputting HTML.
- $file: 'File' object which we're going to show representation for.
+
+StartNotifyMentioned: During notice distribution, we send notifications (email, im...) to the profiles who were somehow mentioned.
+- $stored: Notice object that is being distributed.
+- &$mentioned_ids: Array of profile IDs (not just for local users) who got mentioned by the notice.
+
+EndNotifyMentioned: During notice distribution, we send notifications (email, im...) to the profiles who were somehow mentioned.
+- $stored: Notice object that is being distributed.
+- $mentioned_ids: Array of profile IDs (not just for local users) who got mentioned by the notice.
}
// If it's a repeat, the reply_to should be to the original
- if (!empty($reply->repeat_of)) {
+ if ($reply->isRepeat()) {
$notice->reply_to = $reply->repeat_of;
} else {
$notice->reply_to = $reply->id;
}
if (empty($verb)) {
- if (!empty($notice->repeat_of)) {
+ if ($notice->isRepeat()) {
$notice->verb = ActivityVerb::SHARE;
$notice->object_type = ActivityObject::ACTIVITY;
} else {
self::blow('notice:list-ids:conversation:%s', $this->conversation);
self::blow('conversation:notice_count:%d', $this->conversation);
- if (!empty($this->repeat_of)) {
+ if ($this->isRepeat()) {
// XXX: we should probably only use one of these
$this->blowStream('notice:repeats:%d', $this->repeat_of);
self::blow('notice:list-ids:repeat_of:%d', $this->repeat_of);
// Exclude any deleted, non-local, or blocking recipients.
$profile = $this->getProfile();
$originalProfile = null;
- if ($this->repeat_of) {
+ if ($this->isRepeat()) {
// Check blocks against the original notice's poster as well.
$original = Notice::getKV('id', $this->repeat_of);
if ($original instanceof Notice) {
{
// Don't save reply data for repeats
- if (!empty($this->repeat_of)) {
+ if ($this->isRepeat()) {
return array();
}
{
// Don't send reply notifications for repeats
- if (!empty($this->repeat_of)) {
+ if ($this->isRepeat()) {
return array();
}
$recipientIds = $this->getReplies();
-
- foreach ($recipientIds as $recipientId) {
- $user = User::getKV('id', $recipientId);
- if ($user instanceof User) {
- mail_notify_attn($user, $this);
+ if (Event::handle('StartNotifyMentioned', array($this, &$recipientIds))) {
+ foreach ($recipientIds as $recipientId) {
+ $user = User::getKV('id', $recipientId);
+ if ($user instanceof User) {
+ mail_notify_attn($user, $this);
+ }
}
+ Event::handle('EndNotifyMentioned', array($this, $recipientIds));
}
}
$this->is_local == Notice::LOCAL_NONPUBLIC);
}
+ public function isRepeat()
+ {
+ return !empty($this->repeat_of);
+ }
+
/**
* Get the list of hash tags saved with this notice.
*
*/
abstract function deleteRelated(Notice $notice);
+ protected function notifyMentioned(Notice $stored, array &$mentioned_ids)
+ {
+ // pass through silently by default
+ }
+
/**
* Called when generating Atom XML ActivityStreams output from an
* ActivityObject belonging to this plugin. Gives the plugin
*/
function onNoticeDeleteRelated(Notice $notice)
{
- if (!$this->isMyNotice($notice)) {
+ if ($this->isMyNotice($notice)) {
+ $this->deleteRelated($notice);
+ }
+
+ // Always continue this event in our activity handling plugins.
+ return true;
+ }
+
+ /**
+ * @param Notice $stored The notice being distributed
+ * @param array &$mentioned_ids List of profiles (from $stored->getReplies())
+ */
+ public function onStartNotifyMentioned(Notice $stored, array &$mentioned_ids)
+ {
+ if (!$this->isMyNotice($stored)) {
return true;
}
- $this->deleteRelated($notice);
+ $this->notifyMentioned($stored, $mentioned_ids);
+
+ // If it was _our_ notice, only we should do anything with the mentions.
+ return false;
}
/**
}
}
+ 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
/**
if (!defined('GNUSOCIAL')) { exit(1); }
-require_once INSTALLDIR.'/lib/mail.php';
-
/**
* FavorAction class.
*
$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');
$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
- }
- }
}
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()
{