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)
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"'),
$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;