Skip to content

Commit

Permalink
Merge pull request #335 from TogetherCrew/add-unverifiedTelegramUsern…
Browse files Browse the repository at this point in the history
…ame-support

Add unverifiedTelegramUsername support
  • Loading branch information
Behzad-rabiei authored Apr 4, 2024
2 parents 68f517f + 74906c1 commit 696dee8
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 7 deletions.
12 changes: 12 additions & 0 deletions __tests__/integration/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
// updateBody = {
// email: '[email protected]',
// tcaAt: currentDate,
// unverifiedTelegramUsername: 'alex_jan'
// };
// });
// test('should return 200 and successfully update user if data is ok', async () => {
Expand All @@ -96,6 +97,7 @@
// email: updateBody.email,
// communities: [communityOne._id.toString(), communityTwo._id.toString()],
// tcaAt: currentDate.toISOString(),
// unverifiedTelegramUsername: updateBody.unverifiedTelegramUsername
// });

// const dbUser = await User.findById(userOne._id);
Expand All @@ -121,6 +123,16 @@
// test('should return 400 error if tcaAt is invalid', async () => {
// const updateBody = { tcaAt: 'tcaAt' };

// await insertUsers([userOne]);
// await request(app)
// .patch('/api/v1/users/@me')
// .set('Authorization', `Bearer ${userOneAccessToken}`)
// .send(updateBody)
// .expect(httpStatus.BAD_REQUEST);
// });

// test('should return 400 error if unverifiedTelegramUsername is invalid', async () => {
// const updateBody = { unverifiedTelegramUsername: 100 };
// await insertUsers([userOne]);
// await request(app)
// .patch('/api/v1/users/@me')
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@discordjs/rest": "^1.7.0",
"@notionhq/client": "^2.2.3",
"@sentry/node": "^7.50.0",
"@togethercrew.dev/db": "^3.0.33",
"@togethercrew.dev/db": "^3.0.34",
"@togethercrew.dev/tc-messagebroker": "^0.0.45",
"@types/express-session": "^1.17.7",
"@types/morgan": "^1.9.5",
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/platform.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const connectPlatform = catchAsync(async function (req: ISessionRequest, res: Re
discord.scopes.connectGuild,
permissions,
state,
'',
false,
);
res.redirect(discordUrl);
} else if (platform === 'twitter') {
Expand Down
4 changes: 3 additions & 1 deletion src/docs/schemes.doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ components:
type: string
format: date-time
description: term and condition accepted date

unverifiedTelegramUsername:
type: string
description: unverified telegram username
# ********Community********
Community:
type: object
Expand Down
6 changes: 5 additions & 1 deletion src/docs/user.doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ paths:
patch:
tags:
- User
summary: update user (to add user email)
summary: update user
security:
- bearerAuth: []
requestBody:
Expand All @@ -37,9 +37,13 @@ paths:
type: string
format: date-time
description: term and condition accepted date
unverifiedTelegramUsername:
type: string
description: unverified telegram username
example:
email: [email protected]
tcaAt: 2023-10-31T12:48:55.432Z
unverifiedTelegramUsername: alex_jane

responses:
"200":
Expand Down
4 changes: 4 additions & 0 deletions src/validations/user.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const updateUser = {
.keys({
email: Joi.string().email(),
tcaAt: Joi.date(),
unverifiedTelegramUsername: Joi.string()
.min(5)
.max(32)
.regex(/^[a-zA-Z0-9_]{5,32}$/),
})
.min(1),
};
Expand Down

0 comments on commit 696dee8

Please sign in to comment.