]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/DirectMessage/classes/Message.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / DirectMessage / classes / Message.php
index 3818a38f48ffcc6dfee7635036644866cf160685..29c177445ca0ffa094ef679eda6a325e45167c04 100644 (file)
@@ -13,12 +13,12 @@ class Message extends Managed_DataObject
 
     public $__table = 'message';                         // table name
     public $id;                              // int(4)  primary_key not_null
-    public $uri;                             // varchar(255)  unique_key
+    public $uri;                             // varchar(191)  unique_key   not 255 because utf8mb4 takes more space
     public $from_profile;                    // int(4)   not_null
     public $to_profile;                      // int(4)   not_null
     public $content;                         // text()
     public $rendered;                        // text()
-    public $url;                             // varchar(255)
+    public $url;                             // varchar(191)   not 255 because utf8mb4 takes more space
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
     public $source;                          // varchar(32)
@@ -31,12 +31,12 @@ class Message extends Managed_DataObject
         return array(
             'fields' => array(
                 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
-                'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier'),
+                'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier'),
                 'from_profile' => array('type' => 'int', 'not null' => true, 'description' => 'who the message is from'),
                 'to_profile' => array('type' => 'int', 'not null' => true, 'description' => 'who the message is to'),
                 'content' => array('type' => 'text', 'description' => 'message content'),
                 'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'),
-                'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'),
+                'url' => array('type' => 'varchar', 'length' => 191, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'),
                 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
                 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
                 'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'),
@@ -83,12 +83,14 @@ class Message extends Managed_DataObject
 
         $msg->from_profile = $from;
         $msg->to_profile = $to;
-        if ($user) {
+
+        if ($user instanceof 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($msg->content);
         $msg->created = common_sql_now();
         $msg->source = $source;