use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
+use Friendica\Model\Conversation;
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Item;
*/
function twitter_do_mirrorpost(App $a, $uid, $post)
{
- // $datarray['object'] = json_encode($post); // Activate for debugging
$datarray['api_source'] = true;
$datarray['profile_uid'] = $uid;
$datarray['extid'] = NETWORK_TWITTER;
$datarray['message_id'] = Item::newURI($uid, NETWORK_TWITTER . ':' . $post->id);
+ $datarray['protocol'] = Conversation::PARCEL_TWITTER;
+ $datarray['source'] = json_encode($post);
$datarray['title'] = '';
if (!empty($post->retweeted_status)) {
$tempfile = tempnam(get_temppath(), "cache");
file_put_contents($tempfile, $img_str);
- $mime = image_type_to_mime_type(exif_imagetype($tempfile));
+
+ // See http://php.net/manual/en/function.exif-imagetype.php#79283
+ if (filesize($tempfile) > 11) {
+ $mime = image_type_to_mime_type(exif_imagetype($tempfile));
+ } else {
+ $mime = false;
+ }
+
unlink($tempfile);
if (substr($mime, 0, 6) == "image/") {
$postarray['uid'] = $uid;
$postarray['wall'] = 0;
$postarray['uri'] = "twitter::" . $post->id_str;
- // $postarray['object'] = json_encode($post); // Activate for debugging
+ $postarray['protocol'] = Conversation::PARCEL_TWITTER;
+ $postarray['source'] = json_encode($post);
// Don't import our own comments
if (DBA::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) {
if (!empty($post->retweeted_status)) {
$retweet = twitter_createpost($a, $uid, $post->retweeted_status, $self, false, false, $noquote);
- //$retweet['object'] = $postarray['object']; // Activate for debugging
+ $retweet['source'] = $postarray['source'];
$retweet['private'] = $postarray['private'];
$retweet['allow_cid'] = $postarray['allow_cid'];
$retweet['contact-id'] = $postarray['contact-id'];