mirror of
https://github.com/friendica/friendica
synced 2025-04-19 07:10:11 +00:00
Most user-item traces removed
This commit is contained in:
parent
ac03399a90
commit
c1d99d6c4c
13 changed files with 139 additions and 153 deletions
|
@ -49,27 +49,17 @@ class Ignore extends BaseModule
|
|||
|
||||
$dba = DI::dba();
|
||||
|
||||
$thread = Post::selectFirstThreadForUser(local_user(), ['uid', 'ignored'], ['iid' => $itemId]);
|
||||
$thread = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId, 'gravity' => GRAVITY_PARENT]);
|
||||
if (!$dba->isResult($thread)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
// Numeric values are needed for the json output further below
|
||||
$ignored = !empty($thread['ignored']) ? 0 : 1;
|
||||
$ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], local_user());
|
||||
|
||||
switch ($thread['uid'] ?? 0) {
|
||||
// if the thread is from the current user
|
||||
case local_user():
|
||||
$dba->update('thread', ['ignored' => $ignored], ['iid' => $itemId]);
|
||||
break;
|
||||
// 0 (null will get transformed to 0) => it's a public post
|
||||
case 0:
|
||||
$dba->update('user-item', ['ignored' => $ignored], ['iid' => $itemId, 'uid' => local_user()], true);
|
||||
break;
|
||||
// Throws a BadRequestException and not a ForbiddenException on purpose
|
||||
// Avoids harvesting existing, but forbidden IIDs (security issue)
|
||||
default:
|
||||
throw new HTTPException\BadRequestException();
|
||||
if (in_array($thread['uid'], [0, local_user()])) {
|
||||
Post\ThreadUser::setIgnored($thread['uri-id'], local_user(), $ignored);
|
||||
} else {
|
||||
throw new HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
// See if we've been passed a return path to redirect to
|
||||
|
|
|
@ -24,8 +24,9 @@ namespace Friendica\Module\Item;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
/**
|
||||
|
@ -47,9 +48,18 @@ class Pin extends BaseModule
|
|||
|
||||
$itemId = intval($parameters['id']);
|
||||
|
||||
$pinned = !Item::getPinned($itemId, local_user());
|
||||
$item = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId]);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
Item::setPinned($itemId, local_user(), $pinned);
|
||||
if (!in_array($item['uid'], [0, local_user()])) {
|
||||
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
|
||||
}
|
||||
|
||||
$pinned = !Post\ThreadUser::getPinned($item['uri-id'], local_user());
|
||||
|
||||
Post\ThreadUser::setPinned($item['uri-id'], local_user(), $pinned);
|
||||
|
||||
// See if we've been passed a return path to redirect to
|
||||
$return_path = $_REQUEST['return'] ?? '';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue