kopia lustrzana https://github.com/nextcloud/social
commit
abb9402b57
|
@ -36,6 +36,7 @@ use OCA\Social\AppInfo\Application;
|
||||||
use OCA\Social\Exceptions\AccountDoesNotExistException;
|
use OCA\Social\Exceptions\AccountDoesNotExistException;
|
||||||
use OCA\Social\Exceptions\ClientNotFoundException;
|
use OCA\Social\Exceptions\ClientNotFoundException;
|
||||||
use OCA\Social\Exceptions\InstanceDoesNotExistException;
|
use OCA\Social\Exceptions\InstanceDoesNotExistException;
|
||||||
|
use OCA\Social\Exceptions\StreamNotFoundException;
|
||||||
use OCA\Social\Exceptions\UnknownProbeException;
|
use OCA\Social\Exceptions\UnknownProbeException;
|
||||||
use OCA\Social\Model\ActivityPub\ACore;
|
use OCA\Social\Model\ActivityPub\ACore;
|
||||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||||
|
@ -260,6 +261,15 @@ class ApiController extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($status->getInReplyToId() > 0) {
|
||||||
|
try {
|
||||||
|
$replyTo = $this->streamService->getStreamByNid($status->getInReplyToId());
|
||||||
|
$post->setReplyTo($replyTo->getId());
|
||||||
|
} catch (StreamNotFoundException $e) {
|
||||||
|
$this->logger->debug('reply to post not found');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$activity = $this->postService->createPost($post);
|
$activity = $this->postService->createPost($post);
|
||||||
|
|
||||||
$item = $this->streamService->getStreamById(
|
$item = $this->streamService->getStreamById(
|
||||||
|
|
|
@ -955,4 +955,22 @@ class StreamRequest extends StreamRequestBuilder {
|
||||||
|
|
||||||
public function getRelatedToActor(string $actorId) {
|
public function getRelatedToActor(string $actorId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $id
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getDescendants(string $id): array {
|
||||||
|
$qb = $this->getStreamSelectSql(ACore::FORMAT_LOCAL);
|
||||||
|
|
||||||
|
$qb->filterType(SocialAppNotification::TYPE);
|
||||||
|
$qb->limitToViewer('sd', 'f', true);
|
||||||
|
$qb->limitToInReplyTo($id, true);
|
||||||
|
|
||||||
|
$qb->filterDuplicate();
|
||||||
|
|
||||||
|
return $this->getStreamsFromRequest($qb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -606,7 +606,7 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
|
||||||
|
|
||||||
$status = null;
|
$status = null;
|
||||||
if ($statusPost = $this->getDetails('post')) {
|
if ($statusPost = $this->getDetails('post')) {
|
||||||
if (!empty($statusPost)) {
|
if (sizeof($statusPost) > 0) {
|
||||||
$status = new Stream();
|
$status = new Stream();
|
||||||
$status->importFromCache($statusPost);
|
$status->importFromCache($statusPost);
|
||||||
$status->setExportFormat(self::FORMAT_LOCAL);
|
$status->setExportFormat(self::FORMAT_LOCAL);
|
||||||
|
|
|
@ -39,6 +39,7 @@ class Status implements \JsonSerializable {
|
||||||
private string $visibility = '';
|
private string $visibility = '';
|
||||||
private string $spoilerText = '';
|
private string $spoilerText = '';
|
||||||
private array $mediaIds = [];
|
private array $mediaIds = [];
|
||||||
|
private int $inReplyToId = 0;
|
||||||
private string $status = '';
|
private string $status = '';
|
||||||
|
|
||||||
//"media_ids": [],
|
//"media_ids": [],
|
||||||
|
@ -134,6 +135,16 @@ class Status implements \JsonSerializable {
|
||||||
return $this->mediaIds;
|
return $this->mediaIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setInReplyToId(int $inReplyToId): self {
|
||||||
|
$this->inReplyToId = $inReplyToId;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInReplyToId(): int {
|
||||||
|
return $this->inReplyToId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $status
|
* @param string $status
|
||||||
|
@ -160,6 +171,7 @@ class Status implements \JsonSerializable {
|
||||||
$this->setVisibility($this->get('visibility', $data));
|
$this->setVisibility($this->get('visibility', $data));
|
||||||
$this->setSpoilerText($this->get('spoiler_text', $data));
|
$this->setSpoilerText($this->get('spoiler_text', $data));
|
||||||
$this->setMediaIds($this->getArray('media_ids', $data));
|
$this->setMediaIds($this->getArray('media_ids', $data));
|
||||||
|
$this->setInReplyToId($this->getInt('in_reply_to_id', $data));
|
||||||
$this->setStatus($this->get('status', $data));
|
$this->setStatus($this->get('status', $data));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -59,6 +59,7 @@ class StreamService {
|
||||||
private CacheActorService $cacheActorService;
|
private CacheActorService $cacheActorService;
|
||||||
private ConfigService $configService;
|
private ConfigService $configService;
|
||||||
|
|
||||||
|
private const ANCESTOR_LIMIT = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NoteService constructor.
|
* NoteService constructor.
|
||||||
|
@ -349,11 +350,29 @@ class StreamService {
|
||||||
return $this->streamRequest->getStreamById($id, $asViewer, $format);
|
return $this->streamRequest->getStreamById($id, $asViewer, $format);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: returns context for status
|
|
||||||
|
/**
|
||||||
|
* @param int $nid
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws StreamNotFoundException
|
||||||
|
*/
|
||||||
public function getContextByNid(int $nid): array {
|
public function getContextByNid(int $nid): array {
|
||||||
|
$curr = $post = $this->streamRequest->getStreamByNid($nid);
|
||||||
|
|
||||||
|
$ancestors = [];
|
||||||
|
for ($i = 0; $i < self::ANCESTOR_LIMIT; $i++) {
|
||||||
|
if ($curr->getInReplyTo() === '') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$curr = $this->streamRequest->getStreamById($curr->getInReplyTo());
|
||||||
|
$ancestors[] = $curr;
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ancestors' => [],
|
'ancestors' => array_reverse($ancestors),
|
||||||
'descendants' => []
|
'descendants' => $this->streamRequest->getDescendants($post->getId())
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue