Start/End NoticeAsActivity modifications
More 'scoped' profiles and typing to the functions. Also, there's no need to send an object as a reference.
This commit is contained in:
parent
eb2f93ad2b
commit
6e481d35ed
@ -1751,7 +1751,7 @@ class Notice extends Managed_DataObject
|
|||||||
}
|
}
|
||||||
$act = new Activity();
|
$act = new Activity();
|
||||||
|
|
||||||
if (Event::handle('StartNoticeAsActivity', array($this, &$act))) {
|
if (Event::handle('StartNoticeAsActivity', array($this, $act, $scoped))) {
|
||||||
|
|
||||||
$act->id = $this->uri;
|
$act->id = $this->uri;
|
||||||
$act->time = strtotime($this->created);
|
$act->time = strtotime($this->created);
|
||||||
@ -1898,7 +1898,7 @@ class Notice extends Managed_DataObject
|
|||||||
$act->editLink = $act->selfLink;
|
$act->editLink = $act->selfLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::handle('EndNoticeAsActivity', array($this, &$act));
|
Event::handle('EndNoticeAsActivity', array($this, $act, $scoped));
|
||||||
}
|
}
|
||||||
|
|
||||||
self::cacheSet(Cache::codeKey('notice:as-activity:'.$this->id), $act);
|
self::cacheSet(Cache::codeKey('notice:as-activity:'.$this->id), $act);
|
||||||
|
@ -308,22 +308,21 @@ class ActivityPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndNoticeAsActivity($notice, &$activity)
|
public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null)
|
||||||
{
|
{
|
||||||
switch ($notice->verb) {
|
switch ($stored->verb) {
|
||||||
case ActivityVerb::FAVORITE:
|
case ActivityVerb::FAVORITE:
|
||||||
$fave = Fave::getKV('uri', $notice->uri);
|
$fave = Fave::getKV('uri', $stored->uri);
|
||||||
if (!empty($fave)) {
|
if (!empty($fave)) {
|
||||||
$notice = Notice::getKV('id', $fave->notice_id);
|
$stored = Notice::getKV('id', $fave->notice_id);
|
||||||
if (!empty($notice)) {
|
if (!empty($stored)) {
|
||||||
$cur = common_current_user();
|
$target = $stored->asActivity($scoped);
|
||||||
$target = $notice->asActivity($cur->getProfile());
|
|
||||||
if ($target->verb == ActivityVerb::POST) {
|
if ($target->verb == ActivityVerb::POST) {
|
||||||
// "I like the thing you posted"
|
// "I like the thing you posted"
|
||||||
$activity->objects = $target->objects;
|
$act->objects = $target->objects;
|
||||||
} else {
|
} else {
|
||||||
// "I like that you did whatever you did"
|
// "I like that you did whatever you did"
|
||||||
$activity->objects = array($target);
|
$act->objects = array($target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,21 +331,21 @@ class ActivityPlugin extends Plugin
|
|||||||
// FIXME: do something here
|
// FIXME: do something here
|
||||||
break;
|
break;
|
||||||
case ActivityVerb::JOIN:
|
case ActivityVerb::JOIN:
|
||||||
$mem = Group_member::getKV('uri', $notice->uri);
|
$mem = Group_member::getKV('uri', $stored->uri);
|
||||||
if (!empty($mem)) {
|
if (!empty($mem)) {
|
||||||
$group = $mem->getGroup();
|
$group = $mem->getGroup();
|
||||||
$activity->objects = array(ActivityObject::fromGroup($group));
|
$act->objects = array(ActivityObject::fromGroup($group));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ActivityVerb::LEAVE:
|
case ActivityVerb::LEAVE:
|
||||||
// FIXME: ????
|
// FIXME: ????
|
||||||
break;
|
break;
|
||||||
case ActivityVerb::FOLLOW:
|
case ActivityVerb::FOLLOW:
|
||||||
$sub = Subscription::getKV('uri', $notice->uri);
|
$sub = Subscription::getKV('uri', $stored->uri);
|
||||||
if (!empty($sub)) {
|
if (!empty($sub)) {
|
||||||
$profile = Profile::getKV('id', $sub->subscribed);
|
$profile = Profile::getKV('id', $sub->subscribed);
|
||||||
if (!empty($profile)) {
|
if (!empty($profile)) {
|
||||||
$activity->objects = array($profile->asActivityObject());
|
$act->objects = array($profile->asActivityObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -243,12 +243,12 @@ class EventPlugin extends MicroAppPlugin
|
|||||||
*
|
*
|
||||||
* @return ActivityObject
|
* @return ActivityObject
|
||||||
*/
|
*/
|
||||||
function onEndNoticeAsActivity($notice, &$act) {
|
function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null) {
|
||||||
switch ($notice->object_type) {
|
switch ($stored->object_type) {
|
||||||
case RSVP::POSITIVE:
|
case RSVP::POSITIVE:
|
||||||
case RSVP::NEGATIVE:
|
case RSVP::NEGATIVE:
|
||||||
case RSVP::POSSIBLE:
|
case RSVP::POSSIBLE:
|
||||||
$act->verb = $notice->object_type;
|
$act->verb = $stored->object_type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -68,18 +68,18 @@ class GNUsocialPhotosPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndNoticeAsActivity($notice, &$activity)
|
function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null)
|
||||||
{
|
{
|
||||||
common_log(LOG_INFO, 'photo plugin: EndNoticeAsActivity');
|
common_log(LOG_INFO, 'photo plugin: EndNoticeAsActivity');
|
||||||
$photo = GNUsocialPhoto::getKV('notice_id', $notice->id);
|
$photo = GNUsocialPhoto::getKV('notice_id', $stored->id);
|
||||||
if(!$photo) {
|
if(!$photo) {
|
||||||
common_log(LOG_INFO, 'not a photo.');
|
common_log(LOG_INFO, 'not a photo.');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$activity->objects[0]->type = ActivityObject::PHOTO;
|
$act->objects[0]->type = ActivityObject::PHOTO;
|
||||||
$activity->objects[0]->thumbnail = $photo->thumb_uri;
|
$act->objects[0]->thumbnail = $photo->thumb_uri;
|
||||||
$activity->objects[0]->largerImage = $photo->uri;
|
$act->objects[0]->largerImage = $photo->uri;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,19 +217,19 @@ class NoticeTitlePlugin extends Plugin
|
|||||||
/**
|
/**
|
||||||
* Show the notice title in Atom output
|
* Show the notice title in Atom output
|
||||||
*
|
*
|
||||||
* @param Notice &$notice Notice being shown
|
* @param Notice $notice Notice being shown
|
||||||
* @param XMLStringer &$xs output context
|
* @param Activity $act Activity object to be modified
|
||||||
* @param string &$output string to be output as title
|
* @param Profile $scoped Currently logged in/scoped profile
|
||||||
*
|
*
|
||||||
* @return boolean hook value
|
* @return boolean hook value
|
||||||
*/
|
*/
|
||||||
function onEndNoticeAsActivity($notice, &$activity)
|
function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null)
|
||||||
{
|
{
|
||||||
$title = Notice_title::fromNotice($notice);
|
$title = Notice_title::fromNotice($stored);
|
||||||
|
|
||||||
if (!empty($title)) {
|
if (!empty($title)) {
|
||||||
foreach ($activity->objects as $obj) {
|
foreach ($act->objects as $obj) {
|
||||||
if ($obj->id == $notice->uri) {
|
if ($obj->id == $stored->getUri()) {
|
||||||
$obj->title = $title;
|
$obj->title = $title;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user