summaryrefslogtreecommitdiff
path: root/plugins/OStatus
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-21 09:16:27 -0500
committerEvan Prodromou <evan@status.net>2010-02-21 09:16:27 -0500
commit6169d8a877fb0e76ee17187f74a6747fe7f2c97d (patch)
treefbb726a7448922ae9f6a755eb2df30253c579d12 /plugins/OStatus
parent229f9bd069a25af9635a9eaaa822a614bf6e9348 (diff)
saving notices in salmon actions
Diffstat (limited to 'plugins/OStatus')
-rw-r--r--plugins/OStatus/lib/salmonaction.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/OStatus/lib/salmonaction.php b/plugins/OStatus/lib/salmonaction.php
index c83890507..41e8322e8 100644
--- a/plugins/OStatus/lib/salmonaction.php
+++ b/plugins/OStatus/lib/salmonaction.php
@@ -231,4 +231,49 @@ class SalmonAction extends Action
return null;
}
}
+
+ function saveNotice()
+ {
+ $oprofile = $this->ensureProfile();
+
+ // Get (safe!) HTML and text versions of the content
+
+ require_once(INSTALLDIR.'/extlib/HTMLPurifier/HTMLPurifier.auto.php');
+
+ $html = $this->act->object->content;
+
+ $rendered = HTMLPurifier::purify($html);
+ $content = html_entity_decode(strip_tags($rendered));
+
+ $options = array('is_local' => Notice::REMOTE_OMB,
+ 'uri' => $this->act->object->id,
+ 'url' => $this->act->object->link,
+ 'rendered' => $rendered);
+
+ if (!empty($this->act->context->location)) {
+ $options['lat'] = $location->lat;
+ $options['lon'] = $location->lon;
+ if ($location->location_id) {
+ $options['location_ns'] = $location->location_ns;
+ $options['location_id'] = $location->location_id;
+ }
+ }
+
+ if (!empty($this->act->context->replyToID)) {
+ $orig = Notice::staticGet('uri',
+ $this->act->context->replyToID);
+ if (!empty($orig)) {
+ $options['reply_to'] = $orig->id;
+ }
+ }
+
+ if (!empty($this->act->time)) {
+ $options['created'] = common_sql_time($this->act->time);
+ }
+
+ return Notice::saveNew($oprofile->profile_id,
+ $content,
+ 'ostatus+salmon',
+ $options);
+ }
}