summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-12 00:43:16 -0500
committerEvan Prodromou <evan@status.net>2010-02-12 00:43:16 -0500
commit320532560fe6fa4661d58317923c54b708c897c2 (patch)
treea07a165169c844d250454956f570f1cfa8ea5067
parent5f94efc45463378f246f9db82e9f2e0e8a109f7d (diff)
flesh out salmon endpoint
-rw-r--r--plugins/OStatus/actions/salmon.php52
1 files changed, 42 insertions, 10 deletions
diff --git a/plugins/OStatus/actions/salmon.php b/plugins/OStatus/actions/salmon.php
index 012869cf7..b616027a9 100644
--- a/plugins/OStatus/actions/salmon.php
+++ b/plugins/OStatus/actions/salmon.php
@@ -22,28 +22,60 @@
* @author James Walker <james@status.net>
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET')) {
+ exit(1);
+}
class SalmonAction extends Action
{
+ var $user = null;
+ var $xml = null;
+ var $activity = null;
- function handle()
+ function prepare($args)
{
- parent::handle();
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $this->handlePost();
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(_('This method requires a POST.'));
}
- }
+ if ($_SERVER['CONTENT_TYPE'] != 'application/atom+xml') {
+ $this->clientError(_('Salmon requires application/atom+xml'));
+ }
- function handlePost()
- {
- $user_id = $this->arg('id');
- common_log(LOG_DEBUG, 'Salmon: incoming post for user: '. $user_id);
+ $id = $this->trimmed('id');
+
+ if (!$id) {
+ $this->clientError(_('No ID.'));
+ }
+
+ $this->user = User::staticGet($id);
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user.'));
+ }
$xml = file_get_contents('php://input');
+ $dom = DOMDocument::loadXML($xml);
+
+ // XXX: check that document element is Atom entry
+ // XXX: check the signature
+
+ $this->act = Activity::fromAtomEntry($dom->documentElement);
+ }
+
+ function handle($args)
+ {
+ common_log(LOG_DEBUG, 'Salmon: incoming post for user: '. $user_id);
+
// TODO : Insert new $xml -> notice code
+ switch ($this->act->verb)
+ {
+ case Activity::POST:
+ case Activity::SHARE:
+ case Activity::FAVORITE:
+ case Activity::FOLLOW:
+ }
}
}