kopia lustrzana https://github.com/nextcloud/social
add reblog content to mastadon api
Signed-off-by: Robin Appelman <robin@icewind.nl>pull/1090/head
rodzic
dc5d89fe5c
commit
d045973449
|
@ -657,6 +657,12 @@ class ACore extends Item implements JsonSerializable {
|
|||
$this->setLocal(($this->getInt('local', $data, 0) === 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
public function importFromCache(array $data) {
|
||||
$this->import($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $format
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace OCA\Social\Model\ActivityPub\Object;
|
|||
|
||||
use Exception;
|
||||
use JsonSerializable;
|
||||
use OCA\Social\AP;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\ActivityPub\Stream;
|
||||
|
||||
|
@ -72,26 +73,25 @@ class Announce extends Stream implements JsonSerializable {
|
|||
$this->setAttributedTo($this->getActorId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function importFromDatabase(array $data) {
|
||||
parent::importFromDatabase($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array {
|
||||
$result = parent::jsonSerialize();
|
||||
//$result['actor'] = $this->getAttributedTo();
|
||||
public function exportAsLocal(): array {
|
||||
$result = parent::exportAsLocal();
|
||||
|
||||
if ($this->hasCache()) {
|
||||
$cache = $this->getCache();
|
||||
if ($object = $cache->getItem($this->getObjectId())) {
|
||||
$object = $object->getObject();
|
||||
/** @var Stream $item */
|
||||
$item = AP::$activityPub->getItemFromType($this->get('type', $object, Stream::TYPE));
|
||||
$item->importFromCache($object);
|
||||
$result['reblog'] = $item->exportAsLocal();
|
||||
$result['content'] = $item->getContent();
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ use daita\MySmallPhpTools\Model\CacheItem;
|
|||
use DateTime;
|
||||
use Exception;
|
||||
use JsonSerializable;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Model\StreamAction;
|
||||
use OCA\Social\Traits\TDetails;
|
||||
|
||||
|
@ -436,6 +437,15 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
|
|||
$this->setCache($cache);
|
||||
}
|
||||
|
||||
public function importFromCache(array $data) {
|
||||
parent::importFromCache($data);
|
||||
|
||||
$actor = new Person();
|
||||
$actor->importFromCache($data['actor_info']);
|
||||
$this->setActor($actor);
|
||||
$this->setCompleteDetails(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
@ -520,7 +530,7 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
|
|||
// TODO - store created_at full string with milliseconds ?
|
||||
if ($this->hasActor()) {
|
||||
$actor = $this->getActor();
|
||||
$result['account'] = $actor;
|
||||
$result['account'] = $actor->exportAsLocal();
|
||||
}
|
||||
|
||||
return array_merge(parent::exportAsLocal(), $result);
|
||||
|
|
Ładowanie…
Reference in New Issue