Skip to content

feat: [PBE-1477] - User block feature #1274 #1311

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

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a26dc8e
user block
itsmeadi Mar 18, 2024
d9c9c01
Merge remote-tracking branch 'origin/master' into user_block1
itsmeadi Mar 25, 2024
cedc9f9
add blocked field to query channel response, lint fixes
itsmeadi Mar 27, 2024
911b492
Merge remote-tracking branch 'origin/master' into user_block1
itsmeadi Mar 28, 2024
361cf84
chore: remove unused changes
itsmeadi Apr 9, 2024
8a7a23f
chore: lint
itsmeadi Apr 9, 2024
8df75d4
Merge remote-tracking branch 'origin/master' into user_block1
itsmeadi Apr 29, 2024
1bc4c7c
Merge remote-tracking branch 'origin/master' into user_block1
itsmeadi May 8, 2024
d614d1d
add server side support for block unblock user
itsmeadi May 8, 2024
7991bce
user block, channel hidden configurable
itsmeadi May 20, 2024
dcfcc47
Merge remote-tracking branch 'origin/master' into user_block1
itsmeadi May 20, 2024
613ee6c
rename donthidechannel to keepchannelsvisible
itsmeadi May 23, 2024
533f7f2
lint fix
itsmeadi May 23, 2024
e9eb4c4
Merge remote-tracking branch 'origin/master' into user_block1
itsmeadi May 23, 2024
e14b32b
remove keep_channel_visible flag
itsmeadi May 28, 2024
3dceb0d
rename urls to rest convention
itsmeadi May 30, 2024
1b19148
update get blocked user response to include user object
itsmeadi May 31, 2024
3f91d1b
update get block user response vars
itsmeadi May 31, 2024
4675289
lint
itsmeadi Jun 4, 2024
647497e
Merge remote-tracking branch 'origin/master' into user_block1-tommaso
itsmeadi Jun 4, 2024
ca1dff9
fix naming
itsmeadi Jun 4, 2024
4bc4bc5
fix block user response
itsmeadi Jun 4, 2024
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
20 changes: 20 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@
QuerySegmentTargetsFilter,
SortParam,
GetMessageOptions,
BlockUserAPIResponse,

Check failure on line 182 in src/client.ts

View workflow job for this annotation

GitHub Actions / lint

'"./types"' has no exported member named 'BlockUserAPIResponse'. Did you mean 'BlockUsersAPIResponse'?

Check failure on line 182 in src/client.ts

View workflow job for this annotation

GitHub Actions / test (16)

'"./types"' has no exported member named 'BlockUserAPIResponse'. Did you mean 'BlockUsersAPIResponse'?

Check failure on line 182 in src/client.ts

View workflow job for this annotation

GitHub Actions / test

'"./types"' has no exported member named 'BlockUserAPIResponse'. Did you mean 'BlockUsersAPIResponse'?
GetBlockedUsersAPIResponse,
QueryVotesFilters,
VoteSort,
CreatePollAPIResponse,
Expand All @@ -201,6 +203,7 @@
QueryMessageHistorySort,
QueryMessageHistoryOptions,
QueryMessageHistoryResponse,
BlockUsersAPIResponse,
} from './types';
import { InsightMetrics, postInsights } from './insights';
import { Thread } from './thread';
Expand Down Expand Up @@ -2188,7 +2191,24 @@
...options,
});
}
async blockUser(blockedUserID: string, user_id?: string) {
return await this.post<BlockUsersAPIResponse>(this.baseURL + '/users/block', {
blocked_user_id: blockedUserID,
...(user_id ? { user_id } : {}),
});
}

async getBlockedUsers(user_id?: string) {
return await this.get<GetBlockedUsersAPIResponse>(this.baseURL + '/users/block', {
...(user_id ? { user_id } : {}),
});
}
async unBlockUser(blockedUserID: string, userID?: string) {
return await this.post<APIResponse>(this.baseURL + '/users/unblock', {
blocked_user_id: blockedUserID,
...(userID ? { user_id: userID } : {}),
});
}
/** muteUser - mutes a user
*
* @param {string} targetID
Expand Down
24 changes: 24 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,29 @@ export type MuteUserResponse<StreamChatGenerics extends ExtendableGenerics = Def
own_user?: OwnUserResponse<StreamChatGenerics>;
};

export type BlockUserResponse = APIResponse & {
blocked_by_user_id: string;
blocked_user_id: string;
created_at: string;
};

export type BlockUsersAPIResponse = APIResponse & {
blocked_user: BlockUserResponse[];
};

export type GetBlockedUsersAPIResponse = APIResponse & {
blocks: BlockedUser[];
};
export type BlockedUser = APIResponse & {
blocked_user: UserResponse;
blocked_user_id: string;

timestamp: string;
user: UserResponse;

user_id: string;
};

export type OwnUserBase<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
channel_mutes: ChannelMute<StreamChatGenerics>[];
devices: Device<StreamChatGenerics>[];
Expand Down Expand Up @@ -2040,6 +2063,7 @@ export type ChannelConfigWithInfo<
export type ChannelData<
StreamChatGenerics extends ExtendableGenerics = DefaultGenerics
> = StreamChatGenerics['channelType'] & {
blocked?: boolean;
members?: string[];
name?: string;
};
Expand Down
Loading