feat: full parity pass - suspend enforcement, report modal polish, wechat notify
- Restriction: add is_suspended/get_active_suspend; comment block now covers suspend (小黑屋) in addition to mute, with reason in the deny message - FrontSubmitSave::persist: block post/draft/edit submission for suspended users (reference-theme semantics: 小黑屋 loses all publishing rights) - report.js: close icon switched from fa-times to the SVG sprite ic-close (#icon-close), same as reference theme; textareas gain autoHeight growth (hidden 'other reason' box skips the first measurement) - WeChatNotify: NOTIFY_TYPES now includes report/system so report results and account restriction notices fan out to WeChat template messages; generic title/description fallback for template values - contract tests: +3 tests (suspend enforcement, modal polish, wechat types)
This commit is contained in:
@@ -182,6 +182,28 @@ class Restriction {
|
||||
return $this->is_restricted($user_id, self::TYPE_BAN, self::SCOPE_GLOBAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user is in 小黑屋 (active global suspend).
|
||||
*
|
||||
* 对齐参考主题语义:小黑屋用户失去所有发布权限(发帖、评论等)及大部分操作权限。
|
||||
*/
|
||||
public function is_suspended(int $user_id): bool {
|
||||
return $this->is_restricted($user_id, self::TYPE_SUSPEND, self::SCOPE_GLOBAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active suspend restriction for a user (if any).
|
||||
*/
|
||||
public function get_active_suspend(int $user_id): ?array {
|
||||
$restrictions = $this->get_user_restrictions($user_id, true);
|
||||
foreach ($restrictions as $r) {
|
||||
if ($r['type'] === self::TYPE_SUSPEND && $r['scope'] === self::SCOPE_GLOBAL) {
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active ban restriction for a user (if any).
|
||||
*/
|
||||
@@ -214,13 +236,27 @@ class Restriction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enforce comment mute.
|
||||
* Enforce comment restriction on submission (mute / 小黑屋).
|
||||
*
|
||||
* 禁言(mute,评论域)与小黑屋(suspend,全域)都会拦截评论——
|
||||
* 对齐参考主题:小黑屋用户失去评论等发布权限。
|
||||
*/
|
||||
public function enforce_comment_mute($post_id) {
|
||||
$user_id = get_current_user_id();
|
||||
if ($user_id > 0 && $this->is_restricted($user_id, self::TYPE_MUTE, self::SCOPE_COMMENT)) {
|
||||
if ($user_id <= 0) {
|
||||
return $post_id;
|
||||
}
|
||||
if ($this->is_restricted($user_id, self::TYPE_MUTE, self::SCOPE_COMMENT)) {
|
||||
wp_die('您已被限制评论。', '评论限制', ['response' => 403]);
|
||||
}
|
||||
if ($this->is_suspended($user_id)) {
|
||||
$suspend = $this->get_active_suspend($user_id);
|
||||
$message = '您已被关入小黑屋,暂时无法评论。';
|
||||
if (!empty($suspend['reason'])) {
|
||||
$message .= '原因:' . $suspend['reason'];
|
||||
}
|
||||
wp_die($message, '发布限制', ['response' => 403]);
|
||||
}
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user