Skip to content

Commit

Permalink
Remove managram restrictions for receivers
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Oct 17, 2024
1 parent 436e137 commit 9bf5ae1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 62 deletions.
9 changes: 0 additions & 9 deletions backend/api/src/claim-manalink.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { z } from 'zod'
import { humanish } from 'common/user'
import { canSendMana } from 'common/can-send-mana'
import { APIError, authEndpoint, validate } from './helpers/endpoint'
import { runTxn } from 'shared/txn/run-txn'
Expand Down Expand Up @@ -78,14 +77,6 @@ export const claimmanalink = authEndpoint(async (req, auth) => {
throw new APIError(401, 'Your account was not found')
}

const canReceive = humanish(toUser)
if (!canReceive) {
throw new APIError(
403,
'You must verify your phone number to claim mana.'
)
}

const data = {
fromId: creator_id,
fromType: 'USER',
Expand Down
3 changes: 0 additions & 3 deletions backend/api/src/managram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ export const managram: APIHandler<'managram'> = async (props, auth) => {
if (toUsers.length !== toIds.length) {
throw new APIError(404, 'Some destination users not found.')
}
if (toUsers.some((toUser) => !humanish(toUser))) {
throw new APIError(403, 'All destination users must be verified.')
}
if (
token === 'CASH' &&
toUsers.some((toUser) => !toUser.sweepstakesVerified)
Expand Down
52 changes: 24 additions & 28 deletions backend/shared/src/onboarding-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import {
} from 'common/user-notification-preferences'
import { Notification } from 'common/notification'
import * as crypto from 'crypto'
import {
sendBonusWithInterestingMarketsEmail,
sendUnactivatedNewUserEmail,
} from 'shared/emails'
import { sendBonusWithInterestingMarketsEmail } from 'shared/emails'
import { insertNotificationToSupabase } from 'shared/supabase/notifications'
import { APIError } from 'common/api/utils'
import { getForYouMarkets } from 'shared/weekly-markets-emails'
Expand Down Expand Up @@ -54,31 +51,30 @@ export async function sendOnboardingNotificationsInternal() {
'Non love users created older than 1 day, younger than 1 week:' +
recentUsers.length
)
const verifiedUsers = recentUsers.filter(humanish)

await Promise.all(verifiedUsers.map(sendNextDayManaBonus))
const unactivatedUsers = recentUsers.filter((user) => !user.lastBetTime)
const templateId = 'didnt-bet-new-user-survey'
const unactivatedUsersSentEmailAlready = await pg.map(
`select distinct users.id from users
join sent_emails on users.id = sent_emails.user_id
where users.id = any($1)
and sent_emails.email_template_id = $2`,
[unactivatedUsers.map((user) => user.id), templateId],
(row) => row.id
)

await Promise.all(
unactivatedUsers
.filter((user) => !unactivatedUsersSentEmailAlready.includes(user.id))
.map(async (user) => {
await sendUnactivatedNewUserEmail(user, templateId)
await pg.none(
`insert into sent_emails (user_id, email_template_id) values ($1, $2)`,
[user.id, templateId]
)
})
)
await Promise.all(recentUsers.map(sendNextDayManaBonus))
// const unactivatedUsers = recentUsers.filter((user) => !user.lastBetTime)
// const templateId = 'didnt-bet-new-user-survey'
// const unactivatedUsersSentEmailAlready = await pg.map(
// `select distinct users.id from users
// join sent_emails on users.id = sent_emails.user_id
// where users.id = any($1)
// and sent_emails.email_template_id = $2`,
// [unactivatedUsers.map((user) => user.id), templateId],
// (row) => row.id
// )

// await Promise.all(
// unactivatedUsers
// .filter((user) => !unactivatedUsersSentEmailAlready.includes(user.id))
// .map(async (user) => {
// await sendUnactivatedNewUserEmail(user, templateId)
// await pg.none(
// `insert into sent_emails (user_id, email_template_id) values ($1, $2)`,
// [user.id, templateId]
// )
// })
// )
}

const sendNextDayManaBonus = async (user: User) => {
Expand Down
9 changes: 1 addition & 8 deletions web/components/notifications/notification-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import { SEARCH_TYPE_KEY } from 'web/components/supabase-search'
import { Avatar } from 'web/components/widgets/avatar'
import { useReview } from 'web/hooks/use-review'
import { useUser } from 'web/hooks/use-user'
import { canSetReferrer } from 'web/lib/firebase/users'
import { Button } from '../buttons/button'
import { Modal } from '../layout/modal'
import { Rating, ReviewPanel } from '../reviews/stars'
Expand Down Expand Up @@ -1444,13 +1443,7 @@ function ReferralProgramNotification(props: {
symbol={'💸'}
/>
}
subtitle={
user && canSetReferrer(user) ? (
<span>Did a friend refer you? Tap here to attribute them!</span>
) : (
<span>Tap here to see your referral code.</span>
)
}
subtitle={<span>Tap here to see your referral code.</span>}
>
<span>
Refer friends and get{' '}
Expand Down
15 changes: 1 addition & 14 deletions web/lib/firebase/users.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { Contract } from 'common/contract'
import {
humanish,
MINUTES_ALLOWED_TO_REFER,
PrivateUser,
User,
} from 'common/user'
import { PrivateUser, User } from 'common/user'
import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'
import {
Expand Down Expand Up @@ -79,11 +74,3 @@ export const isContractBlocked = (
blockedUserIds?.includes(contract.creatorId)
)
}

export const canSetReferrer = (user: User) => {
if (user.referredByUserId) return false
if (!humanish(user)) return false
const now = dayjs().utc()
const userCreatedTime = dayjs(user.createdTime)
return now.diff(userCreatedTime, 'minute') < MINUTES_ALLOWED_TO_REFER
}

0 comments on commit 9bf5ae1

Please sign in to comment.