Give Webfinger response to group queries
This commit is contained in:
parent
3d6e25ee5f
commit
d10ce6ac7c
@ -1315,6 +1315,12 @@ class OStatusPlugin extends Plugin
|
||||
{
|
||||
if ($target->getObjectType() === ActivityObject::PERSON) {
|
||||
$this->addWebFingerPersonLinks($xrd, $target);
|
||||
} elseif ($target->getObjectType() === ActivityObject::GROUP) {
|
||||
$xrd->links[] = new XML_XRD_Element_Link(Discovery::UPDATESFROM,
|
||||
common_local_url('ApiTimelineGroup',
|
||||
array('id' => $target->getGroup()->getID(), 'format' => 'atom')),
|
||||
'application/atom+xml');
|
||||
|
||||
}
|
||||
|
||||
// Salmon
|
||||
|
@ -140,6 +140,20 @@ class WebFingerPlugin extends Plugin
|
||||
throw $e;
|
||||
}
|
||||
|
||||
try {
|
||||
common_debug(__METHOD__.': Finding User_group URI for WebFinger lookup on resource=='._ve($resource));
|
||||
$group = new User_group();
|
||||
$group->whereAddIn('uri', array_keys($alt_urls), $group->columnType('uri'));
|
||||
$group->limit(1);
|
||||
if ($group->find(true)) {
|
||||
$profile = $group->getProfile();
|
||||
}
|
||||
unset($group);
|
||||
} catch (Exception $e) {
|
||||
common_log(LOG_ERR, get_class($e).': '._ve($e->getMessage()));
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// User URI did not match, so let's try our alt_urls as Profile URL values
|
||||
if (!$profile instanceof Profile) {
|
||||
common_debug(__METHOD__.': Finding Profile URLs for WebFinger lookup on resource=='._ve($resource));
|
||||
|
@ -23,11 +23,14 @@ class WebFingerResource_Profile extends WebFingerResource
|
||||
{
|
||||
$aliases = array();
|
||||
|
||||
try {
|
||||
// Try to create an acct: URI if we're dealing with a profile
|
||||
$aliases[] = $this->reconstructAcct();
|
||||
} catch (WebFingerReconstructionException $e) {
|
||||
common_debug("WebFinger reconstruction for Profile failed (id={$this->object->id})");
|
||||
// only persons ("accounts" or "agents" actually) have acct: URIs
|
||||
if ($this->object->isPerson()) {
|
||||
try {
|
||||
// Try to create an acct: URI if we're dealing with a profile
|
||||
$aliases[] = $this->reconstructAcct();
|
||||
} catch (WebFingerReconstructionException $e) {
|
||||
common_debug("WebFinger reconstruction for Profile failed (id={$this->object->getID()})");
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge($aliases, parent::getAliases());
|
||||
@ -40,10 +43,10 @@ class WebFingerResource_Profile extends WebFingerResource
|
||||
if (Event::handle('StartWebFingerReconstruction', array($this->object, &$acct))) {
|
||||
// TODO: getUri may not always give us the correct host on remote users?
|
||||
$host = parse_url($this->object->getUri(), PHP_URL_HOST);
|
||||
if (empty($this->object->nickname) || empty($host)) {
|
||||
if (empty($this->object->getNickname()) || empty($host)) {
|
||||
throw new WebFingerReconstructionException($this->object);
|
||||
}
|
||||
$acct = mb_strtolower(sprintf('acct:%s@%s', $this->object->nickname, $host));
|
||||
$acct = mb_strtolower(sprintf('acct:%s@%s', $this->object->getNickname(), $host));
|
||||
|
||||
Event::handle('EndWebFingerReconstruction', array($this->object, &$acct));
|
||||
}
|
||||
@ -55,34 +58,45 @@ class WebFingerResource_Profile extends WebFingerResource
|
||||
{
|
||||
if (Event::handle('StartWebFingerProfileLinks', array($xrd, $this->object))) {
|
||||
|
||||
$xrd->links[] = new XML_XRD_Element_Link(self::PROFILEPAGE,
|
||||
$this->object->getUrl(), 'text/html');
|
||||
|
||||
// XFN
|
||||
$xrd->links[] = new XML_XRD_Element_Link('http://gmpg.org/xfn/11',
|
||||
$this->object->getUrl(), 'text/html');
|
||||
// FOAF
|
||||
$xrd->links[] = new XML_XRD_Element_Link('describedby',
|
||||
common_local_url('foaf',
|
||||
array('nickname' => $this->object->nickname)),
|
||||
'application/rdf+xml');
|
||||
|
||||
$link = new XML_XRD_Element_Link('http://apinamespace.org/atom',
|
||||
common_local_url('ApiAtomService',
|
||||
array('id' => $this->object->nickname)),
|
||||
'application/atomsvc+xml');
|
||||
// XML_XRD must implement changing properties first $link['http://apinamespace.org/atom/username'] = $this->object->nickname;
|
||||
$xrd->links[] = clone $link;
|
||||
|
||||
if (common_config('site', 'fancy')) {
|
||||
$apiRoot = common_path('api/', true);
|
||||
} else {
|
||||
$apiRoot = common_path('index.php/api/', true);
|
||||
}
|
||||
|
||||
$link = new XML_XRD_Element_Link('http://apinamespace.org/twitter', $apiRoot);
|
||||
// XML_XRD must implement changing properties first $link['http://apinamespace.org/twitter/username'] = $this->object->nickname;
|
||||
$xrd->links[] = clone $link;
|
||||
// Profile page, can give more metadata from Link header or HTML parsing
|
||||
$xrd->links[] = new XML_XRD_Element_Link(self::PROFILEPAGE,
|
||||
$this->object->getUrl(), 'text/html');
|
||||
|
||||
// XFN
|
||||
$xrd->links[] = new XML_XRD_Element_Link('http://gmpg.org/xfn/11',
|
||||
$this->object->getUrl(), 'text/html');
|
||||
if ($this->object->isPerson()) {
|
||||
// FOAF for user
|
||||
$xrd->links[] = new XML_XRD_Element_Link('describedby',
|
||||
common_local_url('foaf',
|
||||
array('nickname' => $this->object->getNickname())),
|
||||
'application/rdf+xml');
|
||||
|
||||
// nickname discovery for apps etc.
|
||||
$link = new XML_XRD_Element_Link('http://apinamespace.org/atom',
|
||||
common_local_url('ApiAtomService',
|
||||
array('id' => $this->object->getNickname())),
|
||||
'application/atomsvc+xml');
|
||||
// XML_XRD must implement changing properties first $link['http://apinamespace.org/atom/username'] = $this->object->getNickname();
|
||||
$xrd->links[] = clone $link;
|
||||
|
||||
$link = new XML_XRD_Element_Link('http://apinamespace.org/twitter', $apiRoot);
|
||||
// XML_XRD must implement changing properties first $link['http://apinamespace.org/twitter/username'] = $this->object->getNickname();
|
||||
$xrd->links[] = clone $link;
|
||||
|
||||
} elseif ($this->object->isGroup()) {
|
||||
// FOAF for group
|
||||
$xrd->links[] = new XML_XRD_Element_Link('describedby',
|
||||
common_local_url('foafgroup',
|
||||
array('nickname' => $this->object->getNickname())),
|
||||
'application/rdf+xml');
|
||||
}
|
||||
|
||||
Event::handle('EndWebFingerProfileLinks', array($xrd, $this->object));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user