[TM-3027] start up endpoint to send invitation to join organization u…#585
[TM-3027] start up endpoint to send invitation to join organization u…#585cesarLima1 wants to merge 1 commit intorelease/youthful-yttrofluoritefrom
Conversation
9c8a8ea to
2b096ae
Compare
| ) { | ||
| if (model !== "organisations") { | ||
| throw new BadRequestException("Invites are only supported for organisations"); | ||
| } |
There was a problem hiding this comment.
This should be enforced by the DTO - a new DTO should be created that only accepts orgs on this endpoint.
|
|
||
| const document = buildJsonApi(OrganisationInviteDto); | ||
| document.addData(invite.uuid, new OrganisationInviteDto(invite)); | ||
| return document; |
There was a problem hiding this comment.
🎨 you can streamline this a little and just return the result of document.addData()
| attributes: ["id"] | ||
| }); | ||
| if (existingUser != null) { | ||
| throw new UnprocessableEntityException("User is already a part of this programme"); |
There was a problem hiding this comment.
This error message is misleading - all you've determined here is that the user already exists.
| import { User } from "./user.entity"; | ||
|
|
||
| @Table({ tableName: "v2_organisation_invites", underscored: true }) | ||
| export class OrganisationInvite extends Model<OrganisationInvite> { |
There was a problem hiding this comment.
In the last couple of months, we've been transitioning to using Model<InferAttributes<OrganisationInvite>, InferCreationAttributes<OrganisationInvite>> in place of this simpler form. It makes the semantics around creation a bit better typed. There are lots of examples in the codebase - please update this to match.
https://gfw.atlassian.net/browse/TM-3027