Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4002 prevent user from creating twice the same blocklist item #5213

Merged

Conversation

bosiraphael
Copy link
Contributor

Closes #4002

@bosiraphael bosiraphael linked an issue Apr 29, 2024 that may be closed by this pull request
@bosiraphael bosiraphael requested a review from Weiko April 29, 2024 16:49
@@ -62,7 +62,7 @@ export interface UpdateManyResolverArgs<
Filter = any,
> {
filter: Filter;
data: Data;
data: Data[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data should not be an array here, this is how we use it

{
  "filter": {"id": {"in": ["something", "something-else"]}}, 
  "data": {
    "name": "eae"
  }
}

where data is the shape of what you want to update against all the records that match with the filters


assertMutationNotOnRemoteObject(objectMetadataItem);
assertIsValidUuid(args.data.id);
for (const record of args.data) {
assertIsValidUuid(record.id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already wrong before but we don't want to check the id from data here but from the filter object. In fact, we should reject / not return id in the data type because we don't want to allow update of the ids in an updateMany (nor in an updateOne but for the updateMany won't even work due to unicity constraint)
FYI @charlesBochet @magrinj

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👏 @bosiraphael

@Weiko Weiko merged commit 7c605fc into main Apr 30, 2024
8 of 10 checks passed
@Weiko Weiko deleted the 4002-prevent-user-from-creating-twice-the-same-blocklist-item branch April 30, 2024 12:36
arnavsaxena17 pushed a commit to arnavsaxena17/twenty that referenced this pull request Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent user from creating twice the same blocklist item
2 participants