summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-21 21:38:16 -0500
committerEvan Prodromou <evan@status.net>2010-02-21 21:38:16 -0500
commitbd74f05a665df73078134c37f059cc1797d1a0ea (patch)
tree63ec3058bebe204262a749df7159945c08c3b04e
parentbf23c35495bf713ec662649b2e8964e90da93239 (diff)
Do mention lookup for Webfinger accounts in OStatusPlugin
-rw-r--r--plugins/OStatus/OStatusPlugin.php79
1 files changed, 37 insertions, 42 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index c5a2db3d8..60bb144a8 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -137,25 +137,6 @@ class OStatusPlugin extends Plugin
}
/**
- * Add the feed settings page to the Connect Settings menu
- *
- * @param Action &$action The calling page
- *
- * @return boolean hook return
- */
- function onEndConnectSettingsNav(&$action)
- {
- $action_name = $action->trimmed('action');
-
- $action->menuItem(common_local_url('feedsubsettings'),
- _m('Feeds'),
- _m('Feed subscription options'),
- $action_name === 'feedsubsettings');
-
- return true;
- }
-
- /**
* Automatically load the actions and libraries used by the plugin
*
* @param Class $cls the class
@@ -215,33 +196,16 @@ class OStatusPlugin extends Plugin
* @fixme push webfinger lookup & sending to a background queue
* @fixme also detect short-form name for remote subscribees where not ambiguous
*/
+
function onEndNoticeSave($notice)
{
- $count = preg_match_all('/(\w+\.)*\w+@(\w+\.)*\w+(\w+\-\w+)*\.\w+/', $notice->content, $matches);
- if ($count) {
- foreach ($matches[0] as $webfinger) {
+ $mentioned = $notice->getReplies();
- // FIXME: look up locally first
+ foreach ($mentioned as $profile) {
- // Check to see if we've got an actual webfinger
- $w = new Webfinger;
+ $oprofile = Ostatus_profile::staticGet('profile_id', $profile->id);
- $endpoint_uri = '';
-
- $result = $w->lookup($webfinger);
- if (empty($result)) {
- continue;
- }
-
- foreach ($result->links as $link) {
- if ($link['rel'] == 'salmon') {
- $endpoint_uri = $link['href'];
- }
- }
-
- if (empty($endpoint_uri)) {
- continue;
- }
+ if (!empty($oprofile) && !empty($oprofile->salmonuri)) {
// FIXME: this needs to go out in a queue handler
@@ -249,9 +213,40 @@ class OStatusPlugin extends Plugin
$xml .= $notice->asAtomEntry();
$salmon = new Salmon();
- $salmon->post($endpoint_uri, $xml);
+ $salmon->post($oprofile->salmonuri, $xml);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+
+ function onEndFindMentions($sender, $text, &$mentions)
+ {
+ preg_match_all('/(?:^|\s+)@((?:\w+\.)*\w+@(?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+)/',
+ $text,
+ $wmatches,
+ PREG_OFFSET_CAPTURE);
+
+ foreach ($wmatches[1] as $wmatch) {
+
+ $webfinger = $wmatch[0];
+
+ $oprofile = Ostatus_profile::ensureWebfinger($webfinger);
+
+ if (!empty($oprofile)) {
+
+ $profile = $oprofile->localProfile();
+
+ $mentions[] = array('mentioned' => array($profile),
+ 'text' => $wmatch[0],
+ 'position' => $wmatch[1],
+ 'url' => $profile->profileurl);
}
}
+
+ return true;
}
/**