Merge pull request #14444 from annando/Emoji-count

Fix counter for emoji reactions
This commit is contained in:
Tobias Diekershoff 2024-09-22 17:35:26 +02:00 committed by GitHub
commit a2ad3080e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 23 deletions

View file

@ -1018,18 +1018,18 @@ class Conversation
}
// @todo The following code should be removed, once that we display activity authors on demand
$activity_emoji = [
Activity::LIKE => '👍',
Activity::DISLIKE => '👎',
Activity::ATTEND => '✔️',
Activity::ATTENDMAYBE => '❓',
Activity::ATTENDNO => '❌',
Activity::ANNOUNCE => '♻',
Activity::VIEW => '📺',
Activity::READ => '📖',
$activity_verbs = [
Activity::LIKE,
Activity::DISLIKE,
Activity::ATTEND,
Activity::ATTENDMAYBE,
Activity::ATTENDNO,
Activity::ANNOUNCE,
Activity::VIEW,
Activity::READ,
];
$verbs = array_merge(array_keys($activity_emoji), [Activity::EMOJIREACT, Activity::POST]);
$verbs = array_merge($activity_verbs, [Activity::EMOJIREACT, Activity::POST]);
$condition = DBA::mergeConditions(['parent-uri-id' => $uriids, 'gravity' => [ItemModel::GRAVITY_ACTIVITY, ItemModel::GRAVITY_COMMENT], 'verb' => $verbs], ["NOT `deleted`"]);
$separator = chr(255) . chr(255) . chr(255);
@ -1038,7 +1038,7 @@ class Conversation
$rows = DBA::p($sql, $condition);
while ($row = DBA::fetch($rows)) {
if ($row['gravity'] == ItemModel::GRAVITY_ACTIVITY) {
$emoji = $row['body'] ?: $activity_emoji[$row['verb']];
$emoji = $row['body'] ?: $row['verb'];
} else {
$emoji = '';
}

View file

@ -82,18 +82,18 @@ class Counts
{
$counts = [];
$activity_emoji = [
Activity::LIKE => '👍',
Activity::DISLIKE => '👎',
Activity::ATTEND => '✔️',
Activity::ATTENDMAYBE => '❓',
Activity::ATTENDNO => '❌',
Activity::ANNOUNCE => '♻',
Activity::VIEW => '📺',
Activity::READ => '📖',
$activity_verbs = [
Activity::LIKE,
Activity::DISLIKE,
Activity::ATTEND,
Activity::ATTENDMAYBE,
Activity::ATTENDNO,
Activity::ANNOUNCE,
Activity::VIEW,
Activity::READ,
];
$verbs = array_merge(array_keys($activity_emoji), [Activity::EMOJIREACT, Activity::POST]);
$verbs = array_merge($activity_verbs, [Activity::EMOJIREACT, Activity::POST]);
$condition = DBA::mergeConditions($condition, ['verb' => $verbs]);
$countquery = DBA::select('post-counts-view', [], $condition);
@ -101,8 +101,8 @@ class Counts
if (!empty($count['reaction'])) {
$count['verb'] = Activity::EMOJIREACT;
$count['vid'] = Verb::getID($count['verb']);
} elseif (!empty($activity_emoji[$count['verb']])) {
$count['reaction'] = $activity_emoji[$count['verb']];
} elseif (in_array($count['verb'], $activity_verbs)) {
$count['reaction'] = $count['verb'];
}
$counts[] = $count;
}