protected function prepare(array $args=array())
{
- StatusNet::setApi(true); // Send smaller error pages
+ GNUsocial::setApi(true); // Send smaller error pages
parent::prepare($args);
- if (!isset($_SERVER['CONTENT_TYPE']) || $_SERVER['CONTENT_TYPE'] != 'application/magic-envelope+xml') {
- // TRANS: Client error. Do not translate "application/magic-envelope+xml".
- $this->clientError(_m('Salmon requires "application/magic-envelope+xml".'));
+ if (!isset($_SERVER['CONTENT_TYPE'])) {
+ // TRANS: Client error. Do not translate "Content-type"
+ $this->clientError(_m('Salmon requires a Content-type header.'));
+ }
+ $envxml = null;
+ switch ($_SERVER['CONTENT_TYPE']) {
+ case 'application/magic-envelope+xml':
+ $envxml = file_get_contents('php://input');
+ break;
+ case 'application/x-www-form-urlencoded':
+ $envxml = Magicsig::base64_url_decode($this->trimmed('xml'));
+ break;
+ default:
+ // TRANS: Client error. Do not translate the quoted "application/[type]" strings.
+ $this->clientError(_m('Salmon requires "application/magic-envelope+xml". For Diaspora we also accept "application/x-www-form-urlencoded" with an "xml" parameter.', 415));
}
try {
- $envxml = file_get_contents('php://input');
+ if (empty($envxml)) {
+ throw new ClientException('No magic envelope supplied in POST.');
+ }
$magic_env = new MagicEnvelope($envxml); // parse incoming XML as a MagicEnvelope
$entry = $magic_env->getPayload(); // Not cryptographically verified yet!
// Step 4: Is the newly introduced https://example.com/user/1 URI in the list of aliases
// presented by http://example.com/user/1 (i.e. do they both say they are the same identity?)
if (in_array($e->object_uri, $doublecheck_aliases)) {
- common_debug('These identities both say they are each other: "'.$aliased_uri.'" and "'.$e->object_uri);
+ common_debug('URIFIX These identities both say they are each other: "'.$aliased_uri.'" and "'.$e->object_uri.'"');
+ $orig = clone($oprofile);
+ $oprofile->uri = $e->object_uri;
+ common_debug('URIFIX Updating Ostatus_profile URI for '.$aliased_uri.' to '.$oprofile->uri);
+ $oprofile->updateWithKeys($orig, 'uri'); // 'uri' is the primary key column
+ unset($orig);
$this->oprofile = $oprofile;
break; // don't iterate through aliases anymore
}