mirror of
https://github.com/friendica/friendica
synced 2025-05-01 05:04:24 +02:00
Merge branch 'develop' into mastodon-status-post-with-title
This commit is contained in:
commit
34c4849341
23 changed files with 291 additions and 212 deletions
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2023, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Object\Api\Mastodon;
|
||||
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\Collection\Api\Mastodon\Fields;
|
||||
|
||||
/**
|
||||
* Virtual entity to separate Accounts from Follow Requests.
|
||||
* In the Mastodon API they are one and the same.
|
||||
*/
|
||||
class FollowRequest extends Account
|
||||
{
|
||||
/**
|
||||
* Creates a follow request entity from an introduction record.
|
||||
*
|
||||
* The account ID is set to the Introduction ID to allow for later interaction with follow requests.
|
||||
*
|
||||
* @param BaseURL $baseUrl
|
||||
* @param int $introduction_id Introduction record id
|
||||
* @param array $account entry of "account-user-view"
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function __construct(BaseURL $baseUrl, int $introduction_id, array $account)
|
||||
{
|
||||
parent::__construct($baseUrl, $account, new Fields());
|
||||
|
||||
$this->id = $introduction_id;
|
||||
}
|
||||
}
|
|
@ -534,6 +534,7 @@ class Post
|
|||
'vote' => $buttons,
|
||||
'like_html' => $responses['like']['output'],
|
||||
'dislike_html' => $responses['dislike']['output'],
|
||||
'emojis' => $this->getEmojis($item),
|
||||
'responses' => $responses,
|
||||
'switchcomment' => DI::l10n()->t('Comment'),
|
||||
'reply_label' => DI::l10n()->t('Reply to %s', $profile_name),
|
||||
|
@ -602,6 +603,70 @@ class Post
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch emojis
|
||||
*
|
||||
* @param array $item
|
||||
* @return array
|
||||
*/
|
||||
private function getEmojis(array $item): array
|
||||
{
|
||||
if (empty($item['emojis'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$emojis = [];
|
||||
foreach ($item['emojis'] as $index => $element) {
|
||||
$actors = implode(', ', $element['title']);
|
||||
switch ($element['verb']) {
|
||||
case Activity::ANNOUNCE:
|
||||
$title = DI::l10n()->t('Reshared by: %s', $actors);
|
||||
$icon = ['fa' => 'fa-retweet', 'icon' => 'icon-retweet'];
|
||||
break;
|
||||
|
||||
case Activity::VIEW:
|
||||
$title = DI::l10n()->t('Viewed by: %s', $actors);
|
||||
$icon = ['fa' => 'fa-eye', 'icon' => 'icon-eye-open'];
|
||||
break;
|
||||
|
||||
case Activity::LIKE:
|
||||
$title = DI::l10n()->t('Liked by: %s', $actors);
|
||||
$icon = ['fa' => 'fa-thumbs-up', 'icon' => 'icon-thumbs-up'];
|
||||
break;
|
||||
|
||||
case Activity::DISLIKE:
|
||||
$title = DI::l10n()->t('Disliked by: %s', $actors);
|
||||
$icon = ['fa' => 'fa-thumbs-down', 'icon' => 'icon-thumbs-down'];
|
||||
break;
|
||||
|
||||
case Activity::ATTEND:
|
||||
$title = DI::l10n()->t('Attended by: %s', $actors);
|
||||
$icon = ['fa' => 'fa-check', 'icon' => 'icon-ok'];
|
||||
break;
|
||||
|
||||
case Activity::ATTENDMAYBE:
|
||||
$title = DI::l10n()->t('Maybe attended by: %s', $actors);
|
||||
$icon = ['fa' => 'fa-question', 'icon' => 'icon-question'];
|
||||
break;
|
||||
|
||||
case Activity::ATTENDNO:
|
||||
$title = DI::l10n()->t('Not attended by: %s', $actors);
|
||||
$icon = ['fa' => 'fa-times', 'icon' => 'icon-remove'];
|
||||
break;
|
||||
|
||||
default:
|
||||
$title = DI::l10n()->t('Reacted with %s by: %s', $element['emoji'], $actors);
|
||||
$icon = [];
|
||||
break;
|
||||
break;
|
||||
}
|
||||
$emojis[$index] = ['emoji' => $element['emoji'], 'total' => $element['total'], 'title' => $title, 'icon' => $icon];
|
||||
}
|
||||
ksort($emojis);
|
||||
|
||||
return $emojis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue