OStatus: send favorite/unfavorite notifications to remote authors
This commit is contained in:
parent
ea9d6f21ec
commit
9c2fe8492f
|
@ -1104,6 +1104,38 @@ class Notice extends Memcached_DataObject
|
||||||
return $xs->getString();
|
return $xs->getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an XML string fragment with a reference to a notice as an
|
||||||
|
* Activity Streams noun object with the given element type.
|
||||||
|
*
|
||||||
|
* Assumes that 'activity' namespace has been previously defined.
|
||||||
|
*
|
||||||
|
* @param string $element one of 'subject', 'object', 'target'
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function asActivityNoun($element)
|
||||||
|
{
|
||||||
|
$xs = new XMLStringer(true);
|
||||||
|
|
||||||
|
$xs->elementStart('activity:' . $element);
|
||||||
|
$xs->element('activity:object-type',
|
||||||
|
null,
|
||||||
|
'http://activitystrea.ms/schema/1.0/note');
|
||||||
|
$xs->element('id',
|
||||||
|
null,
|
||||||
|
$this->uri);
|
||||||
|
$xs->element('content',
|
||||||
|
array('type' => 'text/html'),
|
||||||
|
$this->rendered);
|
||||||
|
$xs->element('link',
|
||||||
|
array('type' => 'text/html',
|
||||||
|
'rel' => 'permalink',
|
||||||
|
'href' => $this->bestUrl()));
|
||||||
|
$xs->elementEnd('activity:' . $element);
|
||||||
|
|
||||||
|
return $xs->getString();
|
||||||
|
}
|
||||||
|
|
||||||
function bestUrl()
|
function bestUrl()
|
||||||
{
|
{
|
||||||
if (!empty($this->url)) {
|
if (!empty($this->url)) {
|
||||||
|
|
|
@ -357,4 +357,39 @@ class OStatusPlugin extends Plugin
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify remote users when their notices get favorited.
|
||||||
|
*
|
||||||
|
* @param Profile or User $profile of local user doing the faving
|
||||||
|
* @param Notice $notice being favored
|
||||||
|
* @return hook return value
|
||||||
|
*/
|
||||||
|
function onEndFavorNotice($profile, Notice $notice)
|
||||||
|
{
|
||||||
|
if ($profile instanceof User) {
|
||||||
|
// @fixme upstream function should clarify its parameters
|
||||||
|
$profile = $profile->getProfile();
|
||||||
|
}
|
||||||
|
$oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
|
||||||
|
if ($oprofile) {
|
||||||
|
$oprofile->notify($profile, ActivityVerb::FAVORITE, $notice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify remote users when their notices get de-favorited.
|
||||||
|
*
|
||||||
|
* @param Profile or User $profile of local user doing the de-faving
|
||||||
|
* @param Notice $notice being favored
|
||||||
|
* @return hook return value
|
||||||
|
*/
|
||||||
|
function onEndDisfavorNotice(Profile $profile, Notice $notice)
|
||||||
|
{
|
||||||
|
$oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
|
||||||
|
if ($oprofile) {
|
||||||
|
$oprofile->notify($profile, ActivityVerb::UNFAVORITE, $notice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user