ba-cafe

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 1d57120e89cc778e98ca217525764c9d6914f98f
parent 337f23f3e7610f06297fd3602314867e703b504d
Author: Sunny <122193933+Sunny-JP@users.noreply.github.com>
Date:   Mon, 26 Jan 2026 13:15:17 +0900

Merge pull request #24 from Sunny-JP/v4-sunny-dev

del notify devices max
Diffstat:
Msrc/app/api/tap/route.ts | 39---------------------------------------
Msrc/app/guide/page.tsx | 14+++++++++++---
Msrc/components/Settings.tsx | 1-
3 files changed, 11 insertions(+), 43 deletions(-)

diff --git a/src/app/api/tap/route.ts b/src/app/api/tap/route.ts @@ -23,10 +23,6 @@ export async function POST(request: Request) { const { data: { user }, error: authError } = await supabase.auth.getUser(); if (authError || !user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); - if (onesignalId) { - await cleanupDevices(user.id, onesignalId); - } - const { data: profile } = await supabase.from('profiles').select('tap_history').eq('id', user.id).single(); const newHistory = tapTime ? [...(profile?.tap_history || []), tapTime] : (profile?.tap_history || []); @@ -52,41 +48,6 @@ export async function POST(request: Request) { } } -async function cleanupDevices(userId: string, currentId: string) { - try { - const res = await fetch(`https://onesignal.com/api/v1/apps/${APP_ID}/users/by/external_id/${userId}`, { - headers: { "Authorization": `Basic ${API_KEY}` } - }); - if (!res.ok) return; - - const data = await res.json(); - const subs = data.subscriptions || (data.identity && data.identity.subscriptions) || []; - - const others = subs.filter((s: any) => - (String(s.type).includes("Push") || String(s.type) === "1") && s.id !== currentId - ); - - others.sort((a: any, b: any) => { - const timeA = Number(a.last_active || a.created_at || 0); - const timeB = Number(b.last_active || b.created_at || 0); - return timeB - timeA; - }); - - const toDelete = others.slice(1); - - if (toDelete.length > 0) { - for (const sub of toDelete) { - await fetch(`https://onesignal.com/api/v1/apps/${APP_ID}/subscriptions/${sub.id}`, { - method: "DELETE", - headers: { "Authorization": `Basic ${API_KEY}` } - }); - } - } - } catch (e) { - console.error("[Cleanup] Error:", e); - } -} - async function scheduleNotification(userId: string, tapTime: string) { const sendAfter = new Date(tapTime); sendAfter.setHours(sendAfter.getHours() + 3); diff --git a/src/app/guide/page.tsx b/src/app/guide/page.tsx @@ -35,15 +35,23 @@ export default function GuidePage() { </h2> <p className="mb-4"> メニュー内の「通知設定」から、生徒さんと触れ合える時刻をプッシュ通知でお知らせします。 - 通知設定は1アカウントにつき2端末まで有効です。3端末以上で設定した場合、通知設定を行ったのが最も古い端末から通知設定が解除されます。<br /> - 4:00/16:00 JSTについては、時刻が固定されている&負荷軽減のため、通知を行いません。 + 4:00/16:00 JSTについては、時刻が固定されている&負荷軽減のため、通知を行いません。<br /> </p> + <div className="bg-blue-500/10 border border-blue-500/50 rounded-lg p-4 text-sm mb-4"> + <p className="font-bold mb-2">ℹ️ お願い</p> + <p> + 通知登録されている端末数が増加すると運営者のお財布にクリティカルが発生します。 + </p> + <p className="mt-1"> + 通知登録は1ユーザーあたり2端末を目安とし、通知が不要な端末は都度登録解除していただくようご協力をお願いいたします。 + </p> + </div> <div className="bg-red-500/10 border border-red-500/50 rounded-lg p-4 text-sm"> <p className="font-bold mb-2">⚠️ 通知設定がうまくいかない場合</p> <p> <strong>AdGuard</strong> や <strong>uBlock Origin</strong> などの広告ブロック(コンテンツブロッカー)機能を使用している場合、通知システムが「トラッキング」と誤認され、許可ダイアログが表示されないことがあります。 </p> - <p className="mt-2"> + <p className="mt-1"> 通知設定を行う際は、<strong>このサイト(ドメイン)を許可リストに追加する</strong>か、<strong>一時的に機能をOFF</strong>にしてからページを再読み込み・通知設定を行ってください。 </p> </div> diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx @@ -79,7 +79,6 @@ const Settings = () => { alert("通知をONにしました!"); } - await new Promise(r => setTimeout(r, 1500)); const currentSubscriptionId = OneSignal.User.PushSubscription.id; await fetch('/api/tap', {