kopia lustrzana https://github.com/nextcloud/social
commit
cfc79e1e0f
|
|
@ -266,7 +266,7 @@ class NotesRequest extends NotesRequestBuilder {
|
|||
}
|
||||
$this->leftJoinCacheActors($qb, 'attributed_to');
|
||||
// TODO: to: = real public, cc: = unlisted !?
|
||||
$this->limitToRecipient($qb, ActivityService::TO_PUBLIC);
|
||||
$this->limitToRecipient($qb, ActivityService::TO_PUBLIC, true, ['to']);
|
||||
|
||||
$notes = [];
|
||||
$cursor = $qb->execute();
|
||||
|
|
|
|||
|
|
@ -230,11 +230,12 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
|||
* @param IQueryBuilder $qb
|
||||
* @param string $recipient
|
||||
* @param bool $asAuthor
|
||||
* @param array $type
|
||||
*/
|
||||
protected function limitToRecipient(
|
||||
IQueryBuilder &$qb, string $recipient, bool $asAuthor = false
|
||||
IQueryBuilder &$qb, string $recipient, bool $asAuthor = false, array $type = []
|
||||
) {
|
||||
$qb->andWhere($this->exprLimitToRecipient($qb, $recipient, $asAuthor));
|
||||
$qb->andWhere($this->exprLimitToRecipient($qb, $recipient, $asAuthor, $type));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -242,11 +243,12 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
|||
* @param IQueryBuilder $qb
|
||||
* @param string $recipient
|
||||
* @param bool $asAuthor
|
||||
* @param array $type
|
||||
*
|
||||
* @return ICompositeExpression
|
||||
*/
|
||||
protected function exprLimitToRecipient(
|
||||
IQueryBuilder &$qb, string $recipient, bool $asAuthor = false
|
||||
IQueryBuilder &$qb, string $recipient, bool $asAuthor = false, array $type = []
|
||||
): ICompositeExpression {
|
||||
|
||||
$expr = $qb->expr();
|
||||
|
|
@ -262,15 +264,42 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
|||
);
|
||||
}
|
||||
|
||||
$limit->add($expr->eq('to', $qb->createNamedParameter($recipient)));
|
||||
$limit->add($this->exprValueWithinJsonFormat($qb, 'to_array', $recipient));
|
||||
$limit->add($this->exprValueWithinJsonFormat($qb, 'cc', $recipient));
|
||||
$limit->add($this->exprValueWithinJsonFormat($qb, 'bcc', $recipient));
|
||||
if ($type === []) {
|
||||
$type = ['to', 'cc', 'bcc'];
|
||||
}
|
||||
|
||||
$this->addLimitToRecipient($qb, $limit, $type, $recipient);
|
||||
|
||||
return $limit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param ICompositeExpression $limit
|
||||
* @param array $type
|
||||
* @param string $to
|
||||
*/
|
||||
private function addLimitToRecipient(
|
||||
IQueryBuilder $qb, ICompositeExpression &$limit, array $type, string $to
|
||||
) {
|
||||
|
||||
$expr = $qb->expr();
|
||||
if (in_array('to', $type)) {
|
||||
$limit->add($expr->eq('to', $qb->createNamedParameter($to)));
|
||||
$limit->add($this->exprValueWithinJsonFormat($qb, 'to_array', $to));
|
||||
}
|
||||
|
||||
if (in_array('cc', $type)) {
|
||||
$limit->add($this->exprValueWithinJsonFormat($qb, 'cc', $to));
|
||||
}
|
||||
|
||||
if (in_array('bcc', $type)) {
|
||||
$limit->add($this->exprValueWithinJsonFormat($qb, 'bcc', $to));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $recipient
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue