Fixed message, relationships endpoint added

This commit is contained in:
Michael 2021-05-15 10:55:41 +00:00
parent 6175b065ec
commit 6a5083d918
10 changed files with 73 additions and 14 deletions

View file

@ -0,0 +1,59 @@
<?php
/**
* @copyright Copyright (C) 2010-2021, 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\Module\Api\Mastodon\Accounts;
use Friendica\Core\Search as CoreSearch;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Module\BaseApi;
use Friendica\Object\Search\ContactResult;
/**
* @see https://docs.joinmastodon.org/methods/accounts/
*/
class Relationships extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
{
self::login();
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$relationsships = [];
foreach ($parameters['id'] as $id) {
$relationsships[] = DI::mstdnRelationship()->createFromPublicContactId($id, $uid);
}
System::jsonExit($relationsships);
}
}

View file

@ -48,7 +48,7 @@ class Bookmark extends BaseApi
}
if ($item['gravity'] != GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be bookmarked'));
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be bookmarked'));
}
Item::update(['starred' => true], ['id' => $item['id']]);

View file

@ -47,7 +47,7 @@ class Mute extends BaseApi
}
if ($item['gravity'] != GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be muted'));
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted'));
}
Post\ThreadUser::setIgnored($parameters['id'], $uid, true);

View file

@ -47,7 +47,7 @@ class Pin extends BaseApi
}
if ($item['gravity'] != GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be pinned'));
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned'));
}
Post\ThreadUser::setPinned($parameters['id'], $uid, true);

View file

@ -48,7 +48,7 @@ class Unbookmark extends BaseApi
}
if ($item['gravity'] != GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be unbookmarked'));
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unbookmarked'));
}
Item::update(['starred' => false], ['id' => $item['id']]);

View file

@ -47,7 +47,7 @@ class Unmute extends BaseApi
}
if ($item['gravity'] != GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be unmuted'));
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted'));
}
Post\ThreadUser::setIgnored($parameters['id'], $uid, false);

View file

@ -47,7 +47,7 @@ class Unpin extends BaseApi
}
if ($item['gravity'] != GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting post can be pinned'));
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned'));
}
Post\ThreadUser::setPinned($parameters['id'], $uid, false);