assertApiScope('thread:write'); /** @var Thread $thread */ $thread = $this->assertRecordExists('XF:Thread', $params->thread_id, ['FirstPost'] ); if( $thread->discussion_state !== 'deleted' ) return $this->error("This thread is not deleted.", 'not_deleted' ); if(!$thread->canUndelete($error)){ return $this->noPermission($error); } $thread->discussion_state = 'visible'; $thread->save(); return $this->apiSuccess([ 'thread' => $thread->toApiResult() ]); } }