@@ -49,13 +49,12 @@ function UserController() {
49
49
} ;
50
50
51
51
this . updateUserProfile = async ( req , res , next ) => {
52
- let userId = req . query . userId ;
52
+ let walletAddress = req . query . walletAddress ;
53
53
54
- if ( ! userId ) userId = null ;
54
+ if ( ! walletAddress ) walletAddress = null ;
55
55
else {
56
- const userIdCheck = _ . toString ( userId ) ;
57
- if ( _ . isNaN ( userIdCheck ) ) userId = undefined ;
58
- else userId = Number ( userIdCheck ) ;
56
+ const walletAddressCheck = _ . toString ( walletAddress ) ;
57
+ if ( _ . isNaN ( walletAddressCheck ) ) walletAddress = undefined ;
59
58
}
60
59
61
60
const { status, error } = await validateUpdateProfileBody ( req , res , next ) ;
@@ -64,7 +63,7 @@ function UserController() {
64
63
return res . status ( 400 ) . json ( { message : error , error : error } ) ;
65
64
else {
66
65
const updateInfo = req . body ;
67
- await updateUserProfile ( userId , updateInfo )
66
+ await updateUserProfile ( walletAddress , updateInfo )
68
67
. then ( ( data ) =>
69
68
data === "success"
70
69
? res . status ( 200 ) . json ( {
@@ -86,15 +85,14 @@ function UserController() {
86
85
} ;
87
86
88
87
this . upgradePremiumAccount = async ( req , res , next ) => {
89
- let userId = req . body . userId ;
88
+ let walletAddress = req . body . walletAddress ;
90
89
91
- if ( ! userId ) userId = null ;
90
+ if ( ! walletAddress ) walletAddress = null ;
92
91
else {
93
- if ( isNaN ( userId ) ) userId = undefined ;
94
- else userId = Number ( userId ) ;
92
+ if ( isNaN ( walletAddress ) ) walletAddress = undefined ;
95
93
}
96
94
97
- await upgradeUserPremiumAccount ( userId )
95
+ await upgradeUserPremiumAccount ( walletAddress )
98
96
. then ( ( data ) =>
99
97
data === "success"
100
98
? res . status ( 200 ) . json ( {
@@ -115,12 +113,11 @@ function UserController() {
115
113
} ;
116
114
117
115
this . followSharkWallet = async ( req , res , next ) => {
118
- let { userId , sharkId } = req . body ;
116
+ let { walletAddress , sharkId } = req . body ;
119
117
120
- if ( ! userId ) userId = null ;
118
+ if ( ! walletAddress ) walletAddress = null ;
121
119
else {
122
- if ( isNaN ( userId ) ) userId = undefined ;
123
- else userId = Number ( userId ) ;
120
+ if ( isNaN ( walletAddress ) ) walletAddress = undefined ;
124
121
}
125
122
126
123
if ( ! sharkId ) sharkId = null ;
@@ -129,7 +126,7 @@ function UserController() {
129
126
else sharkId = Number ( sharkId ) ;
130
127
}
131
128
132
- await followWalletOfShark ( userId , sharkId )
129
+ await followWalletOfShark ( walletAddress , sharkId )
133
130
. then ( ( data ) => {
134
131
if ( data . message === "success" )
135
132
return res . status ( 200 ) . json ( {
@@ -152,20 +149,19 @@ function UserController() {
152
149
} ;
153
150
154
151
this . unfollowSharkWallet = async ( req , res , next ) => {
155
- let { userId , sharkId } = req . body ;
152
+ let { walletAddress , sharkId } = req . body ;
156
153
157
- if ( ! userId ) userId = null ;
154
+ if ( ! walletAddress ) walletAddress = null ;
158
155
else {
159
- if ( isNaN ( userId ) ) userId = undefined ;
160
- else userId = Number ( userId ) ;
156
+ if ( isNaN ( walletAddress ) ) walletAddress = undefined ;
161
157
}
162
158
163
159
if ( ! sharkId ) sharkId = null ;
164
160
else {
165
161
if ( isNaN ( sharkId ) ) sharkId = undefined ;
166
162
else sharkId = Number ( sharkId ) ;
167
163
}
168
- await unfollowWalletOfShark ( userId , sharkId )
164
+ await unfollowWalletOfShark ( walletAddress , sharkId )
169
165
. then ( ( data ) => {
170
166
if ( data . message === "success" )
171
167
return res . status ( 200 ) . json ( {
@@ -188,15 +184,14 @@ function UserController() {
188
184
} ;
189
185
190
186
this . getSharkFollowed = async ( req , res , next ) => {
191
- let userId = req . query . userId ;
187
+ let walletAddress = req . query . userId ;
192
188
193
- if ( ! userId ) userId = null ;
189
+ if ( ! walletAddress ) walletAddress = null ;
194
190
else {
195
- if ( isNaN ( userId ) ) userId = undefined ;
196
- else userId = Number ( userId ) ;
191
+ if ( isNaN ( walletAddress ) ) walletAddress = undefined ;
197
192
}
198
193
199
- await getListOfSharkFollowed ( userId )
194
+ await getListOfSharkFollowed ( walletAddress )
200
195
. then ( ( data ) => {
201
196
data . message === "success"
202
197
? res . status ( 200 ) . json ( {
@@ -223,15 +218,19 @@ function UserController() {
223
218
} ;
224
219
225
220
this . addNewShark = async ( req , res , next ) => {
226
- let { walletAddress, userId } = req . body ;
221
+ let { walletAddress, sharkWalletAddress } = req . body ;
227
222
228
- if ( ! userId ) userId = null ;
223
+ if ( ! walletAddress ) walletAddress = null ;
229
224
else {
230
- if ( isNaN ( userId ) ) userId = undefined ;
231
- else userId = Number ( userId ) ;
225
+ if ( isNaN ( walletAddress ) ) walletAddress = undefined ;
226
+ }
227
+
228
+ if ( ! sharkWalletAddress ) sharkWalletAddress = null ;
229
+ else {
230
+ if ( isNaN ( sharkWalletAddress ) ) sharkWalletAddress = undefined ;
232
231
}
233
232
234
- await addNewShark ( walletAddress , userId )
233
+ await addNewShark ( walletAddress , sharkWalletAddress )
235
234
. then ( ( data ) => {
236
235
data . isAdded
237
236
? res . status ( 200 ) . json ( {
0 commit comments