Communities and channels

This commit is contained in:
Aslan 2026-01-07 21:01:01 -05:00
parent 79dbeb6b7a
commit 280158470a
34 changed files with 558 additions and 62 deletions

View file

@ -1,5 +1,14 @@
import { callApi, HTTP } from "../tools";
import { IFetchCommunityRequest, IFetchCommunityResponse } from "./types";
import {
IFetchCommunityRequest,
IFetchCommunityResponse,
IFetchCommunityChannelsRequest,
IFetchCommunityChannelsResponse,
IFetchCommunityRolesRequest,
IFetchCommunityRolesResponse,
IFetchCommunityMembersRequest,
IFetchCommunityMembersResponse,
} from "./types";
const fetchCommunityApi = async (
request: IFetchCommunityRequest,
@ -7,4 +16,27 @@ const fetchCommunityApi = async (
return await callApi(HTTP.GET, `community/${request.id}`);
};
export { fetchCommunityApi };
const fetchCommunityChannelsApi = async (
request: IFetchCommunityChannelsRequest,
): Promise<IFetchCommunityChannelsResponse> => {
return await callApi(HTTP.GET, `community/${request.id}/channels`);
};
const fetchCommunityRolesApi = async (
request: IFetchCommunityRolesRequest,
): Promise<IFetchCommunityRolesResponse> => {
return await callApi(HTTP.GET, `community/${request.id}/roles`);
};
const fetchCommunityMembersApi = async (
request: IFetchCommunityMembersRequest,
): Promise<IFetchCommunityMembersResponse> => {
return await callApi(HTTP.GET, `community/${request.id}/members`);
};
export {
fetchCommunityApi,
fetchCommunityChannelsApi,
fetchCommunityRolesApi,
fetchCommunityMembersApi,
};

View file

@ -12,8 +12,59 @@ interface IFetchCommunityRequest {
interface IFetchCommunityResponse extends IFetchCommunity {}
interface IFetchCommunityChannelsRequest {
id: string;
}
interface IFetchCommunityChannelsResponse {
id: string;
channels: IFetchCommunityChannel[];
}
interface IFetchCommunityChannel {
id: string;
name: string;
}
interface IFetchCommunityRolesRequest {
id: string;
}
interface IFetchCommunityRolesResponse {
id: string;
roles: IFetchCommunityRole[];
}
interface IFetchCommunityRole {
id: string;
name: string;
}
interface IFetchCommunityMembersRequest {
id: string;
}
interface IFetchCommunityMembersResponse {
id: string;
members: IFetchCommunityMember[];
}
interface IFetchCommunityMember {
id: string;
username: string;
}
export {
type IFetchCommunity,
type IFetchCommunityRequest,
type IFetchCommunityResponse,
type IFetchCommunityChannelsRequest,
type IFetchCommunityChannelsResponse,
type IFetchCommunityChannel,
type IFetchCommunityRolesRequest,
type IFetchCommunityRolesResponse,
type IFetchCommunityRole,
type IFetchCommunityMembersRequest,
type IFetchCommunityMembersResponse,
type IFetchCommunityMember,
};