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:
@@ -11,6 +11,12 @@ class WeChatNotify {
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* 可联动微信模板消息的站内通知类型。
|
||||
* report:举报处理结果;system:禁封/限制/解除等账号限制通知。
|
||||
*/
|
||||
const NOTIFY_TYPES = ['comment_reply', 'system_notice', 'order_paid', 'credits_change', 'report', 'system'];
|
||||
|
||||
public static function get_instance(): self {
|
||||
if (null === self::$instance) self::$instance = new self();
|
||||
return self::$instance;
|
||||
@@ -134,6 +140,14 @@ class WeChatNotify {
|
||||
$url = $data['url'] ?? home_url('/');
|
||||
$values = $data['values'] ?? [];
|
||||
|
||||
// 通用兜底:站内通知未带模板字段时,用标题/内容合成。
|
||||
if (empty($values)) {
|
||||
$values = array_filter([
|
||||
'first' => (string) ($data['title'] ?? ''),
|
||||
'keyword1' => (string) ($data['description'] ?? ''),
|
||||
], static function ($v) { return $v !== ''; });
|
||||
}
|
||||
|
||||
$template_data = [];
|
||||
foreach ($values as $key => $value) {
|
||||
$template_data[$key] = [
|
||||
@@ -172,9 +186,8 @@ class WeChatNotify {
|
||||
$config = $this->get_config();
|
||||
if (empty($config['enabled'])) return;
|
||||
|
||||
// 仅特定类型通知发送微信
|
||||
$allowed_types = ['comment_reply', 'system_notice', 'order_paid', 'credits_change'];
|
||||
if (!in_array($type, $allowed_types, true)) return;
|
||||
// 仅特定类型通知发送微信(含举报处理结果与账号限制通知)
|
||||
if (!in_array($type, self::NOTIFY_TYPES, true)) return;
|
||||
|
||||
$this->send($user_id, $type, $data);
|
||||
}
|
||||
@@ -219,7 +232,7 @@ class WeChatNotify {
|
||||
'has_template' => !empty($config['template_id']),
|
||||
'bound_users' => $bound_count,
|
||||
'app_secret' => !empty($config['app_secret']) ? '***' : '',
|
||||
'allowed_types' => ['comment_reply', 'system_notice', 'order_paid', 'credits_change'],
|
||||
'allowed_types' => self::NOTIFY_TYPES,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -234,6 +247,8 @@ class WeChatNotify {
|
||||
'system_notice' => true,
|
||||
'order_paid' => true,
|
||||
'credits_change' => false,
|
||||
'report' => true,
|
||||
'system' => true,
|
||||
];
|
||||
}
|
||||
return $subs;
|
||||
@@ -243,7 +258,7 @@ class WeChatNotify {
|
||||
* Update notification subscriptions for a user.
|
||||
*/
|
||||
public function update_user_subscriptions(int $user_id, array $subscriptions): bool {
|
||||
$allowed = ['comment_reply', 'system_notice', 'order_paid', 'credits_change'];
|
||||
$allowed = self::NOTIFY_TYPES;
|
||||
$clean = [];
|
||||
foreach ($allowed as $key) {
|
||||
$clean[$key] = !empty($subscriptions[$key]);
|
||||
|
||||
Reference in New Issue
Block a user