- made variable $uriId camel-case
This commit is contained in:
Roland Häder 2022-06-23 16:04:20 +02:00
parent 52d971ceab
commit 6c84c9dfc9
No known key found for this signature in database
GPG key ID: C82EDE5DDFA0BA77

View file

@ -1592,16 +1592,16 @@ function twitter_expand_entities($body, stdClass $status)
/** /**
* Store entity attachments * Store entity attachments
* *
* @param integer $uriid * @param integer $uriId
* @param object $post Twitter object with the post * @param object $post Twitter object with the post
*/ */
function twitter_store_attachments(int $uriid, $post) function twitter_store_attachments(int $uriId, $post)
{ {
if (!empty($post->extended_entities->media)) { if (!empty($post->extended_entities->media)) {
foreach ($post->extended_entities->media AS $medium) { foreach ($post->extended_entities->media AS $medium) {
switch ($medium->type) { switch ($medium->type) {
case 'photo': case 'photo':
$attachment = ['uri-id' => $uriid, 'type' => Post\Media::IMAGE]; $attachment = ['uri-id' => $uriId, 'type' => Post\Media::IMAGE];
$attachment['url'] = $medium->media_url_https . '?name=large'; $attachment['url'] = $medium->media_url_https . '?name=large';
$attachment['width'] = $medium->sizes->large->w; $attachment['width'] = $medium->sizes->large->w;
@ -1620,7 +1620,7 @@ function twitter_store_attachments(int $uriid, $post)
break; break;
case 'video': case 'video':
case 'animated_gif': case 'animated_gif':
$attachment = ['uri-id' => $uriid, 'type' => Post\Media::VIDEO]; $attachment = ['uri-id' => $uriId, 'type' => Post\Media::VIDEO];
if (is_array($medium->video_info->variants)) { if (is_array($medium->video_info->variants)) {
$bitrate = 0; $bitrate = 0;
// We take the video with the highest bitrate // We take the video with the highest bitrate
@ -1648,7 +1648,7 @@ function twitter_store_attachments(int $uriid, $post)
if (!empty($post->entities->urls)) { if (!empty($post->entities->urls)) {
foreach ($post->entities->urls as $url) { foreach ($post->entities->urls as $url) {
$attachment = ['uri-id' => $uriid, 'type' => Post\Media::UNKNOWN, 'url' => $url->expanded_url, 'name' => $url->display_url]; $attachment = ['uri-id' => $uriId, 'type' => Post\Media::UNKNOWN, 'url' => $url->expanded_url, 'name' => $url->display_url];
Logger::debug('Attached link', ['attachment' => $attachment]); Logger::debug('Attached link', ['attachment' => $attachment]);
Post\Media::insert($attachment); Post\Media::insert($attachment);
} }
@ -1660,9 +1660,9 @@ function twitter_store_attachments(int $uriid, $post)
* *
* @param object $post Twitter object with the post * @param object $post Twitter object with the post
* @param array $postarray Array of the item that is about to be posted * @param array $postarray Array of the item that is about to be posted
* @param integer $uriid URI Id used to store tags. -1 = don't store tags for this post. * @param integer $uriId URI Id used to store tags. -1 = don't store tags for this post.
*/ */
function twitter_media_entities($post, array &$postarray, int $uriid = -1) function twitter_media_entities($post, array &$postarray, int $uriId = -1)
{ {
// There are no media entities? So we quit. // There are no media entities? So we quit.
if (empty($post->extended_entities->media)) { if (empty($post->extended_entities->media)) {
@ -1714,7 +1714,7 @@ function twitter_media_entities($post, array &$postarray, int $uriid = -1)
} }
} }
if ($uriid != -1) { if ($uriId != -1) {
foreach ($media AS $key => $value) { foreach ($media AS $key => $value) {
$postarray['body'] = str_replace($key, '', $postarray['body']); $postarray['body'] = str_replace($key, '', $postarray['body']);
} }
@ -1737,10 +1737,10 @@ function twitter_media_entities($post, array &$postarray, int $uriid = -1)
* @param bool $create_user Should users be created? * @param bool $create_user Should users be created?
* @param bool $only_existing_contact Only import existing contacts if set to "true" * @param bool $only_existing_contact Only import existing contacts if set to "true"
* @param bool $noquote * @param bool $noquote
* @param integer $uriid URI Id used to store tags. 0 = create a new one; -1 = don't store tags for this post. * @param integer $uriId URI Id used to store tags. 0 = create a new one; -1 = don't store tags for this post.
* @return array item array * @return array item array
*/ */
function twitter_createpost(App $a, int $uid, $post, array $self, $create_user, bool $only_existing_contact, $noquote, int $uriid = 0) function twitter_createpost(App $a, int $uid, $post, array $self, $create_user, bool $only_existing_contact, $noquote, int $uriId = 0): array
{ {
$postarray = []; $postarray = [];
$postarray['network'] = Protocol::TWITTER; $postarray['network'] = Protocol::TWITTER;
@ -1751,8 +1751,8 @@ function twitter_createpost(App $a, int $uid, $post, array $self, $create_user,
$postarray['source'] = json_encode($post); $postarray['source'] = json_encode($post);
$postarray['direction'] = Conversation::PULL; $postarray['direction'] = Conversation::PULL;
if (empty($uriid)) { if (empty($uriId)) {
$uriid = $postarray['uri-id'] = ItemURI::insert(['uri' => $postarray['uri']]); $uriId = $postarray['uri-id'] = ItemURI::insert(['uri' => $postarray['uri']]);
} }
// Don't import our own comments // Don't import our own comments
@ -1845,7 +1845,7 @@ function twitter_createpost(App $a, int $uid, $post, array $self, $create_user,
} }
// Search for media links // Search for media links
twitter_media_entities($post, $postarray, $uriid); twitter_media_entities($post, $postarray, $uriId);
$converted = twitter_expand_entities($postarray['body'], $post); $converted = twitter_expand_entities($postarray['body'], $post);
@ -1858,9 +1858,9 @@ function twitter_createpost(App $a, int $uid, $post, array $self, $create_user,
$postarray['created'] = DateTimeFormat::utc($post->created_at); $postarray['created'] = DateTimeFormat::utc($post->created_at);
$postarray['edited'] = DateTimeFormat::utc($post->created_at); $postarray['edited'] = DateTimeFormat::utc($post->created_at);
if ($uriid > 0) { if ($uriId > 0) {
twitter_store_tags($uriid, $converted['taglist']); twitter_store_tags($uriId, $converted['taglist']);
twitter_store_attachments($uriid, $post); twitter_store_attachments($uriId, $post);
} }
if (!empty($post->place->name)) { if (!empty($post->place->name)) {
@ -1916,7 +1916,7 @@ function twitter_createpost(App $a, int $uid, $post, array $self, $create_user,
if (!empty($quoted['body'])) { if (!empty($quoted['body'])) {
Item::insert($quoted); Item::insert($quoted);
$post = Post::selectFirst(['guid', 'uri-id'], ['uri' => $quoted['uri'], 'uid' => 0]); $post = Post::selectFirst(['guid', 'uri-id'], ['uri' => $quoted['uri'], 'uid' => 0]);
Logger::info('Stored quoted post', ['uid' => $uid, 'uri-id' => $uriid, 'post' => $post]); Logger::info('Stored quoted post', ['uid' => $uid, 'uri-id' => $uriId, 'post' => $post]);
$postarray['body'] .= "\n" . BBCode::getShareOpeningTag( $postarray['body'] .= "\n" . BBCode::getShareOpeningTag(
$quoted['author-name'], $quoted['author-name'],
@ -1941,13 +1941,14 @@ function twitter_createpost(App $a, int $uid, $post, array $self, $create_user,
/** /**
* Store tags and mentions * Store tags and mentions
* *
* @param integer $uriid * @param integer $uriId
* @param array $taglist * @param array $taglist
* @return void
*/ */
function twitter_store_tags(int $uriid, array $taglist) function twitter_store_tags(int $uriId, array $taglist)
{ {
foreach ($taglist as $tag) { foreach ($taglist as $tag) {
Tag::storeByHash($uriid, $tag[0], $tag[1], $tag[2]); Tag::storeByHash($uriId, $tag[0], $tag[1], $tag[2]);
} }
} }
@ -2228,7 +2229,7 @@ function twitter_fetch_own_contact(App $a, int $uid)
return $contact_id; return $contact_id;
} }
function twitter_is_retweet(App $a, int $uid, string $body) function twitter_is_retweet(App $a, int $uid, string $body): bool
{ {
$body = trim($body); $body = trim($body);
@ -2267,7 +2268,7 @@ function twitter_is_retweet(App $a, int $uid, string $body)
return twitter_retweet($uid, $id); return twitter_retweet($uid, $id);
} }
function twitter_retweet(int $uid, int $id, int $item_id = 0) function twitter_retweet(int $uid, int $id, int $item_id = 0): bool
{ {
Logger::info('Retweeting', ['user' => $uid, 'id' => $id]); Logger::info('Retweeting', ['user' => $uid, 'id' => $id]);