From 55c3c54ef6fe3f3d80df01c94d334bdfbf395683 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Feb 2015 19:54:48 -0800 Subject: apply max_import_size to Diaspora posts --- include/diaspora.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 22574f9f8..4280d9d77 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -827,6 +827,12 @@ function diaspora_post($importer,$xml,$msg) { $body = scale_external_images($body); } + $maxlen = get_max_import_size(); + + if($maxlen && mb_strlen($body) > $maxlen) { + $body = mb_substr($body,0,$maxlen,'UTF-8'); + logger('message length exceeds max_import_size: truncated'); + } //WTF? FIXME // Add OEmbed and other information to the body @@ -1040,6 +1046,14 @@ function diaspora_reshare($importer,$xml,$msg) { //return; } + $maxlen = get_max_import_size(); + + if($maxlen && mb_strlen($body) > $maxlen) { + $body = mb_substr($body,0,$maxlen,'UTF-8'); + logger('message length exceeds max_import_size: truncated'); + } + + //if(! $body) { // logger('diaspora_reshare: empty body: source= ' . $x); // return; @@ -1354,6 +1368,15 @@ function diaspora_comment($importer,$xml,$msg) { $body = diaspora2bb($text); + + $maxlen = get_max_import_size(); + + if($maxlen && mb_strlen($body) > $maxlen) { + $body = mb_substr($body,0,$maxlen,'UTF-8'); + logger('message length exceeds max_import_size: truncated'); + } + + $datarray = array(); $tags = get_tags($body); @@ -1540,6 +1563,15 @@ function diaspora_conversation($importer,$xml,$msg) { $body = diaspora2bb($msg_text); + + $maxlen = get_max_import_size(); + + if($maxlen && mb_strlen($body) > $maxlen) { + $body = mb_substr($body,0,$maxlen,'UTF-8'); + logger('message length exceeds max_import_size: truncated'); + } + + $author_signed_data = $msg_guid . ';' . $msg_parent_guid . ';' . $msg_text . ';' . unxmlify($mesg->created_at) . ';' . $msg_diaspora_handle . ';' . $msg_conversation_guid; $author_signature = base64_decode($msg_author_signature); @@ -1677,6 +1709,17 @@ function diaspora_message($importer,$xml,$msg) { $subject = $conversation['subject']; $body = diaspora2bb($msg_text); + + + $maxlen = get_max_import_size(); + + if($maxlen && mb_strlen($body) > $maxlen) { + $body = mb_substr($body,0,$maxlen,'UTF-8'); + logger('message length exceeds max_import_size: truncated'); + } + + + $message_id = $msg_diaspora_handle . ':' . $msg_guid; $author_signed_data = $msg_guid . ';' . $msg_parent_guid . ';' . $msg_text . ';' . unxmlify($xml->created_at) . ';' . $msg_diaspora_handle . ';' . $msg_conversation_guid; -- cgit v1.2.3