From d709030580a3b321b6e7a59390cc65fa2414636c Mon Sep 17 00:00:00 2001 From: laozhoubuluo Date: Fri, 1 Mar 2024 00:40:20 +0000 Subject: [PATCH] feat: sent follow request list api and user interface Co-authored-by: naskya --- docs/api-change.md | 1 + locales/en-US.yml | 2 + locales/zh-CN.yml | 2 + locales/zh-TW.yml | 2 + packages/backend/src/server/api/endpoints.ts | 2 + .../api/endpoints/following/requests/sent.ts | 55 ++++++ .../client/src/pages/follow-requests-sent.vue | 160 ++++++++++++++++++ packages/client/src/pages/settings/other.vue | 4 + packages/client/src/router.ts | 5 + packages/firefish-js/src/api.types.ts | 1 + 10 files changed, 234 insertions(+) create mode 100644 packages/backend/src/server/api/endpoints/following/requests/sent.ts create mode 100644 packages/client/src/pages/follow-requests-sent.vue diff --git a/docs/api-change.md b/docs/api-change.md index 599d2c36ce..a948f1635c 100644 --- a/docs/api-change.md +++ b/docs/api-change.md @@ -4,6 +4,7 @@ Breaking changes are indicated by the :warning: icon. ## Unreleased +- Added `following/requests/sent` endpoint for added Sent Following Requests List Feature. - The following endpoints are added: - `reply-mute/create` - `reply-mute/delete` diff --git a/locales/en-US.yml b/locales/en-US.yml index a8d54ed058..0c40a340fb 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -109,6 +109,7 @@ defaultNoteVisibility: "Default visibility" follow: "Follow" followRequest: "Follow Request" followRequests: "Follow requests" +sentFollowRequests: "Sent follow requests" unfollow: "Unfollow" followRequestPending: "Follow request pending" enterEmoji: "Enter an emoji" @@ -534,6 +535,7 @@ existingAccount: "Existing account" regenerate: "Regenerate" fontSize: "Font size" noFollowRequests: "You don't have any pending follow requests" +noSentFollowRequests: "You don't have any sent follow requests" openImageInNewTab: "Open images in new tab" dashboard: "Dashboard" local: "Local" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index e092f5c25f..1aa187e0a9 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -91,6 +91,7 @@ defaultNoteVisibility: "默认可见性" follow: "关注" followRequest: "关注请求" followRequests: "关注请求" +sentFollowRequests: "待回应的关注请求" unfollow: "取消关注" followRequestPending: "关注请求待批准" enterEmoji: "输入表情符号" @@ -470,6 +471,7 @@ existingAccount: "现有的账号" regenerate: "重新生成" fontSize: "字体大小" noFollowRequests: "没有待批准的关注申请" +noSentFollowRequests: "没有待回应的关注请求" openImageInNewTab: "在新标签页中打开图片" dashboard: "管理面板" local: "本地" diff --git a/locales/zh-TW.yml b/locales/zh-TW.yml index 6a02442d23..ae89e38ae8 100644 --- a/locales/zh-TW.yml +++ b/locales/zh-TW.yml @@ -91,6 +91,7 @@ defaultNoteVisibility: "預設可見性" follow: "追隨" followRequest: "追隨請求" followRequests: "追隨請求" +sentFollowRequests: "待回應的追隨請求" unfollow: "取消追隨" followRequestPending: "追隨許可批准中" enterEmoji: "輸入表情符號" @@ -469,6 +470,7 @@ existingAccount: "現有帳戶" regenerate: "再生" fontSize: "字體大小" noFollowRequests: "沒有要求跟隨您的申請" +noSentFollowRequests: "沒有待回應的跟隨申請" openImageInNewTab: "於新分頁中開啟圖片" dashboard: "儀表板" local: "本地" diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index cb0839bd46..8184df5d23 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -144,6 +144,7 @@ import * as ep___following_invalidate from "./endpoints/following/invalidate.js" import * as ep___following_requests_accept from "./endpoints/following/requests/accept.js"; import * as ep___following_requests_cancel from "./endpoints/following/requests/cancel.js"; import * as ep___following_requests_list from "./endpoints/following/requests/list.js"; +import * as ep___following_requests_sent from "./endpoints/following/requests/sent.js"; import * as ep___following_requests_reject from "./endpoints/following/requests/reject.js"; import * as ep___gallery_featured from "./endpoints/gallery/featured.js"; import * as ep___gallery_popular from "./endpoints/gallery/popular.js"; @@ -492,6 +493,7 @@ const eps = [ ["following/requests/accept", ep___following_requests_accept], ["following/requests/cancel", ep___following_requests_cancel], ["following/requests/list", ep___following_requests_list], + ["following/requests/sent", ep___following_requests_sent], ["following/requests/reject", ep___following_requests_reject], ["gallery/featured", ep___gallery_featured], ["gallery/popular", ep___gallery_popular], diff --git a/packages/backend/src/server/api/endpoints/following/requests/sent.ts b/packages/backend/src/server/api/endpoints/following/requests/sent.ts new file mode 100644 index 0000000000..21ba48af28 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/following/requests/sent.ts @@ -0,0 +1,55 @@ +import define from "@/server/api/define.js"; +import { FollowRequests } from "@/models/index.js"; + +export const meta = { + tags: ["following", "users"], + + requireCredential: true, + + kind: "read:following", + + res: { + type: "array", + optional: false, + nullable: false, + items: { + type: "object", + optional: false, + nullable: false, + properties: { + id: { + type: "string", + optional: false, + nullable: false, + format: "id", + }, + follower: { + type: "object", + optional: false, + nullable: false, + ref: "UserLite", + }, + followee: { + type: "object", + optional: false, + nullable: false, + ref: "UserLite", + }, + }, + }, + }, +} as const; + +export const paramDef = { + type: "object", + properties: {}, + required: [], +} as const; + +export default define(meta, paramDef, async (ps, user) => { + const reqs = await FollowRequests.findBy({ + followerId: user.id, + }); + + return await Promise.all(reqs.map((req) => FollowRequests.pack(req))); +}); diff --git a/packages/client/src/pages/follow-requests-sent.vue b/packages/client/src/pages/follow-requests-sent.vue new file mode 100644 index 0000000000..997ed699c1 --- /dev/null +++ b/packages/client/src/pages/follow-requests-sent.vue @@ -0,0 +1,160 @@ + + + + + diff --git a/packages/client/src/pages/settings/other.vue b/packages/client/src/pages/settings/other.vue index 5e84df9ab9..d33027527a 100644 --- a/packages/client/src/pages/settings/other.vue +++ b/packages/client/src/pages/settings/other.vue @@ -4,6 +4,10 @@ i18n.ts.accountInfo }} + {{ + i18n.ts.sentFollowRequests + }} + {{ i18n.ts.registry }} import("./pages/follow-requests.vue")), loginRequired: true, }, + { + path: "/my/follow-requests/sent", + component: page(() => import("./pages/follow-requests-sent.vue")), + loginRequired: true, + }, { path: "/my/lists/:listId", component: page(() => import("./pages/my-lists/list.vue")), diff --git a/packages/firefish-js/src/api.types.ts b/packages/firefish-js/src/api.types.ts index 5cd90dc9e6..919a33af6c 100644 --- a/packages/firefish-js/src/api.types.ts +++ b/packages/firefish-js/src/api.types.ts @@ -399,6 +399,7 @@ export type Endpoints = { "following/requests/accept": { req: { userId: User["id"] }; res: null }; "following/requests/cancel": { req: { userId: User["id"] }; res: User }; "following/requests/list": { req: NoParams; res: FollowRequest[] }; + "following/requests/sent": { req: NoParams; res: FollowRequest[] }; "following/requests/reject": { req: { userId: User["id"] }; res: null }; // gallery