mirror of
https://github.com/mito-systems/ranger-app.git
synced 2026-05-07 20:24:17 +00:00
fix
This commit is contained in:
parent
5a589469f5
commit
7c63f358a6
@ -266,18 +266,36 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
|
||||
if (!ensuredUserId) {
|
||||
console.error('Failed to ensure user exists, cannot award points');
|
||||
} else {
|
||||
const pointsResult = await awardPointsForImage(
|
||||
ensuredUserId, // Use the ensured ID, which might be different from pointsUserId
|
||||
userEmail,
|
||||
buffer,
|
||||
ipfsUrl,
|
||||
visionResult.description,
|
||||
visionResult.mainObject
|
||||
);
|
||||
console.log('Points award result:', pointsResult);
|
||||
|
||||
// Check for Sei wallet connection and award tokens
|
||||
// Even if we can't award points, we should still return a successful response
|
||||
// so the user gets some useful feedback about their image
|
||||
return NextResponse.json(responseData);
|
||||
} else {
|
||||
// Award points first - this should always happen regardless of wallet status
|
||||
console.log('Attempting to award points for user:', { ensuredUserId, userEmail });
|
||||
try {
|
||||
const pointsResult = await awardPointsForImage(
|
||||
ensuredUserId, // Use the ensured ID, which might be different from pointsUserId
|
||||
userEmail,
|
||||
buffer,
|
||||
ipfsUrl,
|
||||
visionResult.description,
|
||||
visionResult.mainObject
|
||||
);
|
||||
console.log('Points award result:', pointsResult);
|
||||
|
||||
if (pointsResult.success) {
|
||||
console.log(`Successfully awarded ${pointsResult.points} points to user ${ensuredUserId}`);
|
||||
} else {
|
||||
console.warn(`Failed to award points to user ${ensuredUserId}: ${pointsResult.message}`);
|
||||
}
|
||||
} catch (pointsError) {
|
||||
console.error('Error awarding points:', pointsError);
|
||||
// Even if points award fails, we continue to try token rewards
|
||||
}
|
||||
|
||||
// AFTER points are awarded, try to award tokens if wallet is connected
|
||||
// This is separate so issues with token rewards don't affect points
|
||||
try {
|
||||
// Import dynamically to avoid server-side issues with window object
|
||||
const { awardTokensForSighting } = await import('../../../services/blockchain/tokenRewardService');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user