We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 617b6f4f authored by Brion Vibber's avatar Brion Vibber

User user_group.uri to look up local groups for OStatus addressing checks when...

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.
parent a6469aee
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment