kopia lustrzana https://github.com/nextcloud/social
				
				
				
			parse as Note if asked
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/548/head
							rodzic
							
								
									1a04aab7b2
								
							
						
					
					
						commit
						13a03ee457
					
				| 
						 | 
				
			
			@ -73,6 +73,7 @@ use OCA\Social\Model\ActivityPub\Object\Image;
 | 
			
		|||
use OCA\Social\Model\ActivityPub\Object\Note;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\Internal\SocialAppNotification;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\Object\Tombstone;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\Stream;
 | 
			
		||||
use OCA\Social\Service\ConfigService;
 | 
			
		||||
use OCP\AppFramework\QueryException;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -317,6 +318,10 @@ class AP {
 | 
			
		|||
				$item = new SocialAppNotification();
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			case Stream::TYPE:
 | 
			
		||||
				$item = new Stream();
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			case Person::TYPE:
 | 
			
		||||
				$item = new Person();
 | 
			
		||||
				break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -473,7 +473,7 @@ class StreamRequest extends StreamRequestBuilder {
 | 
			
		|||
		$streams = [];
 | 
			
		||||
		$cursor = $qb->execute();
 | 
			
		||||
		while ($data = $cursor->fetch()) {
 | 
			
		||||
			$streams[] = $this->parseStreamSelectSql($data);
 | 
			
		||||
			$streams[] = $this->parseStreamSelectSql($data, Note::TYPE);
 | 
			
		||||
		}
 | 
			
		||||
		$cursor->closeCursor();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,6 +32,7 @@ namespace OCA\Social\Db;
 | 
			
		|||
 | 
			
		||||
use daita\MySmallPhpTools\Traits\TArrayTools;
 | 
			
		||||
use Doctrine\DBAL\Query\QueryBuilder;
 | 
			
		||||
use OCA\Social\AP;
 | 
			
		||||
use OCA\Social\Exceptions\InvalidResourceException;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\ACore;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\Actor\Person;
 | 
			
		||||
| 
						 | 
				
			
			@ -385,11 +386,15 @@ class StreamRequestBuilder extends CoreRequestBuilder {
 | 
			
		|||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @param array $data
 | 
			
		||||
	 * @param string $as
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return Stream
 | 
			
		||||
	 * @throws ItemUnknownException
 | 
			
		||||
	 * @throws SocialAppConfigException
 | 
			
		||||
	 */
 | 
			
		||||
	protected function parseStreamSelectSql($data): Stream {
 | 
			
		||||
		$item = new Stream();
 | 
			
		||||
	protected function parseStreamSelectSql(array $data, string $as = Stream::TYPE): Stream {
 | 
			
		||||
		/** @var Stream $item */
 | 
			
		||||
		$item = AP::$activityPub->getItemFromType($as);
 | 
			
		||||
		$item->importFromDatabase($data);
 | 
			
		||||
 | 
			
		||||
		$instances = json_decode($this->get('instances', $data, '[]'), true);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,6 +41,9 @@ use OCA\Social\Model\StreamAction;
 | 
			
		|||
class Stream extends ACore implements JsonSerializable {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	const TYPE = 'Stream';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	const TYPE_PUBLIC = 'public';
 | 
			
		||||
	const TYPE_UNLISTED = 'unlisted';
 | 
			
		||||
	const TYPE_FOLLOWERS = 'followers';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue