<commit_before><?php

declare(strict_types=1);

/*
 * +----------------------------------------------------------------------+
 * |                          ThinkSNS Plus                               |
 * +----------------------------------------------------------------------+
 * | Copyright (c) 2018 <NAME> Technology Co., Ltd.     |
 * +----------------------------------------------------------------------+
 * | This source file is subject to version 2.0 of the Apache license,    |
 * | that is bundled with this package in the file LICENSE, and is        |
 * | available through the world-wide-web at the following url:           |
 * | http://www.apache.org/licenses/LICENSE-2.0.html                      |
 * +----------------------------------------------------------------------+
 * | Author: <NAME> <<EMAIL>>                          |
 * | Homepage: www.thinksns.com                                           |
 * +----------------------------------------------------------------------+
 */

namespace Zhiyi\Plus\Http\Controllers\APIs\V2;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Zhiyi\Plus\Models\Conversation;

class SystemController extends Controller
{
    /**
     * create a feedback.
     *
     * @author bs<<EMAIL>>
     * @param  Request $request
     * @return mixed
     */
    public function createFeedback(Request $request, Conversation $feedback, Carbon $datetime)
    {
        $feedback->type = 'feedback';
        $feedback->content = $request->input('content');
        $feedback->user_id = $request->user()->id;
        $feedback->system_mark = $request->input('system_mark', ($datetime->timestamp) * 1000);
        $feedback->save();

        return response()->json([
            'message' => ['反馈成功'],
            'data' => $feedback,
        ])->setStatusCode(201);
    }

    /**
     * about us.
     *
     * @author bs<<EMAIL>>
     * @return html
     */
    public function about()
    {
        if (! is_null(config('site.aboutUs.url'))) {
            return redirect(config('site.aboutUs.url'), 302);
        }
        $body = config('site.aboutUs.content', '');
        $body = preg_replace('/\@\!\[(.*?)\]\((\d+)\)/i', '![$1]('.config('app.url').'/api/v2/files/$2)', $body);
        $content = htmlspecialchars_decode(\Parsedown::instance()->setMarkupEscaped(true)->text($body));

        return view('about', ['content' => $content]);
    }

    /**
     * 注册协议.
     *
     * @author Foreach<<EMAIL>>
     * @return html
     */
    public function agreement()
    {
        $content = \Parsedown::instance()->setMarkupEscaped(true)->text(config('registerSettings.content', ''));<commit_msg>fix(核心): 修复 TS+ 用户注册协议未使用最新配置 Bug<commit_after><?php

declare(strict_types=1);

/*
 * +----------------------------------------------------------------------+
 * |                          ThinkSNS Plus                               |
 * +----------------------------------------------------------------------+
 * | Copyright (c) 2018 <NAME> Technology Co., Ltd.     |
 * +----------------------------------------------------------------------+
 * | This source file is subject to version 2.0 of the Apache license,    |
 * | that is bundled with this package in the file LICENSE, and is        |
 * | available through the world-wide-web at the following url:           |
 * | http://www.apache.org/licenses/LICENSE-2.0.html                      |
 * +----------------------------------------------------------------------+
 * | Author: S<NAME> <<EMAIL>>                          |
 * | Homepage: www.thinksns.com                                           |
 * +----------------------------------------------------------------------+
 */

namespace Zhiyi\Plus\Http\Controllers\APIs\V2;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Zhiyi\Plus\Utils\Markdown;
use function Zhiyi\Plus\setting;
use Zhiyi\Plus\Models\Conversation;

class SystemController extends Controller
{
    /**
     * create a feedback.
     *
     * @author bs<<EMAIL>>
     * @param  Request $request
     * @return mixed
     */
    public function createFeedback(Request $request, Conversation $feedback, Carbon $datetime)
    {
        $feedback->type = 'feedback';
        $feedback->content = $request->input('content');
        $feedback->user_id = $request->user()->id;
        $feedback->system_mark = $request->input('system_mark', ($datetime->timestamp) * 1000);
        $feedback->save();

        return response()->json([
            'message' => ['反馈成功'],
            'data' => $feedback,
        ])->setStatusCode(201);
    }

    /**
     * about us.
     *
     * @author bs<<EMAIL>>
     * @return html
     */
    public function about()
    {
        if (! is_null(config('site.aboutUs.url'))) {
            return redirect(config('site.aboutUs.url'), 302);
        }
        $body = config('site.aboutUs.content', '');
        $body = preg_replace('/\@\!\[(.*?)\]\((\d+)\)/i', '![$1]('.config('app.url').'/api/v2/files/$2)', $body);
        $content = htmlspecialchars_decode(\Parsedown::instance()->setMarkupEscaped(true)->text($body));

        return view('about', ['content' => $content]);
    }

    /**
     * 注册协议.
     *
     * @author Foreach<<EMAIL>>
     * @return html
     */
    public function agreement(Markdown $markdown)
    {
        $content = setting('user', 'register-setting', [
            'content' => '# 服务条款及隐私政策',
        ])['content'] ?? '# 服务条款及隐私政策';
        $content = $markdown->toHtml($content);
{'fraction_non_alphanumeric': 0.277848678213309, 'fraction_numerical': 0.008386508659981768, 'mean_word_length': 1.427433628318584, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4932760', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1496, 'n_words': 283}