-import {
- Login,
- LoginResponse,
- CreatePost,
- EditPost,
- CreateComment,
- DeletePost,
- RemovePost,
- LockPost,
- PostResponse,
- SearchResponse,
- FollowCommunity,
- CommunityResponse,
- GetPostResponse,
- Register,
- Comment,
- EditComment,
- DeleteComment,
- RemoveComment,
- Search,
- CommentResponse,
- GetCommunity,
- CreateCommunity,
- DeleteCommunity,
- RemoveCommunity,
- GetPersonMentions,
- CreateCommentLike,
- CreatePostLike,
- EditPrivateMessage,
- DeletePrivateMessage,
- GetPrivateMessages,
- GetSite,
- GetPost,
- PrivateMessageResponse,
- PrivateMessagesResponse,
- GetPersonMentionsResponse,
- SaveUserSettings,
- SortType,
- ListingType,
- GetSiteResponse,
- SearchType,
- LemmyHttp,
- BanPersonResponse,
- BanPerson,
- BanFromCommunity,
- BanFromCommunityResponse,
- Post,
- CreatePrivateMessage,
- ResolveObjectResponse,
- ResolveObject,
- CreatePostReport,
- ListPostReports,
- PostReportResponse,
- ListPostReportsResponse,
- CreateCommentReport,
- CommentReportResponse,
- ListCommentReports,
- ListCommentReportsResponse,
- DeleteAccount,
- DeleteAccountResponse,
- EditSite,
- CommentSortType,
- GetComments,
- GetCommentsResponse,
- FeaturePost,
- PostFeatureType,
- RegistrationMode,
-} from "lemmy-js-client";
+import { LemmyHttp } from "lemmy-js-client";
+import { CreatePost } from "lemmy-js-client/dist/types/CreatePost";
+import { DeletePost } from "lemmy-js-client/dist/types/DeletePost";
+import { EditPost } from "lemmy-js-client/dist/types/EditPost";
+import { EditSite } from "lemmy-js-client/dist/types/EditSite";
+import { FeaturePost } from "lemmy-js-client/dist/types/FeaturePost";
+import { GetComments } from "lemmy-js-client/dist/types/GetComments";
+import { GetCommentsResponse } from "lemmy-js-client/dist/types/GetCommentsResponse";
+import { GetPost } from "lemmy-js-client/dist/types/GetPost";
+import { GetPostResponse } from "lemmy-js-client/dist/types/GetPostResponse";
+import { LockPost } from "lemmy-js-client/dist/types/LockPost";
+import { Login } from "lemmy-js-client/dist/types/Login";
+import { Post } from "lemmy-js-client/dist/types/Post";
+import { PostResponse } from "lemmy-js-client/dist/types/PostResponse";
+import { RemovePost } from "lemmy-js-client/dist/types/RemovePost";
+import { ResolveObject } from "lemmy-js-client/dist/types/ResolveObject";
+import { ResolveObjectResponse } from "lemmy-js-client/dist/types/ResolveObjectResponse";
+import { Search } from "lemmy-js-client/dist/types/Search";
+import { SearchResponse } from "lemmy-js-client/dist/types/SearchResponse";
+import { Comment } from "lemmy-js-client/dist/types/Comment";
+import { BanPersonResponse } from "lemmy-js-client/dist/types/BanPersonResponse";
+import { BanPerson } from "lemmy-js-client/dist/types/BanPerson";
+import { BanFromCommunityResponse } from "lemmy-js-client/dist/types/BanFromCommunityResponse";
+import { BanFromCommunity } from "lemmy-js-client/dist/types/BanFromCommunity";
+import { CommunityResponse } from "lemmy-js-client/dist/types/CommunityResponse";
+import { FollowCommunity } from "lemmy-js-client/dist/types/FollowCommunity";
+import { CreatePostLike } from "lemmy-js-client/dist/types/CreatePostLike";
+import { CommentResponse } from "lemmy-js-client/dist/types/CommentResponse";
+import { CreateComment } from "lemmy-js-client/dist/types/CreateComment";
+import { EditComment } from "lemmy-js-client/dist/types/EditComment";
+import { DeleteComment } from "lemmy-js-client/dist/types/DeleteComment";
+import { RemoveComment } from "lemmy-js-client/dist/types/RemoveComment";
+import { GetPersonMentionsResponse } from "lemmy-js-client/dist/types/GetPersonMentionsResponse";
+import { GetPersonMentions } from "lemmy-js-client/dist/types/GetPersonMentions";
+import { CreateCommentLike } from "lemmy-js-client/dist/types/CreateCommentLike";
+import { CreateCommunity } from "lemmy-js-client/dist/types/CreateCommunity";
+import { GetCommunity } from "lemmy-js-client/dist/types/GetCommunity";
+import { DeleteCommunity } from "lemmy-js-client/dist/types/DeleteCommunity";
+import { RemoveCommunity } from "lemmy-js-client/dist/types/RemoveCommunity";
+import { PrivateMessageResponse } from "lemmy-js-client/dist/types/PrivateMessageResponse";
+import { CreatePrivateMessage } from "lemmy-js-client/dist/types/CreatePrivateMessage";
+import { EditPrivateMessage } from "lemmy-js-client/dist/types/EditPrivateMessage";
+import { DeletePrivateMessage } from "lemmy-js-client/dist/types/DeletePrivateMessage";
+import { LoginResponse } from "lemmy-js-client/dist/types/LoginResponse";
+import { Register } from "lemmy-js-client/dist/types/Register";
+import { SaveUserSettings } from "lemmy-js-client/dist/types/SaveUserSettings";
+import { DeleteAccount } from "lemmy-js-client/dist/types/DeleteAccount";
+import { GetSiteResponse } from "lemmy-js-client/dist/types/GetSiteResponse";
+import { DeleteAccountResponse } from "lemmy-js-client/dist/types/DeleteAccountResponse";
+import { GetSite } from "lemmy-js-client/dist/types/GetSite";
+import { PrivateMessagesResponse } from "lemmy-js-client/dist/types/PrivateMessagesResponse";
+import { GetPrivateMessages } from "lemmy-js-client/dist/types/GetPrivateMessages";
+import { PostReportResponse } from "lemmy-js-client/dist/types/PostReportResponse";
+import { CreatePostReport } from "lemmy-js-client/dist/types/CreatePostReport";
+import { ListPostReportsResponse } from "lemmy-js-client/dist/types/ListPostReportsResponse";
+import { ListPostReports } from "lemmy-js-client/dist/types/ListPostReports";
+import { CommentReportResponse } from "lemmy-js-client/dist/types/CommentReportResponse";
+import { CreateCommentReport } from "lemmy-js-client/dist/types/CreateCommentReport";
+import { ListCommentReportsResponse } from "lemmy-js-client/dist/types/ListCommentReportsResponse";
+import { ListCommentReports } from "lemmy-js-client/dist/types/ListCommentReports";
+import { GetPersonDetailsResponse } from "lemmy-js-client/dist/types/GetPersonDetailsResponse";
+import { GetPersonDetails } from "lemmy-js-client/dist/types/GetPersonDetails";
export interface API {
client: LemmyHttp;
// Registration applications are now enabled by default, need to disable them
let editSiteForm: EditSite = {
- registration_mode: RegistrationMode.Open,
- federation_debug: true,
+ registration_mode: "Open",
rate_limit_message: 999,
rate_limit_post: 999,
rate_limit_register: 999,
await epsilon.client.editSite(editSiteForm);
// Create the main alpha/beta communities
- await createCommunity(alpha, "main");
- await createCommunity(beta, "main");
+ // Ignore thrown errors of duplicates
+ try {
+ await createCommunity(alpha, "main");
+ await createCommunity(beta, "main");
+ } catch (_) {}
}
export async function createPost(
api: API,
- community_id: number
+ community_id: number,
): Promise<PostResponse> {
let name = randomString(5);
let body = randomString(10);
export async function deletePost(
api: API,
deleted: boolean,
- post: Post
+ post: Post,
): Promise<PostResponse> {
let form: DeletePost = {
post_id: post.id,
export async function removePost(
api: API,
removed: boolean,
- post: Post
+ post: Post,
): Promise<PostResponse> {
let form: RemovePost = {
post_id: post.id,
export async function featurePost(
api: API,
featured: boolean,
- post: Post
+ post: Post,
): Promise<PostResponse> {
let form: FeaturePost = {
post_id: post.id,
featured,
- feature_type: PostFeatureType.Community,
+ feature_type: "Community",
auth: api.auth,
};
return api.client.featurePost(form);
export async function lockPost(
api: API,
locked: boolean,
- post: Post
+ post: Post,
): Promise<PostResponse> {
let form: LockPost = {
post_id: post.id,
export async function resolvePost(
api: API,
- post: Post
+ post: Post,
): Promise<ResolveObjectResponse> {
let form: ResolveObject = {
q: post.ap_id,
export async function searchPostLocal(
api: API,
- post: Post
+ post: Post,
): Promise<SearchResponse> {
let form: Search = {
q: post.name,
- type_: SearchType.Posts,
- sort: SortType.TopAll,
+ type_: "Posts",
+ sort: "TopAll",
auth: api.auth,
};
return api.client.search(form);
export async function getPost(
api: API,
- post_id: number
+ post_id: number,
): Promise<GetPostResponse> {
let form: GetPost = {
id: post_id,
export async function getComments(
api: API,
- post_id: number
+ post_id: number,
): Promise<GetCommentsResponse> {
let form: GetComments = {
post_id: post_id,
- type_: ListingType.All,
- sort: CommentSortType.New,
+ type_: "All",
+ sort: "New",
auth: api.auth,
};
return api.client.getComments(form);
export async function resolveComment(
api: API,
- comment: Comment
+ comment: Comment,
): Promise<ResolveObjectResponse> {
let form: ResolveObject = {
q: comment.ap_id,
}
export async function resolveBetaCommunity(
- api: API
+ api: API,
): Promise<ResolveObjectResponse> {
// Use short-hand search url
let form: ResolveObject = {
export async function resolveCommunity(
api: API,
- q: string
+ q: string,
): Promise<ResolveObjectResponse> {
let form: ResolveObject = {
q,
export async function resolvePerson(
api: API,
- apShortname: string
+ apShortname: string,
): Promise<ResolveObjectResponse> {
let form: ResolveObject = {
q: apShortname,
api: API,
person_id: number,
ban: boolean,
- remove_data: boolean
+ remove_data: boolean,
): Promise<BanPersonResponse> {
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
let form: BanPerson = {
person_id: number,
community_id: number,
remove_data: boolean,
- ban: boolean
+ ban: boolean,
): Promise<BanFromCommunityResponse> {
let form: BanFromCommunity = {
person_id,
export async function followCommunity(
api: API,
follow: boolean,
- community_id: number
+ community_id: number,
): Promise<CommunityResponse> {
let form: FollowCommunity = {
community_id,
export async function likePost(
api: API,
score: number,
- post: Post
+ post: Post,
): Promise<PostResponse> {
let form: CreatePostLike = {
post_id: post.id,
api: API,
post_id: number,
parent_id?: number,
- content = "a jest test comment"
+ content = "a jest test comment",
): Promise<CommentResponse> {
let form: CreateComment = {
content,
export async function editComment(
api: API,
comment_id: number,
- content = "A jest test federated comment update"
+ content = "A jest test federated comment update",
): Promise<CommentResponse> {
let form: EditComment = {
content,
export async function deleteComment(
api: API,
deleted: boolean,
- comment_id: number
+ comment_id: number,
): Promise<CommentResponse> {
let form: DeleteComment = {
comment_id,
export async function removeComment(
api: API,
removed: boolean,
- comment_id: number
+ comment_id: number,
): Promise<CommentResponse> {
let form: RemoveComment = {
comment_id,
}
export async function getMentions(
- api: API
+ api: API,
): Promise<GetPersonMentionsResponse> {
let form: GetPersonMentions = {
- sort: CommentSortType.New,
+ sort: "New",
unread_only: false,
auth: api.auth,
};
export async function likeComment(
api: API,
score: number,
- comment: Comment
+ comment: Comment,
): Promise<CommentResponse> {
let form: CreateCommentLike = {
comment_id: comment.id,
export async function createCommunity(
api: API,
- name_: string = randomString(5)
+ name_: string = randomString(5),
): Promise<CommunityResponse> {
let description = "a sample description";
let form: CreateCommunity = {
export async function getCommunity(
api: API,
- id: number
+ id: number,
): Promise<CommunityResponse> {
let form: GetCommunity = {
id,
export async function deleteCommunity(
api: API,
deleted: boolean,
- community_id: number
+ community_id: number,
): Promise<CommunityResponse> {
let form: DeleteCommunity = {
community_id,
export async function removeCommunity(
api: API,
removed: boolean,
- community_id: number
+ community_id: number,
): Promise<CommunityResponse> {
let form: RemoveCommunity = {
community_id,
export async function createPrivateMessage(
api: API,
- recipient_id: number
+ recipient_id: number,
): Promise<PrivateMessageResponse> {
let content = "A jest test federated private message";
let form: CreatePrivateMessage = {
export async function editPrivateMessage(
api: API,
- private_message_id: number
+ private_message_id: number,
): Promise<PrivateMessageResponse> {
let updatedContent = "A jest test federated private message edited";
let form: EditPrivateMessage = {
export async function deletePrivateMessage(
api: API,
deleted: boolean,
- private_message_id: number
+ private_message_id: number,
): Promise<PrivateMessageResponse> {
let form: DeletePrivateMessage = {
deleted,
export async function registerUser(
api: API,
- username: string = randomString(5)
+ username: string = randomString(5),
): Promise<LoginResponse> {
let form: Register = {
username,
export async function saveUserSettingsBio(api: API): Promise<LoginResponse> {
let form: SaveUserSettings = {
show_nsfw: true,
+ blur_nsfw: false,
+ auto_expand: true,
theme: "darkly",
- default_sort_type: Object.keys(SortType).indexOf(SortType.Active),
- default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
+ default_sort_type: "Active",
+ default_listing_type: "All",
interface_language: "en",
show_avatars: true,
send_notifications_to_email: false,
}
export async function saveUserSettingsFederated(
- api: API
+ api: API,
): Promise<LoginResponse> {
let avatar = "https://image.flaticon.com/icons/png/512/35/35896.png";
let banner = "https://image.flaticon.com/icons/png/512/36/35896.png";
let bio = "a changed bio";
let form: SaveUserSettings = {
show_nsfw: false,
- default_sort_type: Object.keys(SortType).indexOf(SortType.Hot),
- default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
+ blur_nsfw: true,
+ auto_expand: false,
+ default_sort_type: "Hot",
+ default_listing_type: "All",
interface_language: "",
avatar,
banner,
export async function saveUserSettings(
api: API,
- form: SaveUserSettings
+ form: SaveUserSettings,
): Promise<LoginResponse> {
return api.client.saveUserSettings(form);
}
+export async function getPersonDetails(
+ api: API,
+ person_id: number,
+): Promise<GetPersonDetailsResponse> {
+ let form: GetPersonDetails = {
+ auth: api.auth,
+ person_id: person_id,
+ };
+ return api.client.getPersonDetails(form);
+}
export async function deleteUser(api: API): Promise<DeleteAccountResponse> {
let form: DeleteAccount = {
}
export async function listPrivateMessages(
- api: API
+ api: API,
): Promise<PrivateMessagesResponse> {
let form: GetPrivateMessages = {
auth: api.auth,
export async function reportPost(
api: API,
post_id: number,
- reason: string
+ reason: string,
): Promise<PostReportResponse> {
let form: CreatePostReport = {
post_id,
}
export async function listPostReports(
- api: API
+ api: API,
): Promise<ListPostReportsResponse> {
let form: ListPostReports = {
auth: api.auth,
export async function reportComment(
api: API,
comment_id: number,
- reason: string
+ reason: string,
): Promise<CommentReportResponse> {
let form: CreateCommentReport = {
comment_id,
}
export async function listCommentReports(
- api: API
+ api: API,
): Promise<ListCommentReportsResponse> {
let form: ListCommentReports = {
auth: api.auth,