Quote for notifications

This commit is contained in:
Michael 2023-01-25 20:35:10 +00:00
parent b6fcfebd56
commit 30093fd2ec
3 changed files with 6 additions and 5 deletions

View File

@ -47,11 +47,12 @@ class Notification extends BaseFactory
/** /**
* @param Notifications\Entity\Notification $Notification * @param Notifications\Entity\Notification $Notification
* @param bool $display_quote Display quoted posts
* *
* @return MstdnNotification * @return MstdnNotification
* @throws UnexpectedNotificationTypeException * @throws UnexpectedNotificationTypeException
*/ */
public function createFromNotification(Notifications\Entity\Notification $Notification): MstdnNotification public function createFromNotification(Notifications\Entity\Notification $Notification, bool $display_quotes): MstdnNotification
{ {
$type = self::getType($Notification); $type = self::getType($Notification);
if (empty($type)) { if (empty($type)) {
@ -62,7 +63,7 @@ class Notification extends BaseFactory
if ($Notification->targetUriId) { if ($Notification->targetUriId) {
try { try {
$status = $this->mstdnStatusFactory->createFromUriId($Notification->targetUriId, $Notification->uid); $status = $this->mstdnStatusFactory->createFromUriId($Notification->targetUriId, $Notification->uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Throwable $th) {
$status = null; $status = null;
} }

View File

@ -87,7 +87,7 @@ class Status extends BaseFactory
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws ImagickException|HTTPException\NotFoundException * @throws ImagickException|HTTPException\NotFoundException
*/ */
public function createFromUriId(int $uriId, int $uid = 0, bool $display_quote = false, bool $reblog = true, bool $in_reply_status = true): \Friendica\Object\Api\Mastodon\Status public function createFromUriId(int $uriId, int $uid = 0, bool $display_quote, bool $reblog = true, bool $in_reply_status = true): \Friendica\Object\Api\Mastodon\Status
{ {
$fields = ['uri-id', 'uid', 'author-id', 'causer-id', 'author-uri-id', 'author-link', 'causer-uri-id', 'post-reason', 'starred', 'app', 'title', 'body', 'raw-body', 'content-warning', 'question-id', $fields = ['uri-id', 'uid', 'author-id', 'causer-id', 'author-uri-id', 'author-link', 'causer-uri-id', 'post-reason', 'starred', 'app', 'title', 'body', 'raw-body', 'content-warning', 'question-id',
'created', 'network', 'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity', 'featured', 'has-media', 'quote-uri-id']; 'created', 'network', 'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity', 'featured', 'has-media', 'quote-uri-id'];

View File

@ -49,7 +49,7 @@ class Notifications extends BaseApi
$id = $this->parameters['id']; $id = $this->parameters['id'];
try { try {
$notification = DI::notification()->selectOneForUser($uid, ['id' => $id]); $notification = DI::notification()->selectOneForUser($uid, ['id' => $id]);
System::jsonExit(DI::mstdnNotification()->createFromNotification($notification)); System::jsonExit(DI::mstdnNotification()->createFromNotification($notification, self::appSupportsQuotes()));
} catch (\Exception $e) { } catch (\Exception $e) {
DI::mstdnError()->RecordNotFound(); DI::mstdnError()->RecordNotFound();
} }
@ -134,7 +134,7 @@ class Notifications extends BaseApi
foreach($Notifications as $Notification) { foreach($Notifications as $Notification) {
try { try {
$mstdnNotifications[] = DI::mstdnNotification()->createFromNotification($Notification); $mstdnNotifications[] = DI::mstdnNotification()->createFromNotification($Notification, self::appSupportsQuotes());
self::setBoundaries($Notification->id); self::setBoundaries($Notification->id);
} catch (\Exception $e) { } catch (\Exception $e) {
// Skip this notification // Skip this notification