summaryrefslogtreecommitdiff
path: root/plugins/OStatus
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-09-27 11:29:54 -0700
committerBrion Vibber <brion@pobox.com>2010-09-27 11:29:54 -0700
commit617b6f4f7d3496ad5d8b36d59f7afd761c7650b0 (patch)
tree3bdaf4bda2ea98e5a6cb15b1c37be3a35950b317 /plugins/OStatus
parenta6469aeed88a400d5d38d75a210417de4af4eea7 (diff)
User user_group.uri to look up local groups for OStatus addressing checks when available. Will still fall back to the URL-scheme-checking code if there's no matching user_group record.
Should help with keeping remote groups working when renaming sites -- as long as user_group.uri has been filled out on the site changing its domain and other issues with POST handling are resolved.
Diffstat (limited to 'plugins/OStatus')
-rw-r--r--plugins/OStatus/OStatusPlugin.php23
1 files changed, 17 insertions, 6 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index 6cd935c9e..dcf1b3607 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -956,7 +956,7 @@ class OStatusPlugin extends Plugin
}
/**
- * Utility function to check if the given URL is a canonical group profile
+ * Utility function to check if the given URI is a canonical group profile
* page, and if so return the ID number.
*
* @param string $url
@@ -964,11 +964,22 @@ class OStatusPlugin extends Plugin
*/
public static function localGroupFromUrl($url)
{
- $template = common_local_url('groupbyid', array('id' => '31337'));
- $template = preg_quote($template, '/');
- $template = str_replace('31337', '(\d+)', $template);
- if (preg_match("/$template/", $url, $matches)) {
- return intval($matches[1]);
+ $group = User_group::staticGet('uri', $url);
+ if ($group) {
+ $local = Local_group::staticGet('id', $group->id);
+ if ($local) {
+ return $group->id;
+ }
+ } else {
+ // To find local groups which haven't had their uri fields filled out...
+ // If the domain has changed since a subscriber got the URI, it'll
+ // be broken.
+ $template = common_local_url('groupbyid', array('id' => '31337'));
+ $template = preg_quote($template, '/');
+ $template = str_replace('31337', '(\d+)', $template);
+ if (preg_match("/$template/", $url, $matches)) {
+ return intval($matches[1]);
+ }
}
return false;
}