Fix for tickets #2917, #2262: user URL shortening options not being applied in non-web channels

common_shorten_links() can only access the web session's logged-in user, so never properly took user options into effect for posting via XMPP, API, mail, etc.

Adds an optional $user parameter on common_shorten_links(), and a $user->shortenLinks() as a clearer interface for that.
Tweaked some lower-level functions so $user gets passed down -- making the $notice_id param previously there for saving URLs at notice save time generalized a little.

Note also ticket #2919: there's a lot of duplicate code calling the shortening, checking the length, and reporting near-identical error messages. These should be consolidated to aid in code and translation maintenance.
This commit is contained in:
Brion Vibber
2010-12-02 10:56:44 -08:00
parent c4f67f7647
commit aa96c3c1d9
15 changed files with 98 additions and 34 deletions

View File

@@ -55,7 +55,7 @@ class MailHandler
return true;
}
$msg = $this->cleanup_msg($msg);
$msg = common_shorten_links($msg);
$msg = $user->shortenLinks($msg);
if (Notice::contentTooLong($msg)) {
$this->error($from, sprintf(_('That\'s too long. Maximum notice size is %d character.',
'That\'s too long. Maximum notice size is %d characters.',