X-Git-Url: https://git.mxchange.org/?p=friendica-addons.git;a=blobdiff_plain;f=statusnet%2Fstatusnet.php;h=c54ff55f6c923ce65d4b4e3051bf2d770144884c;hp=7ef171f75f4825d5147ed20375946e00c9800c79;hb=3268eecd722126c532f9cef18b8657c10046a89e;hpb=e38867c19503ef0fc488cd316d67056c48c73beb diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 7ef171f7..c54ff55f 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -38,6 +38,8 @@ define('STATUSNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'statusnetoauth.php'; require_once 'include/enotify.php'; +use Codebird\Codebird; +use CodebirdSN\CodebirdSN; use Friendica\App; use Friendica\Content\OEmbed; use Friendica\Content\Text\BBCode; @@ -51,6 +53,7 @@ use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Photo; use Friendica\Model\User; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; function statusnet_install() @@ -541,7 +544,6 @@ function statusnet_post_hook(App $a, &$b) return; } - require_once 'include/bbcode.php'; $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent @@ -557,12 +559,7 @@ function statusnet_post_hook(App $a, &$b) $image = ""; if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) { - if ((strlen($msgarr["url"]) > 20) && - ((strlen($msg . " \n" . $msgarr["url"]) > $max_char))) { - $msg .= " \n" . Network::shortenUrl($msgarr["url"]); - } else { - $msg .= " \n" . $msgarr["url"]; - } + $msg .= " \n" . $msgarr["url"]; } elseif (isset($msgarr["image"]) && ($msgarr["type"] != "video")) { $image = $msgarr["image"]; } @@ -602,11 +599,7 @@ function statusnet_post_hook(App $a, &$b) logger('Send to GNU Social failed: "' . $result->error . '"'); } elseif ($iscomment) { logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']); - q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", - dbesc($hostname . "::" . $result->id), - dbesc($result->text), - intval($b['id']) - ); + Item::update(['extid' => $hostname . "::" . $result->id, 'body' => $result->text], ['id' => $b['id']]); } } if ($tempfile != "") { @@ -762,7 +755,7 @@ function statusnet_cron(App $a, $b) $abandon_days = 0; } - $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400); + $abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()"); if (count($r)) { @@ -938,7 +931,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) `location`, `about`, `writable`, `blocked`, `readonly`, `pending` ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0 ) ", intval($uid), - dbesc(datetime_convert()), + dbesc(DateTimeFormat::utcNow()), dbesc($contact->statusnet_profile_url), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(statusnet_address($contact)), @@ -979,13 +972,13 @@ function statusnet_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(datetime_convert()), + dbesc(DateTimeFormat::utcNow()), intval($contact_id) ); } else { // update profile photos once every two weeks as we have no notification of when they change. - //$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false); - $update_photo = ($r[0]['avatar-date'] < datetime_convert('', '', 'now -12 hours')); + //$update_photo = (($r[0]['avatar-date'] < DateTimeFormat::convert('now -2 days', '', '', )) ? true : false); + $update_photo = ($r[0]['avatar-date'] < DateTimeFormat::utc('now -12 hours')); // check that we have all the photos, this has been known to fail on occasion if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { @@ -1010,9 +1003,9 @@ function statusnet_fetch_contact($uid, $contact, $create_user) dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc($contact->statusnet_profile_url), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(statusnet_address($contact)), @@ -1199,8 +1192,8 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $postarray['body'] = $converted["body"]; $postarray['tag'] = $converted["tags"]; - $postarray['created'] = datetime_convert('UTC', 'UTC', $content->created_at); - $postarray['edited'] = datetime_convert('UTC', 'UTC', $content->created_at); + $postarray['created'] = DateTimeFormat::utc($content->created_at); + $postarray['edited'] = DateTimeFormat::utc($content->created_at); if (is_string($content->place->name)) { $postarray["location"] = $content->place->name;