Encode repeats as share activities
This commit is contained in:
parent
94c50194c1
commit
d277f343ca
|
@ -1473,22 +1473,33 @@ class Notice extends Memcached_DataObject
|
||||||
|
|
||||||
if (Event::handle('StartNoticeAsActivity', array($this, &$act))) {
|
if (Event::handle('StartNoticeAsActivity', array($this, &$act))) {
|
||||||
|
|
||||||
|
$act->id = $this->uri;
|
||||||
|
$act->time = strtotime($this->created);
|
||||||
|
$act->link = $this->bestUrl();
|
||||||
|
$act->content = common_xml_safe_str($this->rendered);
|
||||||
|
$act->title = common_xml_safe_str($this->content);
|
||||||
|
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
|
|
||||||
$act->actor = ActivityObject::fromProfile($profile);
|
$act->actor = ActivityObject::fromProfile($profile);
|
||||||
$act->actor->extra[] = $profile->profileInfo($cur);
|
$act->actor->extra[] = $profile->profileInfo($cur);
|
||||||
$act->verb = ActivityVerb::POST;
|
|
||||||
$act->objects[] = ActivityObject::fromNotice($this);
|
if ($this->repeat_of) {
|
||||||
|
|
||||||
|
$repeated = Notice::staticGet('id', $this->repeat_of);
|
||||||
|
|
||||||
|
$act->verb = ActivityVerb::SHARE;
|
||||||
|
$act->objects[] = $repeated->asActivity($cur);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$act->verb = ActivityVerb::POST;
|
||||||
|
$act->objects[] = ActivityObject::fromNotice($this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// XXX: should this be handled by default processing for object entry?
|
// XXX: should this be handled by default processing for object entry?
|
||||||
|
|
||||||
$act->time = strtotime($this->created);
|
|
||||||
$act->link = $this->bestUrl();
|
|
||||||
|
|
||||||
$act->content = common_xml_safe_str($this->rendered);
|
|
||||||
$act->id = $this->uri;
|
|
||||||
$act->title = common_xml_safe_str($this->content);
|
|
||||||
|
|
||||||
// Categories
|
// Categories
|
||||||
|
|
||||||
$tags = $this->getTags();
|
$tags = $this->getTags();
|
||||||
|
|
|
@ -431,7 +431,13 @@ class Activity
|
||||||
} else {
|
} else {
|
||||||
$activity['object'] = array();
|
$activity['object'] = array();
|
||||||
foreach($this->objects as $object) {
|
foreach($this->objects as $object) {
|
||||||
$activity['object'][] = $object->asArray();
|
$oa = $object->asArray();
|
||||||
|
if ($object instanceof Activity) {
|
||||||
|
// throw in a type
|
||||||
|
// XXX: hackety-hack
|
||||||
|
$oa['type'] = 'activity';
|
||||||
|
}
|
||||||
|
$activity['object'][] = $oa;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,7 +501,7 @@ class Activity
|
||||||
return $xs->getString();
|
return $xs->getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputTo($xs, $namespace=false, $author=true, $source=false)
|
function outputTo($xs, $namespace=false, $author=true, $source=false, $tag='entry')
|
||||||
{
|
{
|
||||||
if ($namespace) {
|
if ($namespace) {
|
||||||
$attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
|
$attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
|
||||||
|
@ -510,9 +516,13 @@ class Activity
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$xs->elementStart('entry', $attrs);
|
$xs->elementStart($tag, $attrs);
|
||||||
|
|
||||||
if ($this->verb == ActivityVerb::POST && count($this->objects) == 1) {
|
if ($tag != 'entry') {
|
||||||
|
$xs->element('activity:object-type', null, ActivityObject::ACTIVITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->verb == ActivityVerb::POST && count($this->objects) == 1 && $tag == 'entry') {
|
||||||
|
|
||||||
$obj = $this->objects[0];
|
$obj = $this->objects[0];
|
||||||
$obj->outputTo($xs, null);
|
$obj->outputTo($xs, null);
|
||||||
|
@ -558,9 +568,13 @@ class Activity
|
||||||
$this->actor->outputTo($xs, 'activity:actor');
|
$this->actor->outputTo($xs, 'activity:actor');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->verb != ActivityVerb::POST || count($this->objects) != 1) {
|
if ($this->verb != ActivityVerb::POST || count($this->objects) != 1 || $tag != 'entry') {
|
||||||
foreach($this->objects as $object) {
|
foreach($this->objects as $object) {
|
||||||
$object->outputTo($xs, 'activity:object');
|
if ($object instanceof Activity) {
|
||||||
|
$object->outputTo($xs, false, true, true, 'activity:object');
|
||||||
|
} else {
|
||||||
|
$object->outputTo($xs, 'activity:object');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +708,7 @@ class Activity
|
||||||
$xs->element($tag, $attrs, $content);
|
$xs->element($tag, $attrs, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$xs->elementEnd('entry');
|
$xs->elementEnd($tag);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ class ActivityObject
|
||||||
const PLACE = 'http://activitystrea.ms/schema/1.0/place';
|
const PLACE = 'http://activitystrea.ms/schema/1.0/place';
|
||||||
const COMMENT = 'http://activitystrea.ms/schema/1.0/comment';
|
const COMMENT = 'http://activitystrea.ms/schema/1.0/comment';
|
||||||
// ^^^^^^^^^^ tea!
|
// ^^^^^^^^^^ tea!
|
||||||
|
const ACTIVITY = 'http://activitystrea.ms/schema/1.0/activity';
|
||||||
|
|
||||||
// Atom elements we snarf
|
// Atom elements we snarf
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user