summaryrefslogtreecommitdiff
path: root/classes/Notice.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-02-20 15:56:36 -0800
committerBrion Vibber <brion@pobox.com>2010-02-20 15:56:36 -0800
commit9c2fe8492f7dae183e0369f8d43f124fd80e4433 (patch)
tree86ff0bb2805b5256ff9f1e3e604a67f35ad22e71 /classes/Notice.php
parentea9d6f21ecaff6e26ebe30775d1ddcd6d68d0a11 (diff)
OStatus: send favorite/unfavorite notifications to remote authors
Diffstat (limited to 'classes/Notice.php')
-rw-r--r--classes/Notice.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index a52cfed70..8b8f90474 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1104,6 +1104,38 @@ class Notice extends Memcached_DataObject
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()
{
if (!empty($this->url)) {