From 262eb7120f08a4a7c021c7c1df6a67e1b3c1d27d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 10 Sep 2010 09:10:53 -0400 Subject: make our own twitter links if Twitter doesn't give us entities --- .../TwitterBridge/daemons/twitterstatusfetcher.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php index f1305696b..b2bcc22bc 100755 --- a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php +++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php @@ -713,6 +713,10 @@ class TwitterStatusFetcher extends ParallelizingDaemon $text = $status->text; if (empty($status->entities)) { + common_log(LOG_WARNING, "No entities data for {$status->id}; trying to fake up links ourselves."); + $text = common_replace_urls_callback($text, 'common_linkify'); + $text = preg_replace('/(^|\"\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.TwitterStatusFetcher::tagLink('\\2')", $text); + $text = preg_replace('/(?:^|\s+)@([a-z0-9A-Z_]{1,64})/e', "'\\1@'.TwitterStatusFetcher::atLink('\\2')", $text); return $text; } @@ -771,12 +775,26 @@ class TwitterStatusFetcher extends ParallelizingDaemon function makeHashtagLink($object) { - return "#{$object->text}"; + return "#" . self::tagLink($object->text); } function makeMentionLink($object) { - return "@{$object->screen_name}"; + return "@".self::atLink($object->screen_name, $object->name); + } + + static function tagLink($tag) + { + return "{$tag}"; + } + + static function atLink($screenName, $fullName=null) + { + if (!empty($fullName)) { + return "{$screenName}"; + } else { + return "{$screenName}"; + } } function saveStatusMentions($notice, $status) -- cgit v1.2.3-54-g00ecf From cfcb8603171cf9dd30fe54ee682a3666c0b21d7e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 10 Sep 2010 09:21:01 -0400 Subject: use capturing parens for matching at-mentions in twitterstatusfetcher --- plugins/TwitterBridge/daemons/twitterstatusfetcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php index b2bcc22bc..181be3dcf 100755 --- a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php +++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php @@ -716,7 +716,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon common_log(LOG_WARNING, "No entities data for {$status->id}; trying to fake up links ourselves."); $text = common_replace_urls_callback($text, 'common_linkify'); $text = preg_replace('/(^|\"\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.TwitterStatusFetcher::tagLink('\\2')", $text); - $text = preg_replace('/(?:^|\s+)@([a-z0-9A-Z_]{1,64})/e', "'\\1@'.TwitterStatusFetcher::atLink('\\2')", $text); + $text = preg_replace('/(^|\s+)@([a-z0-9A-Z_]{1,64})/e', "'\\1@'.TwitterStatusFetcher::atLink('\\2')", $text); return $text; } -- cgit v1.2.3-54-g00ecf From f17512cfe603b8f00576cdff10f3a3d71924c000 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 10 Sep 2010 11:50:19 -0700 Subject: Catch exceptions during SubMirror mirror attempt; log & skip that one if found. Should avoid things like RequireValidatedEmailPlugin causing infinite retry loops if the mirror-er isn't validated yet. --- plugins/SubMirror/lib/mirrorqueuehandler.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/SubMirror/lib/mirrorqueuehandler.php b/plugins/SubMirror/lib/mirrorqueuehandler.php index 92b36b5eb..c1a6f65e3 100644 --- a/plugins/SubMirror/lib/mirrorqueuehandler.php +++ b/plugins/SubMirror/lib/mirrorqueuehandler.php @@ -37,7 +37,13 @@ class MirrorQueueHandler extends QueueHandler $mirror->subscribed = $notice->profile_id; if ($mirror->find()) { while ($mirror->fetch()) { - $mirror->mirrorNotice($notice); + try { + $mirror->mirrorNotice($notice); + } catch (Exception $e) { + common_log(LOG_ERR, "Exception trying to mirror notice $notice->id " . + "for subscriber $mirror->subscriber ($mirror->style): " . + $e->getMessage()); + } } } return true; -- cgit v1.2.3-54-g00ecf From 0021c16bd11be5c9e9f0196154b037e604d6bf37 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 13 Sep 2010 12:06:10 -0700 Subject: Declare public options on DisqusPlugin to avoid notice warnings on access if not set. --- plugins/DisqusPlugin.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/DisqusPlugin.php b/plugins/DisqusPlugin.php index c07eaaabd..eef40616e 100644 --- a/plugins/DisqusPlugin.php +++ b/plugins/DisqusPlugin.php @@ -71,6 +71,9 @@ if (!defined('STATUSNET')) { class DisqusPlugin extends Plugin { + public $shortname; // Required 'shortname' for actually triggering Disqus. + public $div_style; // Optional CSS chunk for the main
+ function onEndShowContentBlock($action) { if (get_class($action) == 'ShownoticeAction') { -- cgit v1.2.3-54-g00ecf From 89c561c9cf381a1068e4d78dd9ff1f42f709c4ce Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 16 Sep 2010 14:43:27 -0700 Subject: Ticket #2731: Fix for regression in posting to remote groups (regression in 2d4e0693c88bb8cad47f917db3ac5ecfacf28619) Changes in 2d4e0693c88bb8cad47f917db3ac5ecfacf28619 changed Ostatus_profile::filterReplies() (which sorts out the local, remote, and group recipients on incoming remote messages) from checking for remote profiles with a safe call to Ostatus_profile::staticGet() to calls through Ostatus_profile::ensureProfileURL() and Ostatus_profile::ensureWebfinger(), which throw exceptions and thus abort processing. Since this was done before checking for local groups, the filter would fail when the ensure* functions determined it was looking at a local group and rightfully refused to create a remote group profile for it. Changing the calls to the ensure* functions was done so we can record remote reply recipients for future reply-to-reply processing (the staticGet() call was a cheaper way to do a lookup when we knew we only actually had to process groups that somebody signed up to); most important fix is simply to actually check for the exception! :) Here I'm changing the order of processing so we do the local group lookup first -- where it's nice and safe -- and then when we do the remote checks, we'll go ahead and gracefully skip that entry if the full remote lookup fails, so we'll still process any following recipients. --- plugins/OStatus/classes/Ostatus_profile.php | 33 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'plugins') diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 19fe5169b..11ca67b25 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -703,23 +703,7 @@ class Ostatus_profile extends Memcached_DataObject continue; } - // Is the recipient a remote group? - $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 { - // may be canonicalized or something - $replies[] = $oprofile->uri; - } - continue; - } - // Is the recipient a local group? - // @fixme uri on user_group isn't reliable yet // $group = User_group::staticGet('uri', $recipient); $id = OStatusPlugin::localGroupFromUrl($recipient); if ($id) { @@ -738,7 +722,22 @@ class Ostatus_profile extends Memcached_DataObject } } - common_log(LOG_DEBUG, "Skipping reply to unrecognized profile $recipient"); + // Is the recipient a remote user or group? + try { + $oprofile = Ostatus_profile::ensureProfileURI($recipient); + if ($oprofile->isGroup()) { + // Deliver to local members of this remote group. + // @fixme sender verification? + $groups[] = $oprofile->group_id; + } else { + // may be canonicalized or something + $replies[] = $oprofile->uri; + } + continue; + } catch (Exception $e) { + // Neither a recognizable local nor remote user! + common_log(LOG_DEBUG, "Skipping reply to unrecognized profile $recipient: " . $e->getMessage()); + } } $attention_uris = $replies; -- cgit v1.2.3-54-g00ecf