summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-09-02 16:58:55 -0400
committerEvan Prodromou <evan@status.net>2010-09-02 16:58:55 -0400
commit82b1d6daefc29c870ea71b29ab851153642f270b (patch)
tree61db5e4fcee85ae0b2e94563e50c78ca794bcf4f /plugins
parent7517409bf16137a9d8a420b7358f30fa55945ba0 (diff)
parentebcd8644a51b66d73971d581789e7c70b82007b2 (diff)
Merge branch 'swat0' into 0.9.x
Diffstat (limited to 'plugins')
-rw-r--r--plugins/OStatus/OStatusPlugin.php14
-rw-r--r--plugins/OStatus/actions/usersalmon.php6
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php37
-rw-r--r--plugins/OStatus/lib/ostatusqueuehandler.php13
4 files changed, 65 insertions, 5 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index 76ffd511b..f9a8782fa 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -984,4 +984,18 @@ class OStatusPlugin extends Plugin
$feed = $oprofile->feeduri;
return false;
}
+
+ function onStartGetProfileFromURI($uri, &$profile) {
+
+ // XXX: do discovery here instead (OStatus_profile::ensureProfileURI($uri))
+
+ $oprofile = Ostatus_profile::staticGet('uri', $uri);
+
+ if (!empty($oprofile) && !$oprofile->isGroup()) {
+ $profile = $oprofile->localProfile();
+ return false;
+ }
+
+ return true;
+ }
}
diff --git a/plugins/OStatus/actions/usersalmon.php b/plugins/OStatus/actions/usersalmon.php
index 641e131ab..06a72bf02 100644
--- a/plugins/OStatus/actions/usersalmon.php
+++ b/plugins/OStatus/actions/usersalmon.php
@@ -71,6 +71,7 @@ class UsersalmonAction extends SalmonAction
// Notice must either be a) in reply to a notice by this user
// or b) to the attention of this user
+ // or c) in reply to a notice to the attention of this user
$context = $this->activity->context;
@@ -79,8 +80,9 @@ class UsersalmonAction extends SalmonAction
if (empty($notice)) {
throw new ClientException("In reply to unknown notice");
}
- if ($notice->profile_id != $this->user->id) {
- throw new ClientException("In reply to a notice not by this user");
+ if ($notice->profile_id != $this->user->id &&
+ !in_array($this->user->id, $notice->getReplies())) {
+ throw new ClientException("In reply to a notice not by this user and not mentioning this user");
}
} else if (!empty($context->attention)) {
if (!in_array($this->user->uri, $context->attention) &&
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index cc4307b14..898c63e83 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -700,14 +700,16 @@ class Ostatus_profile extends Memcached_DataObject
}
// Is the recipient a remote group?
- $oprofile = Ostatus_profile::staticGet('uri', $recipient);
+ $oprofile = Ostatus_profile::ensureProfileURI($recipient);
+
if ($oprofile) {
if ($oprofile->isGroup()) {
// Deliver to local members of this remote group.
// @fixme sender verification?
$groups[] = $oprofile->group_id;
} else {
- common_log(LOG_DEBUG, "Skipping reply to remote profile $recipient");
+ // may be canonicalized or something
+ $replies[] = $oprofile->uri;
}
continue;
}
@@ -1764,6 +1766,37 @@ class Ostatus_profile extends Memcached_DataObject
return $file;
}
+
+ static function ensureProfileURI($uri)
+ {
+ $oprofile = null;
+
+ // First, try to query it
+
+ $oprofile = Ostatus_profile::staticGet('uri', $uri);
+
+ // If unfound, do discovery stuff
+
+ if (empty($oprofile)) {
+ if (preg_match("/^(\w+)\:(.*)/", $uri, $match)) {
+ $protocol = $match[1];
+ switch ($protocol) {
+ case 'http':
+ case 'https':
+ $oprofile = Ostatus_profile::ensureProfileURL($uri);
+ break;
+ case 'acct':
+ case 'mailto':
+ $rest = $match[2];
+ $oprofile = Ostatus_profile::ensureWebfinger($rest);
+ default:
+ common_log("Unrecognized URI protocol for profile: $protocol ($uri)");
+ break;
+ }
+ }
+ }
+ return $oprofile;
+ }
}
/**
diff --git a/plugins/OStatus/lib/ostatusqueuehandler.php b/plugins/OStatus/lib/ostatusqueuehandler.php
index 8905d2e21..5e318116a 100644
--- a/plugins/OStatus/lib/ostatusqueuehandler.php
+++ b/plugins/OStatus/lib/ostatusqueuehandler.php
@@ -67,6 +67,17 @@ class OStatusQueueHandler extends QueueHandler
}
}
+ if (!empty($this->notice->reply_to)) {
+ $replyTo = Notice::staticGet('id', $this->notice->reply_to);
+ if (!empty($replyTo)) {
+ foreach($replyTo->getReplies() as $profile_id) {
+ $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id);
+ if ($oprofile) {
+ $this->pingReply($oprofile);
+ }
+ }
+ }
+ }
return true;
}
@@ -161,7 +172,7 @@ class OStatusQueueHandler extends QueueHandler
* Queue up direct feed update pushes to subscribers on our internal hub.
* If there are a large number of subscriber sites, intermediate bulk
* distribution triggers may be queued.
- *
+ *
* @param string $atom update feed, containing only new/changed items
* @param HubSub $sub open query of subscribers
*/