- 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();