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

fix: allow to create empty groups just with group creator. #607

Merged
merged 2 commits into from
Aug 10, 2023

Conversation

mohammeds1992
Copy link
Collaborator

No description provided.

@mohammeds1992 mohammeds1992 linked an issue Aug 6, 2023 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Aug 6, 2023

All looks good.

@@ -22,20 +22,12 @@ export const createGroupRequestValidator = (
throw new Error(`groupDescription cannot be more than 150 characters`);
}

if (members == null) {
Copy link
Member

Choose a reason for hiding this comment

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

We have still have this check to ensure member is empty array rather than null

for (let i = 0; i < members.length; i++) {
if (members[i] && !isValidETHAddress(members[i])) {
throw new Error(`Invalid member address!`);
}
}

if (admins == null) {
Copy link
Member

Choose a reason for hiding this comment

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

We have still have this check to ensure admin is empty array rather than null

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Aman035 I check the create group request type, members or admins cannot be null because of the type. Check below export interface ChatCreateGroupType extends EnvOptionsType {
account?: string | null;
signer?: SignerType | null;
groupName: string;
groupDescription: string;
members: Array;
groupImage: string | null;
admins: Array;
isPublic: boolean;
contractAddressNFT?: string;
numberOfNFTs?: number;
contractAddressERC20?: string;
numberOfERC20?: number;
pgpPrivateKey?: string | null;
meta?: string;
groupType? : string | null,
scheduleAt ?: Date | null;
scheduleEnd?: Date | null;
}

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

File: packages/examples/sdk-frontend-react/src/app/ChatTest/CreateGroupTest.tsx

  1. In the function updateAdmins, the closing brace is missing. It should be added after setAdmins((e.target as HTMLInputElement).value);.

Updated code:

const updateAdmins = (e: React.SyntheticEvent<HTMLElement>) => {
  setAdmins((e.target as HTMLInputElement).value);
};
  1. In the function updateIsPublic, the closing brace is missing. It should be added after setIsPublic((e.target as HTMLInputElement).value);.

Updated code:

const updateIsPublic = (e: React.SyntheticEvent<HTMLElement>) => {
  setIsPublic((e.target as HTMLInputElement).value);
};
  1. In the function updateContractAddressNFT, the closing brace is missing. It should be added after setContractAddressNFT((e.target as HTMLInputElement).value);.

Updated code:

const updateContractAddressNFT = (e: React.SyntheticEvent<HTMLElement>) => {
  setContractAddressNFT((e.target as HTMLInputElement).value);
};
  1. In the function updateNumberOfNFTs, the closing brace is missing. It should be added after setNumberOfNFTs((e.target as HTMLInputElement).value);.

Updated code:

const updateNumberOfNFTs = (e: React.SyntheticEvent<HTMLElement>) => {
  setNumberOfNFTs((e.target as HTMLInputElement).value);
};
  1. In the function updateContractAddressERC20, the closing brace is missing. It should be added after setContractAddressERC20((e.target as HTMLInputElement).value);.

Updated code:

const updateContractAddressERC20 = (e: React.SyntheticEvent<HTMLElement>) => {
  setContractAddressERC20((e.target as HTMLInputElement).value);
};
  1. In the function updateNumberOfERC20, the closing brace is missing. It should be added after setNumberOfERC20((e.target as HTMLInputElement).value);.

Updated code:

const updateNumberOfERC20 = (e: React.SyntheticEvent<HTMLElement>) => {
  setNumberOfERC20((e.target as HTMLInputElement).value);
};
  1. In the function updateMeta, the closing brace is missing. It should be added after setMeta((e.target as HTMLInputElement).value);.

Updated code:

const updateMeta = (e: React.SyntheticEvent<HTMLElement>) => {
  setMeta((e.target as HTMLInputElement).value);
};
  1. In the function updateAccount, the closing brace is missing. It should be added after setAccount((e.target as HTMLInputElement).value);.

Updated code:

const updateAccount = (e: React.SyntheticEvent<HTMLElement>) => {
  setAccount((e.target as HTMLInputElement).value);
};
  1. In the line return ( before the closing brace, the closing parenthesis is missing. It should be added after the closing brace.

Updated code:

return (
  <div>
    <ChatTest />
    <h2>Create Group Test page</h2>
    <Loader show={isLoading} />
    <Section>
      ...
    </Section>
  </div>
);

File: packages/examples/sdk-frontend-react/src/app/ChatTest/UpdateGroupTest.tsx

  1. In the function updateGroupName, the closing brace is missing. It should be added after setGroupName((e.target as HTMLInputElement).value);.

Updated code:

const updateGroupName = (e: React.SyntheticEvent<HTMLElement>) => {
  setGroupName((e.target as HTMLInputElement).value);
};
  1. In the line return ( before the closing brace, the closing parenthesis is missing. It should be added after the closing brace.

Updated code:

return (
  <div>
    <ChatTest />
    <h2>Update Group Test page</h2>
    <Loader show={isLoading} />
    <Section>
      ...
    </Section>
  </div>
);

File: packages/restapi/src/lib/chat/helpers/validator.ts

  1. In the function createGroupRequestValidator, there is a missing opening brace for the if condition if (groupName.length > 50). It should be added after the condition.

Updated code:

if (groupName.length > 50) {
  throw new Error(`groupName cannot be more than 50 characters`);
}
  1. In the function createGroupRequestValidator, there is a missing closing brace for the second if condition if (groupDescription && groupDescription.length > 150). It should be added after the condition.

Updated code:

if (groupDescription && groupDescription.length > 150) {
  throw new Error(`groupDescription cannot be more than 150 characters`);
}
  1. In the function createGroupRequestValidator, there is a missing closing brace for the first if condition if (groupName == null || groupName.length == 0). It should be added after the condition.

Updated code:

if (groupName == null || groupName.length == 0) {
  throw new Error(`groupName cannot be null or empty`);
}
  1. In the line }, admins: Array<string>, account: isCAIP ? walletToPCAIP10(account) : account,, there is a missing closing parenthesis for the walletToPCAIP10(account) function call. It should be added after account.

Updated code:

}, admins: Array<string>, account: isCAIP ? walletToPCAIP10(account) : account),
  1. In the line if (spaceName.length > 50) {, there is a missing closing brace for the if condition. It should be added after the condition.

Updated code:

if (spaceName.length > 50) {
  ...
}
  1. In the line if (spaceDescription && spaceDescription.length > 150) {, there is a missing closing brace for the if condition. It should be added after the condition.

Updated code:

if (spaceDescription && spaceDescription.length > 150) {
  ...
}

@mohammeds1992 mohammeds1992 merged commit 7d14e24 into main Aug 10, 2023
1 check passed
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.

Allow to create empty groups
2 participants