kopia lustrzana https://github.com/nextcloud/social
				
				
				
			limit to liked post
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/642/head
							rodzic
							
								
									e1abbf1987
								
							
						
					
					
						commit
						d985dc87e2
					
				| 
						 | 
				
			
			@ -858,6 +858,59 @@ class CoreRequestBuilder {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @param IQueryBuilder $qb
 | 
			
		||||
	 * @param string $type
 | 
			
		||||
	 */
 | 
			
		||||
	protected function leftJoinActions(IQueryBuilder &$qb, string $type) {
 | 
			
		||||
		if ($qb->getType() !== QueryBuilder::SELECT || $this->viewer === null) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$expr = $qb->expr();
 | 
			
		||||
		$func = $qb->func();
 | 
			
		||||
 | 
			
		||||
		$pf = $this->defaultSelectAlias;
 | 
			
		||||
 | 
			
		||||
		$qb->selectAlias('a.id', 'action_id')
 | 
			
		||||
		   ->selectAlias('a.actor_id', 'action_actor_id')
 | 
			
		||||
		   ->selectAlias('a.object_id', 'action_object_id')
 | 
			
		||||
		   ->selectAlias('a.type', 'action_type');
 | 
			
		||||
 | 
			
		||||
		$andX = $expr->andX();
 | 
			
		||||
		$andX->add($expr->eq($func->lower($pf . '.id'), $func->lower('a.object_id')));
 | 
			
		||||
		$andX->add($expr->eq('a.type', $qb->createNamedParameter($type)));
 | 
			
		||||
		$andX->add(
 | 
			
		||||
			$expr->eq(
 | 
			
		||||
				$func->lower('a.actor_id'),
 | 
			
		||||
				$qb->createNamedParameter(strtolower($this->viewer->getId()))
 | 
			
		||||
			)
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		$qb->leftJoin(
 | 
			
		||||
			$this->defaultSelectAlias, CoreRequestBuilder::TABLE_ACTIONS, 'a', $andX
 | 
			
		||||
		);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @param array $data
 | 
			
		||||
	 */
 | 
			
		||||
	protected function parseActionsLeftJoin(array $data) {
 | 
			
		||||
		$new = [];
 | 
			
		||||
		foreach ($data as $k => $v) {
 | 
			
		||||
			if (substr($k, 0, 7) === 'action_') {
 | 
			
		||||
				$new[substr($k, 7)] = $v;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
//		$action = new Action();
 | 
			
		||||
//		$action->importFromDatabase($new);
 | 
			
		||||
 | 
			
		||||
//		return $action;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @param IQueryBuilder $qb
 | 
			
		||||
	 * @param string $fieldDocumentId
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,6 +44,7 @@ use OCA\Social\Model\ActivityPub\ACore;
 | 
			
		|||
use OCA\Social\Model\ActivityPub\Actor\Person;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\Internal\SocialAppNotification;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\Object\Document;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\Object\Like;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\Object\Note;
 | 
			
		||||
use OCA\Social\Model\ActivityPub\Stream;
 | 
			
		||||
use OCA\Social\Service\ConfigService;
 | 
			
		||||
| 
						 | 
				
			
			@ -524,13 +525,14 @@ class StreamRequest extends StreamRequestBuilder {
 | 
			
		|||
		$this->limitToType($qb, Note::TYPE);
 | 
			
		||||
 | 
			
		||||
		$this->leftJoinCacheActors($qb, 'attributed_to');
 | 
			
		||||
		$this->leftJoinStreamAction($qb);
 | 
			
		||||
		$this->leftJoinActions($qb, Like::TYPE);
 | 
			
		||||
		$this->filterDBField($qb, 'id', '', false, 'a');
 | 
			
		||||
 | 
			
		||||
		$streams = [];
 | 
			
		||||
		$cursor = $qb->execute();
 | 
			
		||||
		while ($data = $cursor->fetch()) {
 | 
			
		||||
			try {
 | 
			
		||||
//				$streams[] = $this->parseStreamSelectSql($data);
 | 
			
		||||
				$streams[] = $this->parseStreamSelectSql($data);
 | 
			
		||||
			} catch (Exception $e) {
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue