]> Untitled Git - lemmy.git/blobdiff - ui/src/interfaces.ts
Merge branch 'dev' into federation
[lemmy.git] / ui / src / interfaces.ts
index 7020ea492f1c079cdf43689212c6d8e404a645b8..12430836c45d1b0ad9f95f550bdc4a6d1ea2e210 100644 (file)
@@ -38,12 +38,20 @@ export enum UserOperation {
   DeleteAccount,
   PasswordReset,
   PasswordChange,
+  CreatePrivateMessage,
+  EditPrivateMessage,
+  GetPrivateMessages,
+  UserJoin,
+  GetComments,
+  GetSiteConfig,
+  SaveSiteConfig,
 }
 
 export enum CommentSortType {
   Hot,
   Top,
   New,
+  Old,
 }
 
 export enum ListingType {
@@ -52,6 +60,11 @@ export enum ListingType {
   Community,
 }
 
+export enum DataType {
+  Post,
+  Comment,
+}
+
 export enum SortType {
   Hot,
   New,
@@ -81,33 +94,47 @@ export interface User {
   default_listing_type: ListingType;
   lang: string;
   avatar?: string;
+  show_avatars: boolean;
+  unreadCount?: number;
 }
 
 export interface UserView {
   id: number;
+  actor_id: string;
   name: string;
   avatar?: string;
-  fedi_name: string;
+  email?: string;
+  matrix_user_id?: string;
+  bio?: string;
+  local: boolean;
   published: string;
   number_of_posts: number;
   post_score: number;
   number_of_comments: number;
   comment_score: number;
   banned: boolean;
+  show_avatars: boolean;
+  send_notifications_to_email: boolean;
 }
 
 export interface CommunityUser {
   id: number;
   user_id: number;
+  user_actor_id: string;
+  user_local: boolean;
   user_name: string;
   avatar?: string;
   community_id: number;
+  community_actor_id: string;
+  community_local: boolean;
   community_name: string;
   published: string;
 }
 
 export interface Community {
   id: number;
+  actor_id: string;
+  local: boolean;
   name: string;
   title: string;
   description?: string;
@@ -118,6 +145,9 @@ export interface Community {
   nsfw: boolean;
   published: string;
   updated?: string;
+  creator_actor_id: string;
+  creator_local: boolean;
+  last_refreshed_at: string;
   creator_name: string;
   creator_avatar?: string;
   category_name: string;
@@ -139,13 +169,23 @@ export interface Post {
   deleted: boolean;
   locked: boolean;
   stickied: boolean;
+  embed_title?: string;
+  embed_description?: string;
+  embed_html?: string;
+  thumbnail_url?: string;
+  ap_id: string;
+  local: boolean;
   nsfw: boolean;
   banned: boolean;
   banned_from_community: boolean;
   published: string;
   updated?: string;
+  creator_actor_id: string;
+  creator_local: boolean;
   creator_name: string;
   creator_avatar?: string;
+  community_actor_id: string;
+  community_local: boolean;
   community_name: string;
   community_removed: boolean;
   community_deleted: boolean;
@@ -155,15 +195,19 @@ export interface Post {
   upvotes: number;
   downvotes: number;
   hot_rank: number;
+  newest_activity_time: string;
   user_id?: number;
   my_vote?: number;
   subscribed?: boolean;
   read?: boolean;
   saved?: boolean;
+  duplicates?: Array<Post>;
 }
 
 export interface Comment {
   id: number;
+  ap_id: string;
+  local: boolean;
   creator_id: number;
   post_id: number;
   parent_id?: number;
@@ -174,18 +218,28 @@ export interface Comment {
   published: string;
   updated?: string;
   community_id: number;
+  community_actor_id: string;
+  community_local: boolean;
+  community_name: string;
   banned: boolean;
   banned_from_community: boolean;
+  creator_actor_id: string;
+  creator_local: boolean;
   creator_name: string;
   creator_avatar?: string;
   score: number;
   upvotes: number;
   downvotes: number;
+  hot_rank: number;
   user_id?: number;
   my_vote?: number;
+  subscribed?: number;
   saved?: boolean;
   user_mention_id?: number; // For mention type
   recipient_id?: number;
+  recipient_actor_id?: string;
+  recipient_local?: boolean;
+  depth?: number;
 }
 
 export interface Category {
@@ -210,6 +264,21 @@ export interface Site {
   enable_nsfw: boolean;
 }
 
+export interface PrivateMessage {
+  id: number;
+  creator_id: number;
+  recipient_id: number;
+  content: string;
+  deleted: boolean;
+  read: boolean;
+  published: string;
+  updated?: string;
+  creator_name: string;
+  creator_avatar?: string;
+  recipient_name: string;
+  recipient_avatar?: string;
+}
+
 export enum BanType {
   Community,
   Site,
@@ -221,8 +290,11 @@ export interface FollowCommunityForm {
   auth?: string;
 }
 
+export interface GetFollowedCommunitiesForm {
+  auth: string;
+}
+
 export interface GetFollowedCommunitiesResponse {
-  op: string;
   communities: Array<CommunityUser>;
 }
 
@@ -237,7 +309,6 @@ export interface GetUserDetailsForm {
 }
 
 export interface UserDetailsResponse {
-  op: string;
   user: UserView;
   follows: Array<CommunityUser>;
   moderates: Array<CommunityUser>;
@@ -255,7 +326,6 @@ export interface GetRepliesForm {
 }
 
 export interface GetRepliesResponse {
-  op: string;
   replies: Array<Comment>;
 }
 
@@ -268,7 +338,6 @@ export interface GetUserMentionsForm {
 }
 
 export interface GetUserMentionsResponse {
-  op: string;
   mentions: Array<Comment>;
 }
 
@@ -279,7 +348,6 @@ export interface EditUserMentionForm {
 }
 
 export interface UserMentionResponse {
-  op: string;
   mention: Comment;
 }
 
@@ -293,7 +361,6 @@ export interface BanFromCommunityForm {
 }
 
 export interface BanFromCommunityResponse {
-  op: string;
   user: UserView;
   banned: boolean;
 }
@@ -317,7 +384,6 @@ export interface TransferSiteForm {
 }
 
 export interface AddModToCommunityResponse {
-  op: string;
   moderators: Array<CommunityUser>;
 }
 
@@ -329,7 +395,6 @@ export interface GetModlogForm {
 }
 
 export interface GetModlogResponse {
-  op: string;
   removed_posts: Array<ModRemovePost>;
   locked_posts: Array<ModLockPost>;
   stickied_posts: Array<ModStickyPost>;
@@ -470,7 +535,6 @@ export interface RegisterForm {
 }
 
 export interface LoginResponse {
-  op: string;
   jwt: string;
 }
 
@@ -481,6 +545,13 @@ export interface UserSettingsForm {
   default_listing_type: ListingType;
   lang: string;
   avatar?: string;
+  email?: string;
+  matrix_user_id?: string;
+  new_password?: string;
+  new_password_verify?: string;
+  old_password?: string;
+  show_avatars: boolean;
+  send_notifications_to_email: boolean;
   auth: string;
 }
 
@@ -498,15 +569,20 @@ export interface CommunityForm {
   auth?: string;
 }
 
+export interface GetCommunityForm {
+  id?: number;
+  name?: string;
+  auth?: string;
+}
+
 export interface GetCommunityResponse {
-  op: string;
   community: Community;
   moderators: Array<CommunityUser>;
   admins: Array<UserView>;
+  online: number;
 }
 
 export interface CommunityResponse {
-  op: string;
   community: Community;
 }
 
@@ -518,12 +594,10 @@ export interface ListCommunitiesForm {
 }
 
 export interface ListCommunitiesResponse {
-  op: string;
   communities: Array<Community>;
 }
 
 export interface ListCategoriesResponse {
-  op: string;
   categories: Array<Category>;
 }
 
@@ -551,13 +625,18 @@ export interface PostFormParams {
   community?: string;
 }
 
+export interface GetPostForm {
+  id: number;
+  auth?: string;
+}
+
 export interface GetPostResponse {
-  op: string;
   post: Post;
   comments: Array<Comment>;
   community: Community;
   moderators: Array<CommunityUser>;
   admins: Array<UserView>;
+  online: number;
 }
 
 export interface SavePostForm {
@@ -567,7 +646,6 @@ export interface SavePostForm {
 }
 
 export interface PostResponse {
-  op: string;
   post: Post;
 }
 
@@ -591,8 +669,8 @@ export interface SaveCommentForm {
 }
 
 export interface CommentResponse {
-  op: string;
   comment: Comment;
+  recipient_ids: Array<number>;
 }
 
 export interface CommentLikeForm {
@@ -617,21 +695,28 @@ export interface GetPostsForm {
 }
 
 export interface GetPostsResponse {
-  op: string;
   posts: Array<Post>;
 }
 
+export interface GetCommentsForm {
+  type_: string;
+  sort: string;
+  page?: number;
+  limit: number;
+  community_id?: number;
+  auth?: string;
+}
+
+export interface GetCommentsResponse {
+  comments: Array<Comment>;
+}
+
 export interface CreatePostLikeForm {
   post_id: number;
   score: number;
   auth?: string;
 }
 
-export interface CreatePostLikeResponse {
-  op: string;
-  post: Post;
-}
-
 export interface SiteForm {
   name: string;
   description?: string;
@@ -641,8 +726,20 @@ export interface SiteForm {
   auth?: string;
 }
 
+export interface GetSiteConfig {
+  auth?: string;
+}
+
+export interface GetSiteConfigResponse {
+  config_hjson: string;
+}
+
+export interface SiteConfigForm {
+  config_hjson: string;
+  auth?: string;
+}
+
 export interface GetSiteResponse {
-  op: string;
   site: Site;
   admins: Array<UserView>;
   banned: Array<UserView>;
@@ -650,7 +747,6 @@ export interface GetSiteResponse {
 }
 
 export interface SiteResponse {
-  op: string;
   site: Site;
 }
 
@@ -663,7 +759,6 @@ export interface BanUserForm {
 }
 
 export interface BanUserResponse {
-  op: string;
   user: UserView;
   banned: boolean;
 }
@@ -675,7 +770,6 @@ export interface AddAdminForm {
 }
 
 export interface AddAdminResponse {
-  op: string;
   admins: Array<UserView>;
 }
 
@@ -686,10 +780,10 @@ export interface SearchForm {
   sort: string;
   page?: number;
   limit?: number;
+  auth?: string;
 }
 
 export interface SearchResponse {
-  op: string;
   type_: string;
   posts?: Array<Post>;
   comments?: Array<Comment>;
@@ -705,12 +799,127 @@ export interface PasswordResetForm {
   email: string;
 }
 
-export interface PasswordResetResponse {
-  op: string;
-}
+// export interface PasswordResetResponse {
+// }
 
 export interface PasswordChangeForm {
   token: string;
   password: string;
   password_verify: string;
 }
+
+export interface PrivateMessageForm {
+  content: string;
+  recipient_id: number;
+  auth?: string;
+}
+
+export interface PrivateMessageFormParams {
+  recipient_id: number;
+}
+
+export interface EditPrivateMessageForm {
+  edit_id: number;
+  content?: string;
+  deleted?: boolean;
+  read?: boolean;
+  auth?: string;
+}
+
+export interface GetPrivateMessagesForm {
+  unread_only: boolean;
+  page?: number;
+  limit?: number;
+  auth?: string;
+}
+
+export interface PrivateMessagesResponse {
+  messages: Array<PrivateMessage>;
+}
+
+export interface PrivateMessageResponse {
+  message: PrivateMessage;
+}
+
+export interface UserJoinForm {
+  auth: string;
+}
+
+export interface UserJoinResponse {
+  user_id: number;
+}
+
+export type MessageType =
+  | EditPrivateMessageForm
+  | LoginForm
+  | RegisterForm
+  | CommunityForm
+  | FollowCommunityForm
+  | ListCommunitiesForm
+  | GetFollowedCommunitiesForm
+  | PostForm
+  | GetPostForm
+  | GetPostsForm
+  | GetCommunityForm
+  | CommentForm
+  | CommentLikeForm
+  | SaveCommentForm
+  | CreatePostLikeForm
+  | BanFromCommunityForm
+  | AddAdminForm
+  | AddModToCommunityForm
+  | TransferCommunityForm
+  | TransferSiteForm
+  | SaveCommentForm
+  | BanUserForm
+  | AddAdminForm
+  | GetUserDetailsForm
+  | GetRepliesForm
+  | GetUserMentionsForm
+  | EditUserMentionForm
+  | GetModlogForm
+  | SiteForm
+  | SearchForm
+  | UserSettingsForm
+  | DeleteAccountForm
+  | PasswordResetForm
+  | PasswordChangeForm
+  | PrivateMessageForm
+  | EditPrivateMessageForm
+  | GetPrivateMessagesForm
+  | SiteConfigForm;
+
+type ResponseType =
+  | SiteResponse
+  | GetFollowedCommunitiesResponse
+  | ListCommunitiesResponse
+  | GetPostsResponse
+  | PostResponse
+  | GetRepliesResponse
+  | GetUserMentionsResponse
+  | ListCategoriesResponse
+  | CommunityResponse
+  | CommentResponse
+  | UserMentionResponse
+  | LoginResponse
+  | GetModlogResponse
+  | SearchResponse
+  | BanFromCommunityResponse
+  | AddModToCommunityResponse
+  | BanUserResponse
+  | AddAdminResponse
+  | PrivateMessageResponse
+  | PrivateMessagesResponse
+  | GetSiteConfigResponse;
+
+export interface WebSocketResponse {
+  op: UserOperation;
+  data: ResponseType;
+}
+
+export interface WebSocketJsonResponse {
+  op?: string;
+  data?: ResponseType;
+  error?: string;
+  reconnect?: boolean;
+}