mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-22 20:05:23 +00:00
core: shorten Go referral codes for easier sharing
This commit is contained in:
@@ -2,7 +2,7 @@ const INVITE_COOKIE = "opencode.go.invite"
|
||||
const INVITE_MAX_AGE = 60 * 60 * 24 * 30
|
||||
|
||||
export function normalizeInviteCode(code?: string | null) {
|
||||
return code?.toUpperCase().replace(/[^A-Z0-9]/g, "").slice(0, 16)
|
||||
return code?.toUpperCase().replace(/[^A-Z0-9]/g, "").slice(0, 10)
|
||||
}
|
||||
|
||||
export function inviteCookie(code: string) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
UPDATE `workspace` SET `referral_code` = NULL WHERE CHAR_LENGTH(`referral_code`) > 10;--> statement-breakpoint
|
||||
ALTER TABLE `workspace` MODIFY COLUMN `referral_code` varchar(10);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@ import { fn } from "./util/fn"
|
||||
|
||||
export namespace Referral {
|
||||
export const REWARD_AMOUNT = centsToMicroCents(500)
|
||||
const CODE_LENGTH = 16
|
||||
const CODE_LENGTH = 10
|
||||
|
||||
function normalizeCode(code?: string) {
|
||||
return code?.toUpperCase().replace(/[^A-Z0-9]/g, "").slice(0, CODE_LENGTH)
|
||||
|
||||
@@ -6,7 +6,7 @@ export const WorkspaceTable = mysqlTable(
|
||||
{
|
||||
id: ulid("id").notNull().primaryKey(),
|
||||
slug: varchar("slug", { length: 255 }),
|
||||
referralCode: varchar("referral_code", { length: 16 }),
|
||||
referralCode: varchar("referral_code", { length: 10 }),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
...timestamps,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user