Skip to content
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

Adding GetSiteMetadata #26

Merged
merged 2 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lemmy-js-client",
"description": "A javascript / typescript client for Lemmy",
"version": "0.11.4-rc.10",
"version": "0.11.4-rc.11",
"author": "Dessalines <tyhou13@gmx.com>",
"license": "AGPL-3.0",
"main": "./dist/index.js",
Expand Down
8 changes: 8 additions & 0 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import {
GetPostResponse,
GetPosts,
GetPostsResponse,
GetSiteMetadata,
GetSiteMetadataResponse,
LockPost,
PostResponse,
RemovePost,
Expand Down Expand Up @@ -238,6 +240,12 @@ export class LemmyHttp {
return this.wrapper(HttpType.Put, '/post/save', form);
}

async getSiteMetadata(
form: GetSiteMetadata
): Promise<GetSiteMetadataResponse> {
return this.wrapper(HttpType.Get, '/post/site_metadata', form);
}

async createComment(form: CreateComment): Promise<CommentResponse> {
return this.wrapper(HttpType.Post, '/comment', form);
}
Expand Down
9 changes: 9 additions & 0 deletions src/interfaces/api/post.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SiteMetadata } from '..';
import {
CommunityView,
CommentView,
Expand Down Expand Up @@ -141,3 +142,11 @@ export interface ListPostReports {
export interface ListPostReportsResponse {
posts: PostReportView[];
}

export interface GetSiteMetadata {
url: string;
}

export interface GetSiteMetadataResponse {
metadata: SiteMetadata;
}
8 changes: 8 additions & 0 deletions src/interfaces/others.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export enum UserOperation {
PostJoin,
CommunityJoin,
ChangePassword,
GetSiteMetadata,
}

export enum SortType {
Expand Down Expand Up @@ -106,3 +107,10 @@ export interface WebSocketJsonResponse<ResponseType> {
error?: string;
reconnect?: boolean;
}

export interface SiteMetadata {
title?: string;
description?: string;
image?: string;
html?: string;
}
5 changes: 5 additions & 0 deletions src/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
EditPost,
GetPost,
GetPosts,
GetSiteMetadata,
LockPost,
RemovePost,
SavePost,
Expand Down Expand Up @@ -201,6 +202,10 @@ export class LemmyWebsocket {
return wrapper(UserOperation.SavePost, form);
}

getSiteMetadata(form: GetSiteMetadata) {
return wrapper(UserOperation.GetSiteMetadata, form);
}

banFromCommunity(form: BanFromCommunity) {
return wrapper(UserOperation.BanFromCommunity, form);
}
Expand Down