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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ const CreateGroupTest = () => {
setLoading(true);
const librarySigner = await library.getSigner();
// Remove empty string elements

const response = await PushAPI.chat.createGroup({
groupName,
groupDescription,
members: members.split(','),
members: members ? members.split(',') : [],
groupImage,
admins: admins.split(','),
admins: admins ? admins.split(',') : [],
isPublic: isPublic === 'true',
contractAddressNFT,
numberOfNFTs: numberOfNFTs != null ? Number(numberOfNFTs) : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const UpdateGroupTest = () => {
groupName,
groupImage,
groupDescription,
members: members.split(','),
admins: admins.split(','),
members: members ? members.split(',') : [],
admins: admins ? admins.split(',') : [],
account: isCAIP ? walletToPCAIP10(account) : account,
signer: librarySigner,
env,
Expand Down
2 changes: 1 addition & 1 deletion packages/restapi/src/lib/chat/helpers/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const createGroupRequestValidator = (
}

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;
}

throw new Error(`admins cannot be null`);
throw new Error(`admins cannot be null`);
}

for (let i = 0; i < admins.length; i++) {
Expand Down
Loading