kopia lustrzana https://github.com/nextcloud/social
Merge pull request #761 from nextcloud/bugfix/noid/viewer-rights-on-singlepost
fix viewer rightspull/777/head
commit
453d03f038
|
@ -37,6 +37,7 @@ use OCA\Social\Exceptions\CacheActorDoesNotExistException;
|
|||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\StreamNotFoundException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Service\AccountService;
|
||||
use OCA\Social\Service\CacheActorService;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\StreamService;
|
||||
|
@ -69,6 +70,9 @@ class SocialPubController extends Controller {
|
|||
/** @var NavigationController */
|
||||
private $navigationController;
|
||||
|
||||
/** @var AccountService */
|
||||
private $accountService;
|
||||
|
||||
/** @var CacheActorService */
|
||||
private $cacheActorService;
|
||||
|
||||
|
@ -87,18 +91,21 @@ class SocialPubController extends Controller {
|
|||
* @param IL10N $l10n
|
||||
* @param NavigationController $navigationController
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param AccountService $accountService
|
||||
* @param StreamService $streamService
|
||||
* @param ConfigService $configService
|
||||
*/
|
||||
public function __construct(
|
||||
$userId, IRequest $request, IL10N $l10n, NavigationController $navigationController,
|
||||
CacheActorService $cacheActorService, StreamService $streamService, ConfigService $configService
|
||||
CacheActorService $cacheActorService, AccountService $accountService, StreamService $streamService,
|
||||
ConfigService $configService
|
||||
) {
|
||||
parent::__construct(Application::APP_NAME, $request);
|
||||
|
||||
$this->userId = $userId;
|
||||
$this->l10n = $l10n;
|
||||
$this->navigationController = $navigationController;
|
||||
$this->accountService = $accountService;
|
||||
$this->cacheActorService = $cacheActorService;
|
||||
$this->streamService = $streamService;
|
||||
$this->configService = $configService;
|
||||
|
@ -210,8 +217,16 @@ class SocialPubController extends Controller {
|
|||
*/
|
||||
public function displayPost(string $username, string $token): TemplateResponse {
|
||||
$postId = $this->configService->getSocialUrl() . '@' . $username . '/' . $token;
|
||||
// TODO: remove this, as viewer rights are already implemented in LocalController
|
||||
$stream = $this->streamService->getStreamById($postId, false);
|
||||
|
||||
if (isset($this->userId)) {
|
||||
try {
|
||||
$viewer = $this->accountService->getActorFromUserId($this->userId, true);
|
||||
$this->streamService->setViewer($viewer);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
$stream = $this->streamService->getStreamById($postId, true);
|
||||
$data = [
|
||||
'id' => $postId,
|
||||
'item' => $stream,
|
||||
|
|
|
@ -65,33 +65,29 @@ class StreamDestRequest extends StreamDestRequestBuilder {
|
|||
* @param Stream $stream
|
||||
*/
|
||||
public function generateStreamDest(Stream $stream) {
|
||||
$recipients = [
|
||||
'to' => $stream->getToAll(),
|
||||
'cc' => $stream->getCcArray(),
|
||||
'bcc' => $stream->getBccArray(),
|
||||
'attributed_to' => [$stream->getAttributedTo()]
|
||||
];
|
||||
$recipients = array_merge(
|
||||
$stream->getToAll(), $stream->getCcArray(), $stream->getBccArray(),
|
||||
[$stream->getAttributedTo()]
|
||||
);
|
||||
|
||||
$streamId = $this->prim($stream->getId());
|
||||
foreach (array_keys($recipients) as $dest) {
|
||||
$type = $dest;
|
||||
foreach ($recipients[$dest] as $actorId) {
|
||||
if ($actorId === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$qb = $this->getStreamDestInsertSql();
|
||||
|
||||
$qb->setValue('stream_id', $qb->createNamedParameter($streamId));
|
||||
$qb->setValue('actor_id', $qb->createNamedParameter($this->prim($actorId)));
|
||||
$qb->setValue('type', $qb->createNamedParameter($type));
|
||||
try {
|
||||
$qb->execute();
|
||||
} catch (UniqueConstraintViolationException $e) {
|
||||
\OC::$server->getLogger()
|
||||
->log(3, 'Social - Duplicate recipient on Stream ' . json_encode($stream));
|
||||
}
|
||||
foreach ($recipients as $actorId) {
|
||||
if ($actorId === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$qb = $this->getStreamDestInsertSql();
|
||||
|
||||
$qb->setValue('stream_id', $qb->createNamedParameter($streamId));
|
||||
$qb->setValue('actor_id', $qb->createNamedParameter($this->prim($actorId)));
|
||||
$qb->setValue('type', $qb->createNamedParameter('recipient'));
|
||||
try {
|
||||
$qb->execute();
|
||||
} catch (UniqueConstraintViolationException $e) {
|
||||
\OC::$server->getLogger()
|
||||
->log(3, 'Social - Duplicate recipient on Stream ' . json_encode($stream));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -376,7 +376,7 @@ class Version0002Date20190916000001 extends SimpleMigrationStep {
|
|||
|
||||
$insert->setValue('stream_id', $insert->createNamedParameter($streamId));
|
||||
$insert->setValue('actor_id', $insert->createNamedParameter(hash('sha512', $actorId)));
|
||||
$insert->setValue('type', $insert->createNamedParameter($type));
|
||||
$insert->setValue('type', $insert->createNamedParameter('recipient'));
|
||||
|
||||
try {
|
||||
$insert->execute();
|
||||
|
|
Ładowanie…
Reference in New Issue