@@ -2,11 +2,6 @@ import { DeviceOS } from "@prisma/client";
22import type { Request , Response } from "express" ;
33import { z } from "zod" ;
44import { prisma } from "@/utils/prisma" ;
5- import { namestoneService } from "../../../../utils/namestone" ;
6- import {
7- validateOnChainName ,
8- validateUsernameUniqueness ,
9- } from "../../profiles/handlers/validate-profile" ;
105
116export const createUserRequestBodySchema = z . object ( {
127 device : z . object ( {
@@ -19,12 +14,16 @@ export const createUserRequestBodySchema = z.object({
1914 xmtpId : z . string ( ) ,
2015 xmtpInstallationId : z . string ( ) . optional ( ) , // TO DO remove optional once all users have fully migrated to newer version of app
2116 } ) ,
22- profile : z . object ( {
23- name : z . string ( ) . min ( 1 ) . optional ( ) ,
24- username : z . string ( ) . min ( 1 ) . optional ( ) ,
25- description : z . string ( ) . nullable ( ) . optional ( ) ,
26- avatar : z . string ( ) . url ( ) . nullable ( ) . optional ( ) ,
27- } ) ,
17+ // Profile data no longer accepted as profiles have been removed
18+ // Keeping for backwards compatibility but will be ignored
19+ profile : z
20+ . object ( {
21+ name : z . string ( ) . min ( 1 ) . optional ( ) ,
22+ username : z . string ( ) . min ( 1 ) . optional ( ) ,
23+ description : z . string ( ) . nullable ( ) . optional ( ) ,
24+ avatar : z . string ( ) . url ( ) . nullable ( ) . optional ( ) ,
25+ } )
26+ . optional ( ) ,
2827} ) ;
2928
3029export type InitRequestBody = z . infer < typeof createUserRequestBodySchema > ;
@@ -40,13 +39,7 @@ export type InitResponse = {
4039 identityAddress : string | null ;
4140 xmtpId : string | null ;
4241 } ;
43- profile : {
44- id : string ;
45- name : string | null ;
46- username : string | null ;
47- description : string | null ;
48- avatar : string | null ;
49- } ;
42+ profile : null ; // Profiles have been removed, returning null for backwards compatibility
5043} ;
5144
5245export async function init (
@@ -70,28 +63,7 @@ export async function init(
7063 throw parseError ;
7164 }
7265
73- // Validate username uniqueness only if username is provided
74- if ( body . profile . username ?. trim ( ) ) {
75- const uniquenessResult = await validateUsernameUniqueness (
76- body . profile . username ,
77- ) ;
78- if ( ! uniquenessResult . success ) {
79- res . status ( 400 ) . json ( uniquenessResult ) ;
80- return ;
81- }
82- }
83-
84- // If name contains a dot, validate on-chain name ownership
85- if ( body . profile . name && body . profile . name . includes ( "." ) ) {
86- const onChainResult = await validateOnChainName ( {
87- name : body . profile . name ,
88- xmtpId : body . identity . xmtpId ,
89- } ) ;
90- if ( ! onChainResult . success ) {
91- res . status ( 400 ) . json ( onChainResult ) ;
92- return ;
93- }
94- }
66+ // Profile validation removed as profiles are no longer supported
9567
9668 // Execute all database operations in a transaction to ensure atomicity
9769 const { device, deviceIdentity } = await prisma . $transaction ( async ( tx ) => {
@@ -108,22 +80,11 @@ export async function init(
10880 } ,
10981 } ) ;
11082
111- // Create device identity
83+ // Create device identity without profile (profiles have been removed)
11284 const deviceIdentity = await tx . deviceIdentity . create ( {
11385 data : {
11486 xmtpId : body . identity . xmtpId ,
11587 identityAddress : body . identity . identityAddress ,
116- profile : {
117- create : {
118- name : body . profile . name || null ,
119- username : body . profile . username || null ,
120- description : body . profile . description ,
121- avatar : body . profile . avatar ,
122- } ,
123- } ,
124- } ,
125- include : {
126- profile : true ,
12788 } ,
12889 } ) ;
12990
@@ -139,10 +100,6 @@ export async function init(
139100 return { device, deviceIdentity } ;
140101 } ) ;
141102
142- if ( ! deviceIdentity . profile ) {
143- throw new Error ( "Profile was not created successfully" ) ;
144- }
145-
146103 const returnedUser : InitResponse = {
147104 device : {
148105 id : device . id ,
@@ -154,46 +111,10 @@ export async function init(
154111 identityAddress : deviceIdentity . identityAddress ,
155112 xmtpId : deviceIdentity . xmtpId ,
156113 } ,
157- profile : {
158- id : deviceIdentity . profile . id ,
159- name : deviceIdentity . profile . name ,
160- username : deviceIdentity . profile . username ,
161- description : deviceIdentity . profile . description ,
162- avatar : deviceIdentity . profile . avatar ,
163- } ,
114+ profile : null , // Profiles have been removed
164115 } ;
165116
166- // Register the username with Namestone only if both username and identityAddress are available
167- if ( deviceIdentity . identityAddress && deviceIdentity . profile . username ) {
168- // Don't await to avoid blocking the user creation response
169- namestoneService
170- . setName ( {
171- username : deviceIdentity . profile . username ,
172- address : deviceIdentity . identityAddress ,
173- textRecords : {
174- ...( deviceIdentity . profile . name && {
175- "display.name" : deviceIdentity . profile . name ,
176- } ) ,
177- ...( deviceIdentity . profile . description && {
178- description : deviceIdentity . profile . description ,
179- } ) ,
180- ...( deviceIdentity . profile . avatar && {
181- avatar : deviceIdentity . profile . avatar ,
182- } ) ,
183- } ,
184- } )
185- . catch ( ( namestoneError : unknown ) => {
186- // Log error but don't fail user creation
187- req . log . error (
188- {
189- error : namestoneError ,
190- username : deviceIdentity . profile ?. username ,
191- address : deviceIdentity . identityAddress ,
192- } ,
193- "Failed to register username with Namestone during user creation" ,
194- ) ;
195- } ) ;
196- }
117+ // Namestone registration removed as profiles are no longer supported
197118
198119 res . status ( 201 ) . json ( returnedUser ) ;
199120 } catch ( error ) {
0 commit comments