Standards

This commit is contained in:
Michael 2021-11-28 13:52:39 +00:00
parent 19019381e6
commit 367479e50e

View File

@ -24,8 +24,6 @@ namespace Friendica\Module\Api\Twitter\Statuses;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Content\Text\Markdown; use Friendica\Content\Text\Markdown;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -43,7 +41,7 @@ use HTMLPurifier_Config;
* Updates the users current status. * Updates the users current status.
* *
* @see https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update * @see https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update
*/ */
class Update extends BaseApi class Update extends BaseApi
{ {
public function post(array $request = [], array $post = []) public function post(array $request = [], array $post = [])
@ -72,7 +70,7 @@ class Update extends BaseApi
$config->set('Cache.DefinitionImpl', null); $config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
$body = $purifier->purify($body); $body = $purifier->purify($body);
$body = HTML::toBBCode($request['htmlstatus']); $body = HTML::toBBCode($request['htmlstatus']);
} else { } else {
@ -85,11 +83,12 @@ class Update extends BaseApi
return BBCode::expandTags($body); return BBCode::expandTags($body);
}); });
$item = []; $item = [];
$item['uid'] = $uid; $item['uid'] = $uid;
$item['verb'] = Activity::POST; $item['verb'] = Activity::POST;
$item['contact-id'] = $owner['id']; $item['contact-id'] = $owner['id'];
$item['author-id'] = $item['owner-id'] = Contact::getPublicIdByUserId($uid); $item['author-id'] = Contact::getPublicIdByUserId($uid);
$item['owner-id'] = $item['author-id'];
$item['title'] = $request['title']; $item['title'] = $request['title'];
$item['body'] = $body; $item['body'] = $body;
$item['app'] = $request['source']; $item['app'] = $request['source'];
@ -117,6 +116,7 @@ class Update extends BaseApi
if ($request['in_reply_to_status_id']) { if ($request['in_reply_to_status_id']) {
$parent = Post::selectFirst(['uri'], ['id' => $request['in_reply_to_status_id'], 'uid' => [0, $uid]]); $parent = Post::selectFirst(['uri'], ['id' => $request['in_reply_to_status_id'], 'uid' => [0, $uid]]);
$item['thr-parent'] = $parent['uri']; $item['thr-parent'] = $parent['uri'];
$item['gravity'] = GRAVITY_COMMENT; $item['gravity'] = GRAVITY_COMMENT;
$item['object-type'] = Activity\ObjectType::COMMENT; $item['object-type'] = Activity\ObjectType::COMMENT;
@ -155,19 +155,19 @@ class Update extends BaseApi
$ressources[] = $media[0]['resource-id']; $ressources[] = $media[0]['resource-id'];
$phototypes = Images::supportedTypes(); $phototypes = Images::supportedTypes();
$ext = $phototypes[$media[0]['type']]; $ext = $phototypes[$media[0]['type']];
$attachment = ['type' => Post\Media::IMAGE, 'mimetype' => $media[0]['type'], $attachment = ['type' => Post\Media::IMAGE, 'mimetype' => $media[0]['type'],
'url' => DI::baseUrl() . '/photo/' . $media[0]['resource-id'] . '-' . $media[0]['scale'] . '.' . $ext, 'url' => DI::baseUrl() . '/photo/' . $media[0]['resource-id'] . '-' . $media[0]['scale'] . '.' . $ext,
'size' => $media[0]['datasize'], 'size' => $media[0]['datasize'],
'name' => $media[0]['filename'] ?: $media[0]['resource-id'], 'name' => $media[0]['filename'] ?: $media[0]['resource-id'],
'description' => $media[0]['desc'] ?? '', 'description' => $media[0]['desc'] ?? '',
'width' => $media[0]['width'], 'width' => $media[0]['width'],
'height' => $media[0]['height']]; 'height' => $media[0]['height']];
if (count($media) > 1) { if (count($media) > 1) {
$attachment['preview'] = DI::baseUrl() . '/photo/' . $media[1]['resource-id'] . '-' . $media[1]['scale'] . '.' . $ext; $attachment['preview'] = DI::baseUrl() . '/photo/' . $media[1]['resource-id'] . '-' . $media[1]['scale'] . '.' . $ext;
$attachment['preview-width'] = $media[1]['width']; $attachment['preview-width'] = $media[1]['width'];
$attachment['preview-height'] = $media[1]['height']; $attachment['preview-height'] = $media[1]['height'];
} }
$item['attachments'][] = $attachment; $item['attachments'][] = $attachment;