Skip to content

Commit

Permalink
Merge branch 'main' into feat/1046/link-message
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoferlund committed Jun 29, 2023
2 parents 345a286 + 3411178 commit 7c46151
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 23 deletions.
8 changes: 4 additions & 4 deletions packages/api/src/praise/schemas/praise.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ export class Praise {
example: 'for making edits in the welcome text',
type: 'string',
})
@Prop({ required: true, minlength: 5, maxlength: 280 })
@Prop({ required: true, minlength: 5, maxlength: 500 })
@IsString()
@MinLength(5)
@MaxLength(280)
@MaxLength(500)
reasonRaw: string;

@ApiResponseProperty({
example: 'for making edits in the welcome text',
type: 'string',
})
@Prop({ required: true, minlength: 5, maxlength: 280 })
@Prop({ required: true, minlength: 5, maxlength: 500 })
@IsString()
@MinLength(5)
@MaxLength(280)
@MaxLength(500)
reason: string;

@ApiResponseProperty({
Expand Down
8 changes: 4 additions & 4 deletions packages/api/test/praise.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ describe('Praise (E2E)', () => {
expect(rb[0]).toBeProperlySerialized();
});

// test, API should return 400 when praise reason contains more than 280 characters
test('400 when reason is more than 280 characters', async () => {
// test, API should return 400 when praise reason contains more than 500 characters
test('400 when reason is more than 500 characters', async () => {
const giver = await userAccountsSeeder.seedUserAccount();
const receiver = await userAccountsSeeder.seedUserAccount();

Expand Down Expand Up @@ -475,10 +475,10 @@ describe('Praise (E2E)', () => {

expect(response.status).toBe(400);
expect(response.body.message).toContain(
'reason must be shorter than or equal to 280 characters',
'reason must be shorter than or equal to 500 characters',
);
expect(response.body.message).toContain(
'reasonRaw must be shorter than or equal to 280 characters',
'reasonRaw must be shorter than or equal to 500 characters',
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/discord-bot/src/handlers/announce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const announcementHandler: CommandHandler = async (
const response = await apiGet<PeriodPaginatedResponseDto>(
'periods',
{
headers: { host: host },
headers: { host },
}
);
periods = [...response.data.docs];
Expand Down
2 changes: 1 addition & 1 deletion packages/discord-bot/src/handlers/forward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const forwardHandler: CommandHandler = async (

const reason = interaction.options.getString('reason', true);

if (reason.length < 5 || reason.length > 280) {
if (reason.length < 5 || reason.length > 500) {
await ephemeralWarning(interaction, 'INVALID_REASON_LENGTH', host);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/discord-bot/src/handlers/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const leaderboardHandler: CommandHandler = async (
const response = await apiClient.get<PeriodPaginatedResponseDto>(
'periods',
{
headers: { host: host },
headers: { host },
}
);
periods = [...response.data.docs];
Expand Down Expand Up @@ -62,7 +62,7 @@ export const leaderboardHandler: CommandHandler = async (
const response = await apiClient.get<PeriodDetailsDto>(
`periods/${latestClosedPeriod?._id}`,
{
headers: { host: host },
headers: { host },
}
);
await interaction.editReply({
Expand Down
2 changes: 1 addition & 1 deletion packages/discord-bot/src/handlers/praise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const praiseHandler: CommandHandler = async (

const reason = interaction.options.getString('reason', true);

if (reason.length < 5 || reason.length > 280) {
if (reason.length < 5 || reason.length > 500) {
await ephemeralWarning(interaction, 'INVALID_REASON_LENGTH', host);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/discord-bot/src/handlers/whatsup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const whatsupHandler: CommandHandler = async (
const praiseResponse = await apiGet<PraisePaginatedResponseDto>(
'/praise?limit=100&page=1&sortColumn=createdAt&sortType=desc',
{
headers: { host: host },
headers: { host },
}
);

Expand Down
2 changes: 1 addition & 1 deletion packages/discord-bot/src/handlers/whoami.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const whoamiHandler: CommandHandler = async (

const activatedAccounts = await apiClient
.get<UserAccount[]>(`useraccounts?user=${ua.user._id}`, {
headers: { host: host },
headers: { host },
})
.then((res) => res.data);
for (const account of activatedAccounts) {
Expand Down
4 changes: 2 additions & 2 deletions packages/discord-bot/src/handlers/whois.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const whoisHandler: CommandHandler = async (
const response = await apiClient.get<PraisePaginatedResponseDto>(
`/praise?limit=100&page=1&receiver=${userAccount._id}&sortType=desc&sortColumn=score`,
{
headers: { host: host },
headers: { host },
}
);

Expand All @@ -79,7 +79,7 @@ export const whoisHandler: CommandHandler = async (
userAccount.user
? apiClient
.get<UserWithStatsDto>(`/users/${userAccount.user._id}`, {
headers: { host: host },
headers: { host },
})
.then((res) => res.data)
: Promise.resolve(null),
Expand Down
3 changes: 2 additions & 1 deletion packages/discord-bot/src/utils/dmTargets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export const selectTargets = async (

try {
const selectedPeriod = await apiGet<PeriodDetailsDto>(
`/periods/${period}`
`/periods/${period}`,
{ headers: { host } }
).then((res) => res.data);

logger.debug(
Expand Down
2 changes: 1 addition & 1 deletion packages/discord-bot/src/utils/getActivateToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getActivateToken = async (
`/useraccounts/${userAccount._id}`,
ua,
{
headers: { host: host },
headers: { host },
}
)
.then((res) => res.data)
Expand Down
6 changes: 3 additions & 3 deletions packages/discord-bot/src/utils/getUserAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const createUserAccount = async (
CreateUserAccountResponseDto,
CreateUserAccountInputDto
>('/useraccounts', newUserAccount, {
headers: { host: host },
headers: { host },
});
return response.data;
};
Expand All @@ -41,7 +41,7 @@ const updateUserAccount = async (
UpdateUserAccountResponseDto,
UpdateUserAccountInputDto
>(`/useraccounts/${ua._id}`, updatedUserAccount, {
headers: { host: host },
headers: { host },
});
return response.data;
}
Expand All @@ -61,7 +61,7 @@ export const getUserAccount = async (
const data = await apiGet<UserAccount[]>(
`/useraccounts/?accountId=${user.id}`,
{
headers: { host: host },
headers: { host },
}
)
.then((res) => res.data.filter((acc) => acc.platform === 'DISCORD'))
Expand Down
2 changes: 1 addition & 1 deletion packages/discord-bot/src/utils/settingsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const getDefaultSetting = (
case 'FORWARDER_ROLE_WARNING':
return "**❌ You don't have the permission to use this command.**";
case 'INVALID_REASON_LENGTH':
return 'Reason should be between 5 to 280 characters';
return 'Reason should be between 5 to 500 characters';
case 'FORWARD_FORWARD_FAILED':
return 'Forward Failed :(';
case 'PRAISE_FAILED':
Expand Down
Binary file added praise-giveth-io-20230614071552.archive
Binary file not shown.

0 comments on commit 7c46151

Please sign in to comment.