+ /**
+ * 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;
+ }
+