diff --git a/package.json b/package.json index 262a81a..ffc11ba 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lemmy-js-client", "description": "A javascript / typescript client for Lemmy", - "version": "0.13.1-rc.1", + "version": "0.13.4-rc.1", "author": "Dessalines ", "license": "AGPL-3.0", "main": "./dist/index.js", diff --git a/src/http.ts b/src/http.ts index 531bd1c..cc934b5 100644 --- a/src/http.ts +++ b/src/http.ts @@ -109,6 +109,8 @@ import { BlockPersonResponse, GetReportCount, GetReportCountResponse, + GetUnreadCount, + GetUnreadCountResponse, } from './interfaces/api/person'; import { VERSION } from './interfaces/others'; @@ -637,6 +639,13 @@ export class LemmyHttp { return this.wrapper(HttpType.Get, '/user/report_count', form); } + /** + * Get your unread counts + */ + async getUnreadCount(form: GetUnreadCount): Promise { + return this.wrapper(HttpType.Get, '/user/unread_count', form); + } + /** * Add an admin to your site. */ diff --git a/src/interfaces/api/person.ts b/src/interfaces/api/person.ts index 5f27730..c093b8c 100644 --- a/src/interfaces/api/person.ts +++ b/src/interfaces/api/person.ts @@ -275,6 +275,16 @@ export interface GetReportCountResponse { post_reports: number; } +export interface GetUnreadCount { + auth: string; +} + +export interface GetUnreadCountResponse { + replies: number; + mentions: number; + private_messages: number; +} + export interface BlockPerson { person_id: number; block: boolean; diff --git a/src/interfaces/others.ts b/src/interfaces/others.ts index 4af1fe6..6539fe4 100644 --- a/src/interfaces/others.ts +++ b/src/interfaces/others.ts @@ -74,6 +74,7 @@ export enum UserOperation { ResolvePostReport, ListPostReports, GetReportCount, + GetUnreadCount, } /** diff --git a/src/websocket.ts b/src/websocket.ts index 829cefe..0e405a7 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -73,6 +73,7 @@ import { ChangePassword, BlockPerson, GetReportCount, + GetUnreadCount, } from './interfaces/api/person'; import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket'; import { UserOperation } from './interfaces/others'; @@ -508,6 +509,12 @@ export class LemmyWebsocket { return wrapper(UserOperation.GetReportCount, form); } + /** + * Get your unread counts + */ + getUnreadCount(form: GetUnreadCount) { + return wrapper(UserOperation.GetUnreadCount, form); + } /** * Delete your account. */