summaryrefslogtreecommitdiff
path: root/classes/Message.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-12-02 10:56:44 -0800
committerBrion Vibber <brion@pobox.com>2010-12-02 13:41:56 -0800
commitaa96c3c1d9823382e9e6de0da5084fcc111f2ee5 (patch)
tree06846b7b32f718d3e62a212fc60924d2f6008668 /classes/Message.php
parentc4f67f76476a4ca608bcf2fc860ad5ef889d269d (diff)
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.
Diffstat (limited to 'classes/Message.php')
-rw-r--r--classes/Message.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/classes/Message.php b/classes/Message.php
index 353dc01f9..c4508187b 100644
--- a/classes/Message.php
+++ b/classes/Message.php
@@ -45,11 +45,18 @@ class Message extends Memcached_DataObject
throw new ClientException(_('You are banned from sending direct messages.'));
}
+ $user = User::staticGet('id', $sender->id);
+
$msg = new Message();
$msg->from_profile = $from;
$msg->to_profile = $to;
- $msg->content = common_shorten_links($content);
+ if ($user) {
+ // Use the sender's URL shortening options.
+ $msg->content = $user->shortenLinks($content);
+ } else {
+ $msg->content = common_shorten_links($content);
+ }
$msg->rendered = common_render_text($content);
$msg->created = common_sql_now();
$msg->source = $source;