import {
- LoginForm,
+ Login,
LoginResponse,
- Post,
- PostForm,
- Comment,
- DeletePostForm,
- RemovePostForm,
- StickyPostForm,
- LockPostForm,
+ CreatePost,
+ EditPost,
+ CreateComment,
+ DeletePost,
+ RemovePost,
+ StickyPost,
+ LockPost,
PostResponse,
SearchResponse,
- FollowCommunityForm,
+ FollowCommunity,
CommunityResponse,
GetFollowedCommunitiesResponse,
GetPostResponse,
- RegisterForm,
- CommentForm,
- DeleteCommentForm,
- RemoveCommentForm,
- SearchForm,
+ Register,
+ Comment,
+ EditComment,
+ DeleteComment,
+ RemoveComment,
+ Search,
CommentResponse,
- GetCommunityForm,
- CommunityForm,
- DeleteCommunityForm,
- RemoveCommunityForm,
- GetUserMentionsForm,
- CommentLikeForm,
- CreatePostLikeForm,
- PrivateMessageForm,
- EditPrivateMessageForm,
- DeletePrivateMessageForm,
- GetFollowedCommunitiesForm,
- GetPrivateMessagesForm,
- GetSiteForm,
- GetPostForm,
+ GetCommunity,
+ CreateCommunity,
+ DeleteCommunity,
+ RemoveCommunity,
+ GetUserMentions,
+ CreateCommentLike,
+ CreatePostLike,
+ EditPrivateMessage,
+ DeletePrivateMessage,
+ GetFollowedCommunities,
+ GetPrivateMessages,
+ GetSite,
+ GetPost,
PrivateMessageResponse,
PrivateMessagesResponse,
GetUserMentionsResponse,
- UserSettingsForm,
+ SaveUserSettings,
SortType,
ListingType,
GetSiteResponse,
SearchType,
LemmyHttp,
BanUserResponse,
- BanUserForm,
- BanFromCommunityForm,
+ BanUser,
+ BanFromCommunity,
BanFromCommunityResponse,
+ Post,
+ CreatePrivateMessage,
} from 'lemmy-js-client';
export interface API {
}
export let alpha: API = {
- client: new LemmyHttp('http://localhost:8541/api/v1'),
+ client: new LemmyHttp('http://localhost:8541/api/v2'),
};
export let beta: API = {
- client: new LemmyHttp('http://localhost:8551/api/v1'),
+ client: new LemmyHttp('http://localhost:8551/api/v2'),
};
export let gamma: API = {
- client: new LemmyHttp('http://localhost:8561/api/v1'),
+ client: new LemmyHttp('http://localhost:8561/api/v2'),
};
export let delta: API = {
- client: new LemmyHttp('http://localhost:8571/api/v1'),
+ client: new LemmyHttp('http://localhost:8571/api/v2'),
};
export let epsilon: API = {
- client: new LemmyHttp('http://localhost:8581/api/v1'),
+ client: new LemmyHttp('http://localhost:8581/api/v2'),
};
export async function setupLogins() {
- let formAlpha: LoginForm = {
+ let formAlpha: Login = {
username_or_email: 'lemmy_alpha',
password: 'lemmy',
};
let name = randomString(5);
let body = randomString(10);
let url = 'https://google.com/';
- let form: PostForm = {
+ let form: CreatePost = {
name,
url,
body,
return api.client.createPost(form);
}
-export async function updatePost(api: API, post: Post): Promise<PostResponse> {
+export async function editPost(api: API, post: Post): Promise<PostResponse> {
let name = 'A jest test federated post, updated';
- let form: PostForm = {
+ let form: EditPost = {
name,
edit_id: post.id,
auth: api.auth,
deleted: boolean,
post: Post
): Promise<PostResponse> {
- let form: DeletePostForm = {
+ let form: DeletePost = {
edit_id: post.id,
deleted: deleted,
auth: api.auth,
removed: boolean,
post: Post
): Promise<PostResponse> {
- let form: RemovePostForm = {
+ let form: RemovePost = {
edit_id: post.id,
removed,
auth: api.auth,
stickied: boolean,
post: Post
): Promise<PostResponse> {
- let form: StickyPostForm = {
+ let form: StickyPost = {
edit_id: post.id,
stickied,
auth: api.auth,
locked: boolean,
post: Post
): Promise<PostResponse> {
- let form: LockPostForm = {
+ let form: LockPost = {
edit_id: post.id,
locked,
auth: api.auth,
api: API,
post: Post
): Promise<SearchResponse> {
- let form: SearchForm = {
+ let form: Search = {
q: post.ap_id,
type_: SearchType.Posts,
sort: SortType.TopAll,
api: API,
post: Post
): Promise<SearchResponse> {
- let form: SearchForm = {
+ let form: Search = {
q: post.name,
type_: SearchType.Posts,
sort: SortType.TopAll,
api: API,
post_id: number
): Promise<GetPostResponse> {
- let form: GetPostForm = {
+ let form: GetPost = {
id: post_id,
};
return api.client.getPost(form);
api: API,
comment: Comment
): Promise<SearchResponse> {
- let form: SearchForm = {
+ let form: Search = {
q: comment.ap_id,
type_: SearchType.Comments,
sort: SortType.TopAll,
): Promise<SearchResponse> {
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
// Use short-hand search url
- let form: SearchForm = {
+ let form: Search = {
q: '!main@lemmy-beta:8551',
type_: SearchType.Communities,
sort: SortType.TopAll,
export async function searchForCommunity(
api: API,
- q: string,
+ q: string
): Promise<SearchResponse> {
// Use short-hand search url
- let form: SearchForm = {
+ let form: Search = {
q,
type_: SearchType.Communities,
sort: SortType.TopAll,
): Promise<SearchResponse> {
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
// Use short-hand search url
- let form: SearchForm = {
+ let form: Search = {
q: apShortname,
type_: SearchType.Users,
sort: SortType.TopAll,
export async function banUserFromSite(
api: API,
user_id: number,
- ban: boolean,
+ ban: boolean
): Promise<BanUserResponse> {
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
// Use short-hand search url
- let form: BanUserForm = {
+ let form: BanUser = {
user_id,
ban,
+ remove_data: false,
auth: api.auth,
};
return api.client.banUser(form);
api: API,
user_id: number,
community_id: number,
- ban: boolean,
+ ban: boolean
): Promise<BanFromCommunityResponse> {
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
// Use short-hand search url
- let form: BanFromCommunityForm = {
+ let form: BanFromCommunity = {
user_id,
community_id,
+ remove_data: false,
ban,
auth: api.auth,
};
follow: boolean,
community_id: number
): Promise<CommunityResponse> {
- let form: FollowCommunityForm = {
+ let form: FollowCommunity = {
community_id,
follow,
auth: api.auth,
export async function checkFollowedCommunities(
api: API
): Promise<GetFollowedCommunitiesResponse> {
- let form: GetFollowedCommunitiesForm = {
+ let form: GetFollowedCommunities = {
auth: api.auth,
};
return api.client.getFollowedCommunities(form);
score: number,
post: Post
): Promise<PostResponse> {
- let form: CreatePostLikeForm = {
+ let form: CreatePostLike = {
post_id: post.id,
score: score,
auth: api.auth,
parent_id?: number,
content = 'a jest test comment'
): Promise<CommentResponse> {
- let form: CommentForm = {
+ let form: CreateComment = {
content,
post_id,
parent_id,
return api.client.createComment(form);
}
-export async function updateComment(
+export async function editComment(
api: API,
edit_id: number,
content = 'A jest test federated comment update'
): Promise<CommentResponse> {
- let form: CommentForm = {
+ let form: EditComment = {
content,
edit_id,
auth: api.auth,
deleted: boolean,
edit_id: number
): Promise<CommentResponse> {
- let form: DeleteCommentForm = {
+ let form: DeleteComment = {
edit_id,
deleted,
auth: api.auth,
removed: boolean,
edit_id: number
): Promise<CommentResponse> {
- let form: RemoveCommentForm = {
+ let form: RemoveComment = {
edit_id,
removed,
auth: api.auth,
}
export async function getMentions(api: API): Promise<GetUserMentionsResponse> {
- let form: GetUserMentionsForm = {
+ let form: GetUserMentions = {
sort: SortType.New,
unread_only: false,
auth: api.auth,
score: number,
comment: Comment
): Promise<CommentResponse> {
- let form: CommentLikeForm = {
+ let form: CreateCommentLike = {
comment_id: comment.id,
score,
auth: api.auth,
let description = 'a sample description';
let icon = 'https://image.flaticon.com/icons/png/512/35/35896.png';
let banner = 'https://image.flaticon.com/icons/png/512/35/35896.png';
- let form: CommunityForm = {
+ let form: CreateCommunity = {
name: name_,
title: name_,
description,
export async function getCommunity(
api: API,
- id: number,
+ id: number
): Promise<CommunityResponse> {
- let form: GetCommunityForm = {
+ let form: GetCommunity = {
id,
};
return api.client.getCommunity(form);
deleted: boolean,
edit_id: number
): Promise<CommunityResponse> {
- let form: DeleteCommunityForm = {
+ let form: DeleteCommunity = {
edit_id,
deleted,
auth: api.auth,
removed: boolean,
edit_id: number
): Promise<CommunityResponse> {
- let form: RemoveCommunityForm = {
+ let form: RemoveCommunity = {
edit_id,
removed,
auth: api.auth,
recipient_id: number
): Promise<PrivateMessageResponse> {
let content = 'A jest test federated private message';
- let form: PrivateMessageForm = {
+ let form: CreatePrivateMessage = {
content,
recipient_id,
auth: api.auth,
return api.client.createPrivateMessage(form);
}
-export async function updatePrivateMessage(
+export async function editPrivateMessage(
api: API,
edit_id: number
): Promise<PrivateMessageResponse> {
let updatedContent = 'A jest test federated private message edited';
- let form: EditPrivateMessageForm = {
+ let form: EditPrivateMessage = {
content: updatedContent,
edit_id,
auth: api.auth,
deleted: boolean,
edit_id: number
): Promise<PrivateMessageResponse> {
- let form: DeletePrivateMessageForm = {
+ let form: DeletePrivateMessage = {
deleted,
edit_id,
auth: api.auth,
api: API,
username: string = randomString(5)
): Promise<LoginResponse> {
- let form: RegisterForm = {
+ let form: Register = {
username,
password: 'test',
password_verify: 'test',
api: API,
auth: string
): Promise<LoginResponse> {
- let form: UserSettingsForm = {
+ let form: SaveUserSettings = {
show_nsfw: true,
theme: 'darkly',
- default_sort_type: Object.keys(SortType).indexOf(SortType.Active),
- default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
+ default_sort_type: SortType.Active,
+ default_listing_type: ListingType.All,
lang: 'en',
show_avatars: true,
send_notifications_to_email: false,
export async function saveUserSettings(
api: API,
- form: UserSettingsForm
+ form: SaveUserSettings
): Promise<LoginResponse> {
return api.client.saveUserSettings(form);
}
api: API,
auth: string
): Promise<GetSiteResponse> {
- let form: GetSiteForm = {
+ let form: GetSite = {
auth,
};
return api.client.getSite(form);
export async function listPrivateMessages(
api: API
): Promise<PrivateMessagesResponse> {
- let form: GetPrivateMessagesForm = {
+ let form: GetPrivateMessages = {
auth: api.auth,
unread_only: false,
limit: 999,
// Unfollow all remote communities
let followed = await checkFollowedCommunities(api);
let remoteFollowed = followed.communities.filter(
- c => c.community_local == false
+ c => c.community.local == false
);
for (let cu of remoteFollowed) {
- await followCommunity(api, false, cu.community_id);
+ await followCommunity(api, false, cu.community.id);
}
let followed2 = await checkFollowedCommunities(api);
return followed2;
// Cache it
let search = await searchForBetaCommunity(api);
- let com = search.communities.filter(c => c.local == false);
- if (com[0]) {
- let follow = await followCommunity(api, true, com[0].id);
+ let com = search.communities.find(c => c.community.local == false);
+ if (com) {
+ let follow = await followCommunity(api, true, com.community.id);
return follow;
}
}
export function delay(millis: number = 500) {
- return new Promise((resolve, _reject) => {
- setTimeout(_ => resolve(), millis);
- });
+ return new Promise(resolve => setTimeout(resolve, millis));
}
export function longDelay() {