-
Notifications
You must be signed in to change notification settings - Fork 49
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
Conversation
All looks good. |
@@ -22,20 +22,12 @@ export const createGroupRequestValidator = ( | |||
throw new Error(`groupDescription cannot be more than 150 characters`); | |||
} | |||
|
|||
if (members == null) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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;
}
File: packages/examples/sdk-frontend-react/src/app/ChatTest/CreateGroupTest.tsx
Updated code: const updateAdmins = (e: React.SyntheticEvent<HTMLElement>) => {
setAdmins((e.target as HTMLInputElement).value);
};
Updated code: const updateIsPublic = (e: React.SyntheticEvent<HTMLElement>) => {
setIsPublic((e.target as HTMLInputElement).value);
};
Updated code: const updateContractAddressNFT = (e: React.SyntheticEvent<HTMLElement>) => {
setContractAddressNFT((e.target as HTMLInputElement).value);
};
Updated code: const updateNumberOfNFTs = (e: React.SyntheticEvent<HTMLElement>) => {
setNumberOfNFTs((e.target as HTMLInputElement).value);
};
Updated code: const updateContractAddressERC20 = (e: React.SyntheticEvent<HTMLElement>) => {
setContractAddressERC20((e.target as HTMLInputElement).value);
};
Updated code: const updateNumberOfERC20 = (e: React.SyntheticEvent<HTMLElement>) => {
setNumberOfERC20((e.target as HTMLInputElement).value);
};
Updated code: const updateMeta = (e: React.SyntheticEvent<HTMLElement>) => {
setMeta((e.target as HTMLInputElement).value);
};
Updated code: const updateAccount = (e: React.SyntheticEvent<HTMLElement>) => {
setAccount((e.target as HTMLInputElement).value);
};
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
Updated code: const updateGroupName = (e: React.SyntheticEvent<HTMLElement>) => {
setGroupName((e.target as HTMLInputElement).value);
};
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
Updated code: if (groupName.length > 50) {
throw new Error(`groupName cannot be more than 50 characters`);
}
Updated code: if (groupDescription && groupDescription.length > 150) {
throw new Error(`groupDescription cannot be more than 150 characters`);
}
Updated code: if (groupName == null || groupName.length == 0) {
throw new Error(`groupName cannot be null or empty`);
}
Updated code: }, admins: Array<string>, account: isCAIP ? walletToPCAIP10(account) : account),
Updated code: if (spaceName.length > 50) {
...
}
Updated code: if (spaceDescription && spaceDescription.length > 150) {
...
} |
No description provided.