Detect social milestones when scans arrive
This commit is contained in:
@@ -5,6 +5,7 @@ import { getWwwOrigin } from '@/lib/hosts';
|
||||
import { db } from '@/lib/db';
|
||||
import { hashIP } from '@/lib/hash';
|
||||
import { triggerLifecycleScoring } from '@/lib/revops-server';
|
||||
import { detectSocialMilestones } from '@/lib/social-milestones-server';
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
@@ -260,6 +261,12 @@ async function trackScan(qrId: string, userId: string, request: NextRequest) {
|
||||
},
|
||||
});
|
||||
|
||||
// The customer sees a newly crossed milestone on their next dashboard
|
||||
// visit; no separate cron invocation is required after a real scan.
|
||||
if (isUnique) {
|
||||
await detectSocialMilestones(qrId);
|
||||
}
|
||||
|
||||
const activatedUsers = await db.user.updateMany({
|
||||
where: {
|
||||
id: userId,
|
||||
|
||||
Reference in New Issue
Block a user