-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add experiment to phone number, sms to welcome users and prepar…
…e for thirdweb v5
- Loading branch information
1 parent
bca3271
commit ac3fb97
Showing
9 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use server' | ||
import 'server-only' | ||
|
||
import { appRouterGetAuthUser } from '@/utils/server/authentication/appRouterGetAuthUser' | ||
import { prismaClient } from '@/utils/server/prismaClient' | ||
import { throwIfRateLimited } from '@/utils/server/ratelimit/throwIfRateLimited' | ||
import { optInUser } from '@/utils/server/sms/actions' | ||
import { withServerActionMiddleware } from '@/utils/server/withServerActionMiddleware' | ||
|
||
export const actionWelcomeSMSAfterPhoneSignUp = withServerActionMiddleware( | ||
'actionWelcomeSMSAfterPhoneSignUp', | ||
_actionWelcomeSMSAfterPhoneSignUp, | ||
) | ||
|
||
async function _actionWelcomeSMSAfterPhoneSignUp() { | ||
const authUser = await appRouterGetAuthUser() | ||
if (!authUser) { | ||
throw new Error('Unauthenticated') | ||
} | ||
|
||
await throwIfRateLimited({ context: 'authenticated' }) | ||
|
||
const user = await prismaClient.user.findFirstOrThrow({ | ||
where: { | ||
id: authUser.userId, | ||
}, | ||
}) | ||
|
||
if (user.hasOptedInToSms && user.phoneNumber) { | ||
await optInUser(user.phoneNumber, user) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters