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