summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-01 16:57:58 -0800
committerBrion Vibber <brion@pobox.com>2010-03-01 16:57:58 -0800
commite30af99873ceda83bb4e9a2e221da894e8363489 (patch)
tree4e1db1ce277b4643c0e2610adcb94fe4ada29eb3
parent45e8819c1b9cc618e9b2d6678b0ff14c653a09d3 (diff)
parent493b5479c15f0e135054fd6b961e50e690077eda (diff)
Merge branch 'work' into testing
-rw-r--r--actions/newnotice.php3
-rw-r--r--plugins/OStatus/OStatusPlugin.php57
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php2
-rw-r--r--plugins/OStatus/lib/xrd.php10
4 files changed, 53 insertions, 19 deletions
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 78480abab..ed0fa1b2b 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -294,6 +294,9 @@ class NewnoticeAction extends Action
if ($profile) {
$content = '@' . $profile->nickname . ' ';
}
+ } else {
+ // @fixme most of these bits above aren't being passed on above
+ $inreplyto = null;
}
$notice_form = new NoticeForm($this, '', $content, null, $inreplyto);
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index 720dedd0a..4ffbba45b 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -222,31 +222,62 @@ class OStatusPlugin extends Plugin
}
/**
- *
+ * Find any explicit remote mentions. Accepted forms:
+ * Webfinger: @user@example.com
+ * Profile link: @example.com/mublog/user
+ * @param Profile $sender (os user?)
+ * @param string $text input markup text
+ * @param array &$mention in/out param: set of found mentions
+ * @return boolean hook return value
*/
function onEndFindMentions($sender, $text, &$mentions)
{
- preg_match_all('/(?:^|\s+)@((?:\w+\.)*\w+@(?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+)/',
+ preg_match_all('!(?:^|\s+)
+ @( # Webfinger:
+ (?:\w+\.)*\w+ # user
+ @ # @
+ (?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+ # domain
+ | # Profile:
+ (?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+ # domain
+ (?:/\w+)+ # /path1(/path2...)
+ )!x',
$text,
$wmatches,
PREG_OFFSET_CAPTURE);
foreach ($wmatches[1] as $wmatch) {
-
- $webfinger = $wmatch[0];
-
- $this->log(LOG_INFO, "Checking Webfinger for address '$webfinger'");
-
- $oprofile = Ostatus_profile::ensureWebfinger($webfinger);
+ $target = $wmatch[0];
+ $oprofile = null;
+
+ if (strpos($target, '/') === false) {
+ $this->log(LOG_INFO, "Checking Webfinger for address '$target'");
+ try {
+ $oprofile = Ostatus_profile::ensureWebfinger($target);
+ } catch (Exception $e) {
+ $this->log(LOG_ERR, "Webfinger check failed: " . $e->getMessage());
+ }
+ } else {
+ $schemes = array('https', 'http');
+ foreach ($schemes as $scheme) {
+ $url = "$scheme://$target";
+ $this->log(LOG_INFO, "Checking profile address '$url'");
+ try {
+ $oprofile = Ostatus_profile::ensureProfile($url);
+ if ($oprofile) {
+ continue;
+ }
+ } catch (Exception $e) {
+ $this->log(LOG_ERR, "Profile check failed: " . $e->getMessage());
+ }
+ }
+ }
if (empty($oprofile)) {
-
- $this->log(LOG_INFO, "No Ostatus_profile found for address '$webfinger'");
-
+ $this->log(LOG_INFO, "No Ostatus_profile found for address '$target'");
} else {
- $this->log(LOG_INFO, "Ostatus_profile found for address '$webfinger'");
+ $this->log(LOG_INFO, "Ostatus_profile found for address '$target'");
if ($oprofile->isGroup()) {
continue;
@@ -261,7 +292,7 @@ class OStatusPlugin extends Plugin
}
}
$mentions[] = array('mentioned' => array($profile),
- 'text' => $wmatch[0],
+ 'text' => $target,
'position' => $pos,
'url' => $profile->profileurl);
}
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index 93e8934c9..a33e95d93 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -698,7 +698,7 @@ class Ostatus_profile extends Memcached_DataObject
{
// Get the canonical feed URI and check it
$discover = new FeedDiscovery();
- if ($hints['feedurl']) {
+ if (isset($hints['feedurl'])) {
$feeduri = $hints['feedurl'];
$feeduri = $discover->discoverFromFeedURL($feeduri);
} else {
diff --git a/plugins/OStatus/lib/xrd.php b/plugins/OStatus/lib/xrd.php
index 1de065db9..85df26c54 100644
--- a/plugins/OStatus/lib/xrd.php
+++ b/plugins/OStatus/lib/xrd.php
@@ -161,20 +161,20 @@ class XRD
function saveLink($doc, $link)
{
$link_element = $doc->createElement('Link');
- if ($link['rel']) {
+ if (!empty($link['rel'])) {
$link_element->setAttribute('rel', $link['rel']);
}
- if ($link['type']) {
+ if (!empty($link['type'])) {
$link_element->setAttribute('type', $link['type']);
}
- if ($link['href']) {
+ if (!empty($link['href'])) {
$link_element->setAttribute('href', $link['href']);
}
- if ($link['template']) {
+ if (!empty($link['template'])) {
$link_element->setAttribute('template', $link['template']);
}
- if (is_array($link['title'])) {
+ if (!empty($link['title']) && is_array($link['title'])) {
foreach($link['title'] as $title) {
$title = $doc->createElement('Title', $title);
$link_element->appendChild($title);