X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FConversation.php;h=249190b1add67c4630aebf2aad6551cd2b5218ff;hb=6394bd91c0f25d9e2c61ca6166a78e9563506554;hp=c5e854b1d9ece6a02f55ab98e9238aec0ef4022b;hpb=8e9b3234f4b75cff396201122ed88ff6d168b139;p=friendica.git diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index c5e854b1d9..249190b1ad 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -314,7 +314,7 @@ class Conversation $tpl = Renderer::getMarkupTemplate('jot-header.tpl'); $this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [ '$newpost' => 'true', - '$baseurl' => $this->baseURL->get(true), + '$baseurl' => $this->baseURL, '$geotag' => $geotag, '$nickname' => $x['nickname'], '$ispublic' => $this->l10n->t('Visible to everybody'), @@ -385,7 +385,7 @@ class Conversation '$posttype' => $notes_cid ? ItemModel::PT_PERSONAL_NOTE : ItemModel::PT_ARTICLE, '$content' => $x['content'] ?? '', '$post_id' => $x['post_id'] ?? '', - '$baseurl' => $this->baseURL->get(true), + '$baseurl' => $this->baseURL, '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$pvisit' => $notes_cid ? 'none' : $x['visitor'], @@ -446,8 +446,6 @@ class Conversation $this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css')); $this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css')); - $ssl_state = (bool)$this->session->getLocalUserId(); - $live_update_div = ''; $blocklist = $this->getBlocklist(); @@ -784,7 +782,7 @@ class Conversation } $o = Renderer::replaceMacros($page_template, [ - '$baseurl' => $this->baseURL->get($ssl_state), + '$baseurl' => $this->baseURL, '$return_path' => $this->args->getQueryString(), '$live_update' => $live_update_div, '$remove' => $this->l10n->t('remove'), @@ -979,6 +977,11 @@ class Conversation $condition['author-hidden'] = false; } + if ($this->config->get('system', 'emoji_activities')) { + $emojis = $this->getEmojis($uriids); + $condition = DBA::mergeConditions($condition, ["(`gravity` != ? OR `origin`)", ItemModel::GRAVITY_ACTIVITY]); + } + $condition = DBA::mergeConditions($condition, ["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW), Verb::getID(Activity::READ)]); @@ -1081,6 +1084,8 @@ class Conversation } foreach ($items as $key => $row) { + $items[$key]['emojis'] = $emojis[$key] ?? []; + $always_display = in_array($mode, [self::MODE_CONTACTS, self::MODE_CONTACT_POSTS]); $items[$key]['user-blocked-author'] = !$always_display && in_array($row['author-id'], $blocks); @@ -1102,6 +1107,53 @@ class Conversation return $items; } + /** + * Fetch emoji reaction from the conversation + * + * @param array $uriids + * @return array + */ + private function getEmojis(array $uriids): array + { + $activity_emoji = [ + Activity::LIKE => '👍', + Activity::DISLIKE => '👎', + Activity::ATTEND => '✔️', + Activity::ATTENDMAYBE => '❓', + Activity::ATTENDNO => '❌', + Activity::ANNOUNCE => '♻', + Activity::VIEW => '📺', + ]; + + $index_list = array_values($activity_emoji); + $verbs = array_merge(array_keys($activity_emoji), [Activity::EMOJIREACT]); + + $condition = DBA::mergeConditions(['parent-uri-id' => $uriids, 'gravity' => ItemModel::GRAVITY_ACTIVITY, 'verb' => $verbs], ["NOT `deleted`"]); + $separator = chr(255) . chr(255) . chr(255); + + $sql = "SELECT `thr-parent-id`, `body`, `verb`, COUNT(*) AS `total`, GROUP_CONCAT(REPLACE(`author-name`, '" . $separator . "', ' ') SEPARATOR '". $separator ."' LIMIT 50) AS `title` FROM `post-view` WHERE " . array_shift($condition) . " GROUP BY `thr-parent-id`, `verb`, `body`"; + + $emojis = []; + + $rows = DBA::p($sql, $condition); + while ($row = DBA::fetch($rows)) { + $row['verb'] = $row['body'] ? Activity::EMOJIREACT : $row['verb']; + $emoji = $row['body'] ?: $activity_emoji[$row['verb']]; + if (!isset($index_list[$emoji])) { + $index_list[] = $emoji; + } + $index = array_search($emoji, $index_list); + + $emojis[$row['thr-parent-id']][$index]['emoji'] = $emoji; + $emojis[$row['thr-parent-id']][$index]['verb'] = $row['verb']; + $emojis[$row['thr-parent-id']][$index]['total'] = ($emojis[$row['thr-parent-id']][$index]['total'] ?? 0) + $row['total']; + $emojis[$row['thr-parent-id']][$index]['title'] = array_unique(array_merge($emojis[$row['thr-parent-id']][$index]['title'] ?? [], explode($separator, $row['title']))); + } + DBA::close($rows); + + return $emojis; + } + /** * Plucks the children of the given parent from a given item list. *