diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/MobileProfile/MobileProfilePlugin.php | 2 | ||||
-rw-r--r-- | plugins/NoticeTitle/NoticeTitlePlugin.php | 49 | ||||
-rw-r--r-- | plugins/OStatus/OStatusPlugin.php | 27 | ||||
-rw-r--r-- | plugins/OStatus/actions/usersalmon.php | 6 | ||||
-rw-r--r-- | plugins/OStatus/classes/Ostatus_profile.php | 37 | ||||
-rw-r--r-- | plugins/OStatus/lib/ostatusqueuehandler.php | 13 | ||||
-rw-r--r-- | plugins/OStatus/scripts/updateostatus.php | 4 | ||||
-rw-r--r-- | plugins/TwitterBridge/TwitterBridgePlugin.php | 25 |
8 files changed, 143 insertions, 20 deletions
diff --git a/plugins/MobileProfile/MobileProfilePlugin.php b/plugins/MobileProfile/MobileProfilePlugin.php index 6076bbde0..72a6a04fb 100644 --- a/plugins/MobileProfile/MobileProfilePlugin.php +++ b/plugins/MobileProfile/MobileProfilePlugin.php @@ -241,7 +241,7 @@ class MobileProfilePlugin extends WAP20Plugin return true; } - $action->cssLink('css/display.css'); + $action->primaryCssLink(); if (file_exists(Theme::file('css/mp-screen.css'))) { $action->cssLink('css/mp-screen.css', null, 'screen'); diff --git a/plugins/NoticeTitle/NoticeTitlePlugin.php b/plugins/NoticeTitle/NoticeTitlePlugin.php index f7fb1e4d0..9f53173db 100644 --- a/plugins/NoticeTitle/NoticeTitlePlugin.php +++ b/plugins/NoticeTitle/NoticeTitlePlugin.php @@ -278,5 +278,54 @@ class NoticeTitlePlugin extends Plugin return true; } + + /** + * If a notice has a title, show it in the <title> element + * + * @param Action $action Action being executed + * + * @return boolean hook value + */ + + function onStartShowHeadTitle($action) + { + $actionName = $action->trimmed('action'); + + if ($actionName == 'shownotice') { + $title = Notice_title::fromNotice($action->notice); + if (!empty($title)) { + $action->element('title', null, + // TRANS: Page title. %1$s is the title, %2$s is the site name. + sprintf(_("%1\$s - %2\$s"), + $title, + common_config('site', 'name'))); + } + } + + return true; + } + + /** + * If a notice has a title, show it in the <h1> element + * + * @param Action $action Action being executed + * + * @return boolean hook value + */ + + function onStartShowPageTitle($action) + { + $actionName = $action->trimmed('action'); + + if ($actionName == 'shownotice') { + $title = Notice_title::fromNotice($action->notice); + if (!empty($title)) { + $action->element('h1', null, $title); + return false; + } + } + + return true; + } } diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 6fef20d6f..f9a8782fa 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -248,17 +248,6 @@ class OStatusPlugin extends Plugin } /** - * Check if we've got remote replies to send via Salmon. - * - * @fixme push webfinger lookup & sending to a background queue - * @fixme also detect short-form name for remote subscribees where not ambiguous - */ - - function onEndNoticeSave($notice) - { - } - - /** * Find any explicit remote mentions. Accepted forms: * Webfinger: @user@example.com * Profile link: @example.com/mublog/user @@ -492,7 +481,7 @@ class OStatusPlugin extends Plugin * Tell the FeedSub infrastructure whether we have any active OStatus * usage for the feed; if not it'll be able to garbage-collect the * feed subscription. - * + * * @param FeedSub $feedsub * @param integer $count in/out * @return mixed hook return code @@ -995,4 +984,18 @@ class OStatusPlugin extends Plugin $feed = $oprofile->feeduri; return false; } + + function onStartGetProfileFromURI($uri, &$profile) { + + // XXX: do discovery here instead (OStatus_profile::ensureProfileURI($uri)) + + $oprofile = Ostatus_profile::staticGet('uri', $uri); + + if (!empty($oprofile) && !$oprofile->isGroup()) { + $profile = $oprofile->localProfile(); + return false; + } + + return true; + } } diff --git a/plugins/OStatus/actions/usersalmon.php b/plugins/OStatus/actions/usersalmon.php index 641e131ab..06a72bf02 100644 --- a/plugins/OStatus/actions/usersalmon.php +++ b/plugins/OStatus/actions/usersalmon.php @@ -71,6 +71,7 @@ class UsersalmonAction extends SalmonAction // Notice must either be a) in reply to a notice by this user // or b) to the attention of this user + // or c) in reply to a notice to the attention of this user $context = $this->activity->context; @@ -79,8 +80,9 @@ class UsersalmonAction extends SalmonAction if (empty($notice)) { throw new ClientException("In reply to unknown notice"); } - if ($notice->profile_id != $this->user->id) { - throw new ClientException("In reply to a notice not by this user"); + if ($notice->profile_id != $this->user->id && + !in_array($this->user->id, $notice->getReplies())) { + throw new ClientException("In reply to a notice not by this user and not mentioning this user"); } } else if (!empty($context->attention)) { if (!in_array($this->user->uri, $context->attention) && diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index cc4307b14..898c63e83 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -700,14 +700,16 @@ class Ostatus_profile extends Memcached_DataObject } // Is the recipient a remote group? - $oprofile = Ostatus_profile::staticGet('uri', $recipient); + $oprofile = Ostatus_profile::ensureProfileURI($recipient); + if ($oprofile) { if ($oprofile->isGroup()) { // Deliver to local members of this remote group. // @fixme sender verification? $groups[] = $oprofile->group_id; } else { - common_log(LOG_DEBUG, "Skipping reply to remote profile $recipient"); + // may be canonicalized or something + $replies[] = $oprofile->uri; } continue; } @@ -1764,6 +1766,37 @@ class Ostatus_profile extends Memcached_DataObject return $file; } + + static function ensureProfileURI($uri) + { + $oprofile = null; + + // First, try to query it + + $oprofile = Ostatus_profile::staticGet('uri', $uri); + + // If unfound, do discovery stuff + + if (empty($oprofile)) { + if (preg_match("/^(\w+)\:(.*)/", $uri, $match)) { + $protocol = $match[1]; + switch ($protocol) { + case 'http': + case 'https': + $oprofile = Ostatus_profile::ensureProfileURL($uri); + break; + case 'acct': + case 'mailto': + $rest = $match[2]; + $oprofile = Ostatus_profile::ensureWebfinger($rest); + default: + common_log("Unrecognized URI protocol for profile: $protocol ($uri)"); + break; + } + } + } + return $oprofile; + } } /** diff --git a/plugins/OStatus/lib/ostatusqueuehandler.php b/plugins/OStatus/lib/ostatusqueuehandler.php index 8905d2e21..5e318116a 100644 --- a/plugins/OStatus/lib/ostatusqueuehandler.php +++ b/plugins/OStatus/lib/ostatusqueuehandler.php @@ -67,6 +67,17 @@ class OStatusQueueHandler extends QueueHandler } } + if (!empty($this->notice->reply_to)) { + $replyTo = Notice::staticGet('id', $this->notice->reply_to); + if (!empty($replyTo)) { + foreach($replyTo->getReplies() as $profile_id) { + $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id); + if ($oprofile) { + $this->pingReply($oprofile); + } + } + } + } return true; } @@ -161,7 +172,7 @@ class OStatusQueueHandler extends QueueHandler * Queue up direct feed update pushes to subscribers on our internal hub. * If there are a large number of subscriber sites, intermediate bulk * distribution triggers may be queued. - * + * * @param string $atom update feed, containing only new/changed items * @param HubSub $sub open query of subscribers */ diff --git a/plugins/OStatus/scripts/updateostatus.php b/plugins/OStatus/scripts/updateostatus.php index 622ded56a..ff0d86d37 100644 --- a/plugins/OStatus/scripts/updateostatus.php +++ b/plugins/OStatus/scripts/updateostatus.php @@ -44,14 +44,14 @@ try { if (empty($user)) { throw new Exception("Can't find user with id '$id'."); } - updateProfileURL($user); + updateOStatus($user); } else if (have_option('n', 'nickname')) { $nickname = get_option_value('n', 'nickname'); $user = User::staticGet('nickname', $nickname); if (empty($user)) { throw new Exception("Can't find user with nickname '$nickname'"); } - updateProfileURL($user); + updateOStatus($user); } else if (have_option('a', 'all')) { $user = new User(); if ($user->find()) { diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index 0505a328f..8e3eba318 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -335,5 +335,30 @@ class TwitterBridgePlugin extends Plugin return (bool)$this->adminImportControl; } + /** + * When the site is set to ssl=sometimes mode, we should make sure our + * various auth-related pages are on SSL to keep things looking happy. + * Although we're not submitting passwords directly, we do link out to + * an authentication source and it's a lot happier if we've got some + * protection against MitM. + * + * @param string $action name + * @param boolean $ssl outval to force SSL + * @return mixed hook return value + */ + function onSensitiveAction($action, &$ssl) + { + $sensitive = array('twitteradminpanel', + 'twittersettings', + 'twitterauthorization', + 'twitterlogin'); + if (in_array($action, $sensitive)) { + $ssl = true; + return false; + } else { + return true; + } + } + } |