[Admin] Notification channel toggles (web/SMS/push active-deactive)
CI/CD / CI · dotnet build (push) Successful in 50s
CI/CD / Deploy · hamkadr (push) Successful in 1m1s

Add a 'notification channels' card at the top of admin Settings with three master on/off checkboxes: web/in-app (new WebNotificationsEnabled, default true), SMS (existing SmsEnabled), and Web Push (existing PushEnabled). Removed the duplicate enable checkboxes from the SMS and Push sections so each binds once. NotificationService now gates the in-app + live SSE channel on WebNotificationsEnabled; push self-gates on PushEnabled. Migration defaults the new column to true so existing installs keep web notifications on.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-04 15:56:40 +03:30
parent 91c953ff5d
commit 8fad9c1bb6
8 changed files with 1154 additions and 22 deletions
+28 -12
View File
@@ -34,6 +34,32 @@
<div class="alert alert-success">✓ @Model.Saved</div>
}
<form method="post" class="card card-pad">
<h3 style="margin-top:0;">کانال‌های اعلان (فعال / غیرفعال)</h3>
<p class="muted" style="font-size:12px; margin-top:0;">روشن/خاموش‌کردن هر کانال ارسال اعلان به کاربران. کلیدها و تنظیمات هر کانال در بخش‌های پایین‌تر.</p>
<div class="filter-group">
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
<input type="checkbox" name="WebNotificationsEnabled" value="true" style="width:auto;" checked="@Model.WebNotificationsEnabled" />
اعلان‌های وب / درون‌برنامه‌ای (زنگوله + نوتیف زنده) — توصیه‌شده برای ایران
</label>
<p class="muted" style="font-size:12px; margin:4px 0 0;">از طریق سرور خودمان ارسال می‌شود؛ نیازی به سرویس‌های گوگل ندارد و در ایران کار می‌کند.</p>
</div>
<div class="filter-group">
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
<input type="checkbox" name="SmsEnabled" value="true" style="width:auto;" checked="@Model.SmsEnabled" />
پیامک (SMS) — کاوه‌نگار
</label>
<p class="muted" style="font-size:12px; margin:4px 0 0;">برای کد ورود و اعلان‌های مهم. کلید و تمپلیت را در بخش «پیامک ورود» پایین وارد کن.</p>
</div>
<div class="filter-group">
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
<input type="checkbox" name="PushEnabled" value="true" style="width:auto;" checked="@Model.PushEnabled" />
پوش مرورگر (Web Push) — بهترین تلاش
</label>
<p class="muted" style="font-size:12px; margin:4px 0 0;">برای اعلان هنگام بسته‌بودن برنامه؛ ولی از سرویس مرورگر (گوگل) عبور می‌کند که در ایران اغلب فیلتر است.</p>
</div>
<hr style="border:none; border-top:1px solid var(--line); margin:18px 0;" />
<h3 style="margin-top:0;">حالت انتشار</h3>
<div class="filter-group">
<label>نحوه افزودن آگهی‌ها به سایت</label>
@@ -156,12 +182,7 @@
<hr style="border:none; border-top:1px solid var(--line); margin:18px 0;" />
<h3 style="margin-top:0;">پیامک ورود (OTP) — کاوه‌نگار</h3>
<div class="filter-group">
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
<input type="checkbox" name="SmsEnabled" value="true" style="width:auto;" checked="@Model.SmsEnabled" />
ارسال کد ورود با پیامک (در صورت خاموش بودن، کد روی صفحه نمایش داده می‌شود)
</label>
</div>
<p class="muted" style="font-size:12px; margin-top:0;">روشن/خاموش‌کردن این کانال در بخش «کانال‌های اعلان» بالا. (در صورت خاموش بودن، کد ورود روی صفحه نمایش داده می‌شود.)</p>
<div class="filter-group">
<label>کلید API کاوه‌نگار</label>
<input type="password" name="SmsApiKey" value="@Model.SmsApiKey" dir="ltr" />
@@ -182,12 +203,7 @@
<hr style="border:none; border-top:1px solid var(--line); margin:18px 0;" />
<h3 style="margin-top:0;">اعلان‌ها (Web Push / PWA)</h3>
<div class="filter-group">
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
<input type="checkbox" name="PushEnabled" value="true" style="width:auto;" checked="@Model.PushEnabled" />
فعال‌سازی اشتراک اعلان مرورگری
</label>
</div>
<p class="muted" style="font-size:12px; margin-top:0;">روشن/خاموش‌کردن این کانال در بخش «کانال‌های اعلان» بالا. اینجا فقط کلیدهای VAPID را وارد کن.</p>
<div class="filter-group">
<label>VAPID Public Key</label>
<input type="text" name="VapidPublicKey" value="@Model.VapidPublicKey" dir="ltr" />