}
$item = twitter_createpost($a, 0, $status, [], true, false, true);
+ if (empty($item)) {
+ return;
+ }
if ($b['format'] == 'json') {
$images = [];
// We don't support nested shares, so we mustn't show quotes as shares on retweets
$item = twitter_createpost($a, $uid, $post->retweeted_status, ['id' => 0], false, false, true, -1);
- if (empty($item['body'])) {
+ if (empty($item)) {
return [];
}
} else {
$item = twitter_createpost($a, $uid, $post, ['id' => 0], false, false, false, -1);
- if (empty($item['body'])) {
+ if (empty($item)) {
return [];
}
return $datarray;
}
-function twitter_fetchtimeline(App $a, int $uid)
+/**
+ * Fetches the Twitter user's own posts
+ *
+ * @param App $a
+ * @param int $uid
+ * @return void
+ * @throws Exception
+ */
+function twitter_fetchtimeline(App $a, int $uid): void
{
$ckey = DI::config()->get('twitter', 'consumerkey');
$csecret = DI::config()->get('twitter', 'consumersecret');
if (!empty($post->retweeted_status)) {
$retweet = twitter_createpost($a, $uid, $post->retweeted_status, $self, false, false, $noquote);
- if (empty($retweet['body'])) {
+ if (empty($retweet)) {
return [];
}
$postarray['body'] .= "\n\nhttps://twitter.com/" . $post->quoted_status->user->screen_name . "/status/" . $post->quoted_status->id_str;
} else {
$quoted = twitter_createpost($a, 0, $post->quoted_status, $self, false, false, true);
- if (!empty($quoted['body'])) {
+ if (!empty($quoted)) {
Item::insert($quoted);
$post = Post::selectFirst(['guid', 'uri-id'], ['uri' => $quoted['uri'], 'uid' => 0]);
Logger::info('Stored quoted post', ['uid' => $uid, 'uri-id' => $uriId, 'post' => $post]);
foreach ($posts as $post) {
$postarray = twitter_createpost($a, $uid, $post, $self, false, !DI::pConfig()->get($uid, 'twitter', 'create_user'), false);
- if (empty($postarray['body'])) {
+ if (empty($postarray)) {
continue;
}
}
}
-function twitter_fetchhometimeline(App $a, int $uid)
+/**
+ * Fetches the posts received by the Twitter user
+ *
+ * @param App $a
+ * @param int $uid
+ * @return void
+ * @throws Exception
+ */
+function twitter_fetchhometimeline(App $a, int $uid): void
{
$ckey = DI::config()->get('twitter', 'consumerkey');
$csecret = DI::config()->get('twitter', 'consumersecret');
$postarray = twitter_createpost($a, $uid, $post, $self, $create_user, true, false);
- if (empty($postarray['body']) || trim($postarray['body']) == '') {
- Logger::info('Empty body for post ' . $post->id_str . ' and user ' . $uid);
+ if (empty($postarray)) {
+ Logger::info('Empty post ' . $post->id_str . ' and user ' . $uid);
continue;
}
$postarray = twitter_createpost($a, $uid, $post, $self, false, !$create_user, false);
- if (empty($postarray['body'])) {
+ if (empty($postarray)) {
continue;
}