From 6a66010294147412cca3820b770d24d21c66b2b6 Mon Sep 17 00:00:00 2001 From: Natty Date: Sun, 7 Jan 2024 02:42:33 +0100 Subject: [PATCH] Removed user groups --- packages/backend/src/db/postgre.ts | 6 - packages/backend/src/misc/api-permissions.ts | 2 - .../backend/src/misc/check-hit-antenna.ts | 14 +-- packages/backend/src/misc/schema.ts | 2 - .../backend/src/models/entities/antenna.ts | 32 +----- .../src/models/entities/notification.ts | 35 ++---- .../models/entities/user-group-invitation.ts | 49 -------- .../src/models/entities/user-group-joining.ts | 49 -------- .../backend/src/models/entities/user-group.ts | 53 --------- .../src/models/entities/user-profile.ts | 2 +- packages/backend/src/models/index.ts | 6 - .../src/models/repositories/antenna.ts | 6 +- .../src/models/repositories/notification.ts | 9 +- .../repositories/user-group-invitation.ts | 23 ---- .../src/models/repositories/user-group.ts | 23 ---- packages/backend/src/models/schema/antenna.ts | 8 +- .../backend/src/models/schema/user-group.ts | 40 ------- packages/backend/src/server/api/endpoints.ts | 26 ----- .../server/api/endpoints/antennas/create.ts | 29 +---- .../server/api/endpoints/antennas/update.ts | 25 +--- .../api/endpoints/i/user-group-invites.ts | 60 ---------- .../api/endpoints/users/groups/create.ts | 49 -------- .../api/endpoints/users/groups/delete.ts | 42 ------- .../users/groups/invitations/accept.ts | 56 --------- .../users/groups/invitations/reject.ts | 47 -------- .../api/endpoints/users/groups/invite.ts | 108 ------------------ .../api/endpoints/users/groups/joined.ts | 48 -------- .../api/endpoints/users/groups/leave.ts | 53 --------- .../api/endpoints/users/groups/owned.ts | 38 ------ .../server/api/endpoints/users/groups/pull.ts | 73 ------------ .../server/api/endpoints/users/groups/show.ts | 58 ---------- .../api/endpoints/users/groups/transfer.ts | 85 -------------- .../api/endpoints/users/groups/update.ts | 55 --------- packages/backend/src/types.ts | 1 - 34 files changed, 27 insertions(+), 1185 deletions(-) delete mode 100644 packages/backend/src/models/entities/user-group-invitation.ts delete mode 100644 packages/backend/src/models/entities/user-group-joining.ts delete mode 100644 packages/backend/src/models/entities/user-group.ts delete mode 100644 packages/backend/src/models/repositories/user-group-invitation.ts delete mode 100644 packages/backend/src/models/repositories/user-group.ts delete mode 100644 packages/backend/src/models/schema/user-group.ts delete mode 100644 packages/backend/src/server/api/endpoints/i/user-group-invites.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/create.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/delete.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/invite.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/joined.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/leave.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/owned.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/pull.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/show.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/transfer.ts delete mode 100644 packages/backend/src/server/api/endpoints/users/groups/update.ts diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index c673d8a814..32e4a4f8c6 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -26,9 +26,6 @@ import {SwSubscription} from "@/models/entities/sw-subscription.js"; import {Blocking} from "@/models/entities/blocking.js"; import {UserList} from "@/models/entities/user-list.js"; import {UserListJoining} from "@/models/entities/user-list-joining.js"; -import {UserGroup} from "@/models/entities/user-group.js"; -import {UserGroupJoining} from "@/models/entities/user-group-joining.js"; -import {UserGroupInvitation} from "@/models/entities/user-group-invitation.js"; import {Hashtag} from "@/models/entities/hashtag.js"; import {NoteFavorite} from "@/models/entities/note-favorite.js"; import {AbuseUserReport} from "@/models/entities/abuse-user-report.js"; @@ -123,9 +120,6 @@ export const entities = [ UserPublickey, UserList, UserListJoining, - UserGroup, - UserGroupJoining, - UserGroupInvitation, UserNotePining, UserSecurityKey, UsedUsername, diff --git a/packages/backend/src/misc/api-permissions.ts b/packages/backend/src/misc/api-permissions.ts index 73c748caf0..9ab2bbf9d7 100644 --- a/packages/backend/src/misc/api-permissions.ts +++ b/packages/backend/src/misc/api-permissions.ts @@ -21,8 +21,6 @@ export const kinds = [ "write:pages", "write:page-likes", "read:page-likes", - "read:user-groups", - "write:user-groups", "read:gallery", "write:gallery", "read:gallery-likes", diff --git a/packages/backend/src/misc/check-hit-antenna.ts b/packages/backend/src/misc/check-hit-antenna.ts index e57ba32ffb..a92488b6e0 100644 --- a/packages/backend/src/misc/check-hit-antenna.ts +++ b/packages/backend/src/misc/check-hit-antenna.ts @@ -1,7 +1,7 @@ import type {Antenna} from "@/models/entities/antenna.js"; import type {Note} from "@/models/entities/note.js"; import type {User} from "@/models/entities/user.js"; -import {Blockings, UserGroupJoinings, UserListJoinings,} from "@/models/index.js"; +import {Blockings, UserListJoinings,} from "@/models/index.js"; import {getFullApAccount} from "./convert-host.js"; import * as Acct from "@/misc/acct.js"; import {Cache} from "./cache.js"; @@ -53,18 +53,6 @@ export async function checkHitAntenna( ).map((x) => x.userId); if (!listUsers.includes(note.userId)) return false; - } else if (antenna.src === "group") { - const joining = await UserGroupJoinings.findOneByOrFail({ - id: antenna.userGroupJoiningId!, - }); - - const groupUsers = ( - await UserGroupJoinings.findBy({ - userGroupId: joining.userGroupId, - }) - ).map((x) => x.userId); - - if (!groupUsers.includes(note.userId)) return false; } else if (antenna.src === "users") { const accts = antenna.users.map((x) => { const { username, host } = Acct.parse(x); diff --git a/packages/backend/src/misc/schema.ts b/packages/backend/src/misc/schema.ts index 31fb237304..7fbb023072 100644 --- a/packages/backend/src/misc/schema.ts +++ b/packages/backend/src/misc/schema.ts @@ -19,7 +19,6 @@ import {packedBlockingSchema} from "@/models/schema/blocking.js"; import {packedNoteReactionSchema} from "@/models/schema/note-reaction.js"; import {packedHashtagSchema} from "@/models/schema/hashtag.js"; import {packedPageSchema} from "@/models/schema/page.js"; -import {packedUserGroupSchema} from "@/models/schema/user-group.js"; import {packedNoteFavoriteSchema} from "@/models/schema/note-favorite.js"; import {packedAntennaSchema} from "@/models/schema/antenna.js"; import {packedClipSchema} from "@/models/schema/clip.js"; @@ -39,7 +38,6 @@ export const refs = { User: packedUserSchema, UserList: packedUserListSchema, - UserGroup: packedUserGroupSchema, App: packedAppSchema, NoteEdit: packedNoteEdit, NoteReaction: packedNoteReactionSchema, diff --git a/packages/backend/src/models/entities/antenna.ts b/packages/backend/src/models/entities/antenna.ts index 633dcc1d27..b369122848 100644 --- a/packages/backend/src/models/entities/antenna.ts +++ b/packages/backend/src/models/entities/antenna.ts @@ -1,15 +1,7 @@ -import { - PrimaryColumn, - Entity, - Index, - JoinColumn, - Column, - ManyToOne, -} from "typeorm"; -import { User } from "./user.js"; -import { id } from "../id.js"; -import { UserList } from "./user-list.js"; -import { UserGroupJoining } from "./user-group-joining.js"; +import {Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn,} from "typeorm"; +import {User} from "./user.js"; +import {id} from "../id.js"; +import {UserList} from "./user-list.js"; @Entity() export class Antenna { @@ -41,9 +33,9 @@ export class Antenna { public name: string; @Column("enum", { - enum: ["home", "all", "users", "list", "group", "instances"], + enum: ["home", "all", "users", "list", "instances"], }) - public src: "home" | "all" | "users" | "list" | "group" | "instances"; + public src: "home" | "all" | "users" | "list" | "instances"; @Column({ ...id(), @@ -57,18 +49,6 @@ export class Antenna { @JoinColumn() public userList: UserList | null; - @Column({ - ...id(), - nullable: true, - }) - public userGroupJoiningId: UserGroupJoining["id"] | null; - - @ManyToOne((type) => UserGroupJoining, { - onDelete: "CASCADE", - }) - @JoinColumn() - public userGroupJoining: UserGroupJoining | null; - @Column("varchar", { length: 1024, array: true, diff --git a/packages/backend/src/models/entities/notification.ts b/packages/backend/src/models/entities/notification.ts index da23f7d3ee..0177b517d9 100644 --- a/packages/backend/src/models/entities/notification.ts +++ b/packages/backend/src/models/entities/notification.ts @@ -1,18 +1,10 @@ -import { - Entity, - Index, - JoinColumn, - ManyToOne, - Column, - PrimaryColumn, -} from "typeorm"; -import { User } from "./user.js"; -import { id } from "../id.js"; -import { Note } from "./note.js"; -import { FollowRequest } from "./follow-request.js"; -import { UserGroupInvitation } from "./user-group-invitation.js"; -import { AccessToken } from "./access-token.js"; -import { notificationTypes } from "@/types.js"; +import {Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn,} from "typeorm"; +import {User} from "./user.js"; +import {id} from "../id.js"; +import {Note} from "./note.js"; +import {FollowRequest} from "./follow-request.js"; +import {AccessToken} from "./access-token.js"; +import {notificationTypes} from "@/types.js"; @Entity() export class Notification { @@ -70,7 +62,6 @@ export class Notification { * pollEnded - 自分のアンケートもしくは自分が投票したアンケートが終了した * receiveFollowRequest - フォローリクエストされた * followRequestAccepted - A follow request has been accepted. - * groupInvited - グループに招待された * app - App notifications. */ @Index() @@ -114,18 +105,6 @@ export class Notification { @JoinColumn() public followRequest: FollowRequest | null; - @Column({ - ...id(), - nullable: true, - }) - public userGroupInvitationId: UserGroupInvitation["id"] | null; - - @ManyToOne((type) => UserGroupInvitation, { - onDelete: "CASCADE", - }) - @JoinColumn() - public userGroupInvitation: UserGroupInvitation | null; - @Column("varchar", { length: 128, nullable: true, diff --git a/packages/backend/src/models/entities/user-group-invitation.ts b/packages/backend/src/models/entities/user-group-invitation.ts deleted file mode 100644 index fa2655ab67..0000000000 --- a/packages/backend/src/models/entities/user-group-invitation.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { - PrimaryColumn, - Entity, - Index, - JoinColumn, - Column, - ManyToOne, -} from "typeorm"; -import { User } from "./user.js"; -import { UserGroup } from "./user-group.js"; -import { id } from "../id.js"; - -@Entity() -@Index(["userId", "userGroupId"], { unique: true }) -export class UserGroupInvitation { - @PrimaryColumn(id()) - public id: string; - - @Column("timestamp with time zone", { - comment: "The created date of the UserGroupInvitation.", - }) - public createdAt: Date; - - @Index() - @Column({ - ...id(), - comment: "The user ID.", - }) - public userId: User["id"]; - - @ManyToOne((type) => User, { - onDelete: "CASCADE", - }) - @JoinColumn() - public user: User | null; - - @Index() - @Column({ - ...id(), - comment: "The group ID.", - }) - public userGroupId: UserGroup["id"]; - - @ManyToOne((type) => UserGroup, { - onDelete: "CASCADE", - }) - @JoinColumn() - public userGroup: UserGroup | null; -} diff --git a/packages/backend/src/models/entities/user-group-joining.ts b/packages/backend/src/models/entities/user-group-joining.ts deleted file mode 100644 index 78f820d0e8..0000000000 --- a/packages/backend/src/models/entities/user-group-joining.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { - PrimaryColumn, - Entity, - Index, - JoinColumn, - Column, - ManyToOne, -} from "typeorm"; -import { User } from "./user.js"; -import { UserGroup } from "./user-group.js"; -import { id } from "../id.js"; - -@Entity() -@Index(["userId", "userGroupId"], { unique: true }) -export class UserGroupJoining { - @PrimaryColumn(id()) - public id: string; - - @Column("timestamp with time zone", { - comment: "The created date of the UserGroupJoining.", - }) - public createdAt: Date; - - @Index() - @Column({ - ...id(), - comment: "The user ID.", - }) - public userId: User["id"]; - - @ManyToOne((type) => User, { - onDelete: "CASCADE", - }) - @JoinColumn() - public user: User | null; - - @Index() - @Column({ - ...id(), - comment: "The group ID.", - }) - public userGroupId: UserGroup["id"]; - - @ManyToOne((type) => UserGroup, { - onDelete: "CASCADE", - }) - @JoinColumn() - public userGroup: UserGroup | null; -} diff --git a/packages/backend/src/models/entities/user-group.ts b/packages/backend/src/models/entities/user-group.ts deleted file mode 100644 index 23876ec8b8..0000000000 --- a/packages/backend/src/models/entities/user-group.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { - Entity, - Index, - JoinColumn, - Column, - PrimaryColumn, - ManyToOne, -} from "typeorm"; -import { User } from "./user.js"; -import { id } from "../id.js"; - -@Entity() -export class UserGroup { - @PrimaryColumn(id()) - public id: string; - - @Index() - @Column("timestamp with time zone", { - comment: "The created date of the UserGroup.", - }) - public createdAt: Date; - - @Column("varchar", { - length: 256, - }) - public name: string; - - @Index() - @Column({ - ...id(), - comment: "The ID of owner.", - }) - public userId: User["id"]; - - @ManyToOne((type) => User, { - onDelete: "CASCADE", - }) - @JoinColumn() - public user: User | null; - - @Column("boolean", { - default: false, - }) - public isPrivate: boolean; - - constructor(data: Partial) { - if (data == null) return; - - for (const [k, v] of Object.entries(data)) { - (this as any)[k] = v; - } - } -} diff --git a/packages/backend/src/models/entities/user-profile.ts b/packages/backend/src/models/entities/user-profile.ts index e97f4a7815..f3df23d3a8 100644 --- a/packages/backend/src/models/entities/user-profile.ts +++ b/packages/backend/src/models/entities/user-profile.ts @@ -78,7 +78,7 @@ export class UserProfile { public emailVerified: boolean; @Column("jsonb", { - default: ["follow", "receiveFollowRequest", "groupInvited"], + default: ["follow", "receiveFollowRequest"], }) public emailNotificationTypes: string[]; diff --git a/packages/backend/src/models/index.ts b/packages/backend/src/models/index.ts index c6f3499a57..b9c6ecf234 100644 --- a/packages/backend/src/models/index.ts +++ b/packages/backend/src/models/index.ts @@ -19,9 +19,6 @@ import {UserNotePining} from "./entities/user-note-pining.js"; import {SigninRepository} from "./repositories/signin.js"; import {UserListRepository} from "./repositories/user-list.js"; import {UserListJoining} from "./entities/user-list-joining.js"; -import {UserGroupRepository} from "./repositories/user-group.js"; -import {UserGroupJoining} from "./entities/user-group-joining.js"; -import {UserGroupInvitationRepository} from "./repositories/user-group-invitation.js"; import {FollowRequestRepository} from "./repositories/follow-request.js"; import {MutingRepository} from "./repositories/muting.js"; import {RenoteMutingRepository} from "./repositories/renote-muting.js"; @@ -84,9 +81,6 @@ export const UserSecurityKeys = db.getRepository(UserSecurityKey); export const UserPublickeys = db.getRepository(UserPublickey); export const UserLists = UserListRepository; export const UserListJoinings = db.getRepository(UserListJoining); -export const UserGroups = UserGroupRepository; -export const UserGroupJoinings = db.getRepository(UserGroupJoining); -export const UserGroupInvitations = UserGroupInvitationRepository; export const UserNotePinings = db.getRepository(UserNotePining); export const UserIps = db.getRepository(UserIp); export const UsedUsernames = db.getRepository(UsedUsername); diff --git a/packages/backend/src/models/repositories/antenna.ts b/packages/backend/src/models/repositories/antenna.ts index d3b1ebc019..fa459a83d4 100644 --- a/packages/backend/src/models/repositories/antenna.ts +++ b/packages/backend/src/models/repositories/antenna.ts @@ -1,7 +1,7 @@ import {db} from "@/db/postgre.js"; import {Antenna} from "@/models/entities/antenna.js"; import type {Packed} from "@/misc/schema.js"; -import {AntennaNotes, UserGroupJoinings} from "../index.js"; +import {AntennaNotes} from "../index.js"; export const AntennaRepository = db.getRepository(Antenna).extend({ async pack(src: Antenna["id"] | Antenna): Promise> { @@ -11,9 +11,6 @@ export const AntennaRepository = db.getRepository(Antenna).extend({ const hasUnreadNote = (await AntennaNotes.findOneBy({ antennaId: antenna.id, read: false })) != null; - const userGroupJoining = antenna.userGroupJoiningId - ? await UserGroupJoinings.findOneBy({ id: antenna.userGroupJoiningId }) - : null; return { id: antenna.id, @@ -23,7 +20,6 @@ export const AntennaRepository = db.getRepository(Antenna).extend({ excludeKeywords: antenna.excludeKeywords, src: antenna.src, userListId: antenna.userListId, - userGroupId: userGroupJoining ? userGroupJoining.userGroupId : null, users: antenna.users, instances: antenna.instances, caseSensitive: antenna.caseSensitive, diff --git a/packages/backend/src/models/repositories/notification.ts b/packages/backend/src/models/repositories/notification.ts index b3273b5776..044d000313 100644 --- a/packages/backend/src/models/repositories/notification.ts +++ b/packages/backend/src/models/repositories/notification.ts @@ -7,7 +7,7 @@ import type {NoteReaction} from "@/models/entities/note-reaction.js"; import type {User} from "@/models/entities/user.js"; import {aggregateNoteEmojis, prefetchEmojis} from "@/misc/populate-emojis.js"; import {db} from "@/db/postgre.js"; -import {AccessTokens, NoteReactions, UserGroupInvitations, Users,} from "../index.js"; +import {AccessTokens, NoteReactions, Users,} from "../index.js"; import {getNote} from "@/server/api/common/getters.js"; export const NotificationRepository = db.getRepository(Notification).extend({ @@ -76,13 +76,6 @@ export const NotificationRepository = db.getRepository(Notification).extend({ note: getNote(notification.noteId!, { id: notification.notifieeId }), } : {}), - ...(notification.type === "groupInvited" - ? { - invitation: UserGroupInvitations.pack( - notification.userGroupInvitationId!, - ), - } - : {}), ...(notification.type === "app" ? { body: notification.customBody, diff --git a/packages/backend/src/models/repositories/user-group-invitation.ts b/packages/backend/src/models/repositories/user-group-invitation.ts deleted file mode 100644 index 920fb9ba29..0000000000 --- a/packages/backend/src/models/repositories/user-group-invitation.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { db } from "@/db/postgre.js"; -import { UserGroupInvitation } from "@/models/entities/user-group-invitation.js"; -import { UserGroups } from "../index.js"; - -export const UserGroupInvitationRepository = db - .getRepository(UserGroupInvitation) - .extend({ - async pack(src: UserGroupInvitation["id"] | UserGroupInvitation) { - const invitation = - typeof src === "object" ? src : await this.findOneByOrFail({ id: src }); - - return { - id: invitation.id, - group: await UserGroups.pack( - invitation.userGroup || invitation.userGroupId, - ), - }; - }, - - packMany(invitations: any[]) { - return Promise.all(invitations.map((x) => this.pack(x))); - }, - }); diff --git a/packages/backend/src/models/repositories/user-group.ts b/packages/backend/src/models/repositories/user-group.ts deleted file mode 100644 index daec94490e..0000000000 --- a/packages/backend/src/models/repositories/user-group.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { db } from "@/db/postgre.js"; -import { UserGroup } from "@/models/entities/user-group.js"; -import { UserGroupJoinings } from "../index.js"; -import type { Packed } from "@/misc/schema.js"; - -export const UserGroupRepository = db.getRepository(UserGroup).extend({ - async pack(src: UserGroup["id"] | UserGroup): Promise> { - const userGroup = - typeof src === "object" ? src : await this.findOneByOrFail({ id: src }); - - const users = await UserGroupJoinings.findBy({ - userGroupId: userGroup.id, - }); - - return { - id: userGroup.id, - createdAt: userGroup.createdAt.toISOString(), - name: userGroup.name, - ownerId: userGroup.userId, - userIds: users.map((x) => x.userId), - }; - }, -}); diff --git a/packages/backend/src/models/schema/antenna.ts b/packages/backend/src/models/schema/antenna.ts index 990e2daa2c..6de55de638 100644 --- a/packages/backend/src/models/schema/antenna.ts +++ b/packages/backend/src/models/schema/antenna.ts @@ -52,7 +52,7 @@ export const packedAntennaSchema = { type: "string", optional: false, nullable: false, - enum: ["home", "all", "users", "list", "group", "instances"], + enum: ["home", "all", "users", "list", "instances"], }, userListId: { type: "string", @@ -60,12 +60,6 @@ export const packedAntennaSchema = { nullable: true, format: "id", }, - userGroupId: { - type: "string", - optional: false, - nullable: true, - format: "id", - }, users: { type: "array", optional: false, diff --git a/packages/backend/src/models/schema/user-group.ts b/packages/backend/src/models/schema/user-group.ts deleted file mode 100644 index a4a85f9699..0000000000 --- a/packages/backend/src/models/schema/user-group.ts +++ /dev/null @@ -1,40 +0,0 @@ -export const packedUserGroupSchema = { - type: "object", - properties: { - id: { - type: "string", - optional: false, - nullable: false, - format: "id", - example: "xxxxxxxxxx", - }, - createdAt: { - type: "string", - optional: false, - nullable: false, - format: "date-time", - }, - name: { - type: "string", - optional: false, - nullable: false, - }, - ownerId: { - type: "string", - nullable: false, - optional: false, - format: "id", - }, - userIds: { - type: "array", - nullable: false, - optional: true, - items: { - type: "string", - nullable: false, - optional: false, - format: "id", - }, - }, - }, -} as const; diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 40243a7fd6..1ada582474 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -203,7 +203,6 @@ import * as ep___i_signinHistory from "./endpoints/i/signin-history.js"; import * as ep___i_unpin from "./endpoints/i/unpin.js"; import * as ep___i_updateEmail from "./endpoints/i/update-email.js"; import * as ep___i_update from "./endpoints/i/update.js"; -import * as ep___i_userGroupInvites from "./endpoints/i/user-group-invites.js"; import * as ep___i_webhooks_create from "./endpoints/i/webhooks/create.js"; import * as ep___i_webhooks_show from "./endpoints/i/webhooks/show.js"; import * as ep___i_webhooks_list from "./endpoints/i/webhooks/list.js"; @@ -284,18 +283,6 @@ import * as ep___users_followers from "./endpoints/users/followers.js"; import * as ep___users_following from "./endpoints/users/following.js"; import * as ep___users_gallery_posts from "./endpoints/users/gallery/posts.js"; import * as ep___users_getFrequentlyRepliedUsers from "./endpoints/users/get-frequently-replied-users.js"; -import * as ep___users_groups_create from "./endpoints/users/groups/create.js"; -import * as ep___users_groups_delete from "./endpoints/users/groups/delete.js"; -import * as ep___users_groups_invitations_accept from "./endpoints/users/groups/invitations/accept.js"; -import * as ep___users_groups_invitations_reject from "./endpoints/users/groups/invitations/reject.js"; -import * as ep___users_groups_invite from "./endpoints/users/groups/invite.js"; -import * as ep___users_groups_joined from "./endpoints/users/groups/joined.js"; -import * as ep___users_groups_leave from "./endpoints/users/groups/leave.js"; -import * as ep___users_groups_owned from "./endpoints/users/groups/owned.js"; -import * as ep___users_groups_pull from "./endpoints/users/groups/pull.js"; -import * as ep___users_groups_show from "./endpoints/users/groups/show.js"; -import * as ep___users_groups_transfer from "./endpoints/users/groups/transfer.js"; -import * as ep___users_groups_update from "./endpoints/users/groups/update.js"; import * as ep___users_lists_create from "./endpoints/users/lists/create.js"; import * as ep___users_lists_delete from "./endpoints/users/lists/delete.js"; import * as ep___users_lists_delete_all from "./endpoints/users/lists/delete-all.js"; @@ -532,7 +519,6 @@ const eps = [ ["i/unpin", ep___i_unpin], ["i/update-email", ep___i_updateEmail], ["i/update", ep___i_update], - ["i/user-group-invites", ep___i_userGroupInvites], ["i/webhooks/create", ep___i_webhooks_create], ["i/webhooks/list", ep___i_webhooks_list], ["i/webhooks/show", ep___i_webhooks_show], @@ -613,18 +599,6 @@ const eps = [ ["users/following", ep___users_following], ["users/gallery/posts", ep___users_gallery_posts], ["users/get-frequently-replied-users", ep___users_getFrequentlyRepliedUsers], - ["users/groups/create", ep___users_groups_create], - ["users/groups/delete", ep___users_groups_delete], - ["users/groups/invitations/accept", ep___users_groups_invitations_accept], - ["users/groups/invitations/reject", ep___users_groups_invitations_reject], - ["users/groups/invite", ep___users_groups_invite], - ["users/groups/joined", ep___users_groups_joined], - ["users/groups/leave", ep___users_groups_leave], - ["users/groups/owned", ep___users_groups_owned], - ["users/groups/pull", ep___users_groups_pull], - ["users/groups/show", ep___users_groups_show], - ["users/groups/transfer", ep___users_groups_transfer], - ["users/groups/update", ep___users_groups_update], ["users/lists/create", ep___users_lists_create], ["users/lists/delete", ep___users_lists_delete], ["users/lists/delete-all", ep___users_lists_delete_all], diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index f69501ae20..5694823a53 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -1,8 +1,8 @@ import define from "../../define.js"; -import { genId } from "@/misc/gen-id.js"; -import { Antennas, UserLists, UserGroupJoinings } from "@/models/index.js"; -import { ApiError } from "../../error.js"; -import { publishInternalEvent } from "@/services/stream.js"; +import {genId} from "@/misc/gen-id.js"; +import {Antennas, UserLists} from "@/models/index.js"; +import {ApiError} from "../../error.js"; +import {publishInternalEvent} from "@/services/stream.js"; export const meta = { tags: ["antennas"], @@ -18,12 +18,6 @@ export const meta = { id: "95063e93-a283-4b8b-9aa5-bcdb8df69a7f", }, - noSuchUserGroup: { - message: "No such user group.", - code: "NO_SUCH_USER_GROUP", - id: "aa3c0b9a-8cae-47c0-92ac-202ce5906682", - }, - tooManyAntennas: { message: "Too many antennas.", code: "TOO_MANY_ANTENNAS", @@ -45,10 +39,9 @@ export const paramDef = { name: { type: "string", minLength: 1, maxLength: 100 }, src: { type: "string", - enum: ["home", "all", "users", "list", "group", "instances"], + enum: ["home", "all", "users", "list", "instances"], }, userListId: { type: "string", format: "misskey:id", nullable: true }, - userGroupId: { type: "string", format: "misskey:id", nullable: true }, keywords: { type: "array", items: { @@ -99,9 +92,7 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, user) => { - if (user.movedToUri != null) throw new ApiError(meta.errors.noSuchUserGroup); let userList; - let userGroupJoining; const antennas = await Antennas.findBy({ userId: user.id, @@ -119,15 +110,6 @@ export default define(meta, paramDef, async (ps, user) => { if (userList == null) { throw new ApiError(meta.errors.noSuchUserList); } - } else if (ps.src === "group" && ps.userGroupId) { - userGroupJoining = await UserGroupJoinings.findOneBy({ - userGroupId: ps.userGroupId, - userId: user.id, - }); - - if (userGroupJoining == null) { - throw new ApiError(meta.errors.noSuchUserGroup); - } } const antenna = await Antennas.insert({ @@ -137,7 +119,6 @@ export default define(meta, paramDef, async (ps, user) => { name: ps.name, src: ps.src, userListId: userList ? userList.id : null, - userGroupJoiningId: userGroupJoining ? userGroupJoining.id : null, keywords: ps.keywords, excludeKeywords: ps.excludeKeywords, users: ps.users, diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index f491c0b638..9b1a6a4618 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -1,7 +1,7 @@ import define from "../../define.js"; -import { ApiError } from "../../error.js"; -import { Antennas, UserLists, UserGroupJoinings } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; +import {ApiError} from "../../error.js"; +import {Antennas, UserLists} from "@/models/index.js"; +import {publishInternalEvent} from "@/services/stream.js"; export const meta = { tags: ["antennas"], @@ -22,12 +22,6 @@ export const meta = { code: "NO_SUCH_USER_LIST", id: "1c6b35c9-943e-48c2-81e4-2844989407f7", }, - - noSuchUserGroup: { - message: "No such user group.", - code: "NO_SUCH_USER_GROUP", - id: "109ed789-b6eb-456e-b8a9-6059d567d385", - }, }, res: { @@ -45,10 +39,9 @@ export const paramDef = { name: { type: "string", minLength: 1, maxLength: 100 }, src: { type: "string", - enum: ["home", "all", "users", "list", "group", "instances"], + enum: ["home", "all", "users", "list", "instances"], }, userListId: { type: "string", format: "misskey:id", nullable: true }, - userGroupId: { type: "string", format: "misskey:id", nullable: true }, keywords: { type: "array", items: { @@ -122,22 +115,12 @@ export default define(meta, paramDef, async (ps, user) => { if (userList == null) { throw new ApiError(meta.errors.noSuchUserList); } - } else if (ps.src === "group" && ps.userGroupId) { - userGroupJoining = await UserGroupJoinings.findOneBy({ - userGroupId: ps.userGroupId, - userId: user.id, - }); - - if (userGroupJoining == null) { - throw new ApiError(meta.errors.noSuchUserGroup); - } } await Antennas.update(antenna.id, { name: ps.name, src: ps.src, userListId: userList ? userList.id : null, - userGroupJoiningId: userGroupJoining ? userGroupJoining.id : null, keywords: ps.keywords, excludeKeywords: ps.excludeKeywords, users: ps.users, diff --git a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts b/packages/backend/src/server/api/endpoints/i/user-group-invites.ts deleted file mode 100644 index d0c6caf0e2..0000000000 --- a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts +++ /dev/null @@ -1,60 +0,0 @@ -import define from "../../define.js"; -import { UserGroupInvitations } from "@/models/index.js"; -import { makePaginationQuery } from "../../common/make-pagination-query.js"; - -export const meta = { - tags: ["account", "groups"], - - requireCredential: true, - - kind: "read:user-groups", - - res: { - type: "array", - optional: false, - nullable: false, - items: { - type: "object", - optional: false, - nullable: false, - properties: { - id: { - type: "string", - optional: false, - nullable: false, - format: "id", - }, - group: { - type: "object", - optional: false, - nullable: false, - ref: "UserGroup", - }, - }, - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - limit: { type: "integer", minimum: 1, maximum: 100, default: 10 }, - sinceId: { type: "string", format: "misskey:id" }, - untilId: { type: "string", format: "misskey:id" }, - }, - required: [], -} as const; - -export default define(meta, paramDef, async (ps, user) => { - const query = makePaginationQuery( - UserGroupInvitations.createQueryBuilder("invitation"), - ps.sinceId, - ps.untilId, - ) - .andWhere("invitation.userId = :meId", { meId: user.id }) - .leftJoinAndSelect("invitation.userGroup", "user_group"); - - const invitations = await query.take(ps.limit).getMany(); - - return await UserGroupInvitations.packMany(invitations); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/create.ts b/packages/backend/src/server/api/endpoints/users/groups/create.ts deleted file mode 100644 index 76bd78c49f..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/create.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import type { UserGroup } from "@/models/entities/user-group.js"; -import type { UserGroupJoining } from "@/models/entities/user-group-joining.js"; -import define from "../../../define.js"; - -export const meta = { - tags: ["groups"], - - requireCredential: true, - - kind: "write:user-groups", - - description: "Create a new group.", - - res: { - type: "object", - optional: false, - nullable: false, - ref: "UserGroup", - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - name: { type: "string", minLength: 1, maxLength: 100 }, - }, - required: ["name"], -} as const; - -export default define(meta, paramDef, async (ps, user) => { - const userGroup = await UserGroups.insert({ - id: genId(), - createdAt: new Date(), - userId: user.id, - name: ps.name, - } as UserGroup).then((x) => UserGroups.findOneByOrFail(x.identifiers[0])); - - // Push the owner - await UserGroupJoinings.insert({ - id: genId(), - createdAt: new Date(), - userId: user.id, - userGroupId: userGroup.id, - } as UserGroupJoining); - - return await UserGroups.pack(userGroup); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/delete.ts b/packages/backend/src/server/api/endpoints/users/groups/delete.ts deleted file mode 100644 index 81c15ad38e..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/delete.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { UserGroups } from "@/models/index.js"; -import define from "../../../define.js"; -import { ApiError } from "../../../error.js"; - -export const meta = { - tags: ["groups"], - - requireCredential: true, - - kind: "write:user-groups", - - description: "Delete an existing group.", - - errors: { - noSuchGroup: { - message: "No such group.", - code: "NO_SUCH_GROUP", - id: "63dbd64c-cd77-413f-8e08-61781e210b38", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - groupId: { type: "string", format: "misskey:id" }, - }, - required: ["groupId"], -} as const; - -export default define(meta, paramDef, async (ps, user) => { - const userGroup = await UserGroups.findOneBy({ - id: ps.groupId, - userId: user.id, - }); - - if (userGroup == null) { - throw new ApiError(meta.errors.noSuchGroup); - } - - await UserGroups.delete(userGroup.id); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts b/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts deleted file mode 100644 index 5cb3a7bad3..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { UserGroupJoinings, UserGroupInvitations } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import type { UserGroupJoining } from "@/models/entities/user-group-joining.js"; -import { ApiError } from "../../../../error.js"; -import define from "../../../../define.js"; - -export const meta = { - tags: ["groups", "users"], - - requireCredential: true, - - kind: "write:user-groups", - - description: "Join a group the authenticated user has been invited to.", - - errors: { - noSuchInvitation: { - message: "No such invitation.", - code: "NO_SUCH_INVITATION", - id: "98c11eca-c890-4f42-9806-c8c8303ebb5e", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - invitationId: { type: "string", format: "misskey:id" }, - }, - required: ["invitationId"], -} as const; - -export default define(meta, paramDef, async (ps, user) => { - // Fetch the invitation - const invitation = await UserGroupInvitations.findOneBy({ - id: ps.invitationId, - }); - - if (invitation == null) { - throw new ApiError(meta.errors.noSuchInvitation); - } - - if (invitation.userId !== user.id) { - throw new ApiError(meta.errors.noSuchInvitation); - } - - // Push the user - await UserGroupJoinings.insert({ - id: genId(), - createdAt: new Date(), - userId: user.id, - userGroupId: invitation.userGroupId, - } as UserGroupJoining); - - UserGroupInvitations.delete(invitation.id); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts b/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts deleted file mode 100644 index c04ebed23b..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { UserGroupInvitations } from "@/models/index.js"; -import define from "../../../../define.js"; -import { ApiError } from "../../../../error.js"; - -export const meta = { - tags: ["groups", "users"], - - requireCredential: true, - - kind: "write:user-groups", - - description: - "Delete an existing group invitation for the authenticated user without joining the group.", - - errors: { - noSuchInvitation: { - message: "No such invitation.", - code: "NO_SUCH_INVITATION", - id: "ad7471d4-2cd9-44b4-ac68-e7136b4ce656", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - invitationId: { type: "string", format: "misskey:id" }, - }, - required: ["invitationId"], -} as const; - -export default define(meta, paramDef, async (ps, user) => { - // Fetch the invitation - const invitation = await UserGroupInvitations.findOneBy({ - id: ps.invitationId, - }); - - if (invitation == null) { - throw new ApiError(meta.errors.noSuchInvitation); - } - - if (invitation.userId !== user.id) { - throw new ApiError(meta.errors.noSuchInvitation); - } - - await UserGroupInvitations.delete(invitation.id); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/invite.ts b/packages/backend/src/server/api/endpoints/users/groups/invite.ts deleted file mode 100644 index 10cc215861..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/invite.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { - UserGroups, - UserGroupJoinings, - UserGroupInvitations, -} from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; -import type { UserGroupInvitation } from "@/models/entities/user-group-invitation.js"; -import { createNotification } from "@/services/create-notification.js"; -import { getUser } from "../../../common/getters.js"; -import { ApiError } from "../../../error.js"; -import define from "../../../define.js"; - -export const meta = { - tags: ["groups", "users"], - - requireCredential: true, - - kind: "write:user-groups", - - description: "Invite a user to an existing group.", - - errors: { - noSuchGroup: { - message: "No such group.", - code: "NO_SUCH_GROUP", - id: "583f8bc0-8eee-4b78-9299-1e14fc91e409", - }, - - noSuchUser: { - message: "No such user.", - code: "NO_SUCH_USER", - id: "da52de61-002c-475b-90e1-ba64f9cf13a8", - }, - - alreadyAdded: { - message: "That user has already been added to that group.", - code: "ALREADY_ADDED", - id: "7e35c6a0-39b2-4488-aea6-6ee20bd5da2c", - }, - - alreadyInvited: { - message: "That user has already been invited to that group.", - code: "ALREADY_INVITED", - id: "ee0f58b4-b529-4d13-b761-b9a3e69f97e6", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - groupId: { type: "string", format: "misskey:id" }, - userId: { type: "string", format: "misskey:id" }, - }, - required: ["groupId", "userId"], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - // Fetch the group - const userGroup = await UserGroups.findOneBy({ - id: ps.groupId, - userId: me.id, - }); - - if (userGroup == null) { - throw new ApiError(meta.errors.noSuchGroup); - } - - // Fetch the user - const user = await getUser(ps.userId).catch((e) => { - if (e.id === "15348ddd-432d-49c2-8a5a-8069753becff") - throw new ApiError(meta.errors.noSuchUser); - throw e; - }); - - const joining = await UserGroupJoinings.findOneBy({ - userGroupId: userGroup.id, - userId: user.id, - }); - - if (joining) { - throw new ApiError(meta.errors.alreadyAdded); - } - - const existInvitation = await UserGroupInvitations.findOneBy({ - userGroupId: userGroup.id, - userId: user.id, - }); - - if (existInvitation) { - throw new ApiError(meta.errors.alreadyInvited); - } - - const invitation = await UserGroupInvitations.insert({ - id: genId(), - createdAt: new Date(), - userId: user.id, - userGroupId: userGroup.id, - } as UserGroupInvitation).then((x) => - UserGroupInvitations.findOneByOrFail(x.identifiers[0]), - ); - - // 通知を作成 - createNotification(user.id, "groupInvited", { - notifierId: me.id, - userGroupInvitationId: invitation.id, - }); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/joined.ts b/packages/backend/src/server/api/endpoints/users/groups/joined.ts deleted file mode 100644 index 8422cf586d..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/joined.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Not, In } from "typeorm"; -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; -import define from "../../../define.js"; - -export const meta = { - tags: ["groups", "account"], - - requireCredential: true, - - kind: "read:user-groups", - - description: "List the groups that the authenticated user is a member of.", - - res: { - type: "array", - optional: false, - nullable: false, - items: { - type: "object", - optional: false, - nullable: false, - ref: "UserGroup", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: {}, - required: [], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - const ownedGroups = await UserGroups.findBy({ - userId: me.id, - }); - - const joinings = await UserGroupJoinings.findBy({ - userId: me.id, - ...(ownedGroups.length > 0 - ? { - userGroupId: Not(In(ownedGroups.map((x) => x.id))), - } - : {}), - }); - - return await Promise.all(joinings.map((x) => UserGroups.pack(x.userGroupId))); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/leave.ts b/packages/backend/src/server/api/endpoints/users/groups/leave.ts deleted file mode 100644 index d963b1826e..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/leave.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; -import define from "../../../define.js"; -import { ApiError } from "../../../error.js"; - -export const meta = { - tags: ["groups", "users"], - - requireCredential: true, - - kind: "write:user-groups", - - description: - "Leave a group. The owner of a group can not leave. They must transfer ownership or delete the group instead.", - - errors: { - noSuchGroup: { - message: "No such group.", - code: "NO_SUCH_GROUP", - id: "62780270-1f67-5dc0-daca-3eb510612e31", - }, - - youAreOwner: { - message: "Your are the owner.", - code: "YOU_ARE_OWNER", - id: "b6d6e0c2-ef8a-9bb8-653d-79f4a3107c69", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - groupId: { type: "string", format: "misskey:id" }, - }, - required: ["groupId"], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - // Fetch the group - const userGroup = await UserGroups.findOneBy({ - id: ps.groupId, - }); - - if (userGroup == null) { - throw new ApiError(meta.errors.noSuchGroup); - } - - if (me.id === userGroup.userId) { - throw new ApiError(meta.errors.youAreOwner); - } - - await UserGroupJoinings.delete({ userGroupId: userGroup.id, userId: me.id }); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/owned.ts b/packages/backend/src/server/api/endpoints/users/groups/owned.ts deleted file mode 100644 index d86185ff02..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/owned.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { UserGroups } from "@/models/index.js"; -import define from "../../../define.js"; - -export const meta = { - tags: ["groups", "account"], - - requireCredential: true, - - kind: "read:user-groups", - - description: "List the groups that the authenticated user is the owner of.", - - res: { - type: "array", - optional: false, - nullable: false, - items: { - type: "object", - optional: false, - nullable: false, - ref: "UserGroup", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: {}, - required: [], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - const userGroups = await UserGroups.findBy({ - userId: me.id, - }); - - return await Promise.all(userGroups.map((x) => UserGroups.pack(x))); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/pull.ts b/packages/backend/src/server/api/endpoints/users/groups/pull.ts deleted file mode 100644 index 1f79a2d2b7..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/pull.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; -import define from "../../../define.js"; -import { ApiError } from "../../../error.js"; -import { getUser } from "../../../common/getters.js"; - -export const meta = { - tags: ["groups", "users"], - - requireCredential: true, - - kind: "write:user-groups", - - description: - "Removes a specified user from a group. The owner can not be removed.", - - errors: { - noSuchGroup: { - message: "No such group.", - code: "NO_SUCH_GROUP", - id: "4662487c-05b1-4b78-86e5-fd46998aba74", - }, - - noSuchUser: { - message: "No such user.", - code: "NO_SUCH_USER", - id: "0b5cc374-3681-41da-861e-8bc1146f7a55", - }, - - isOwner: { - message: "The user is the owner.", - code: "IS_OWNER", - id: "1546eed5-4414-4dea-81c1-b0aec4f6d2af", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - groupId: { type: "string", format: "misskey:id" }, - userId: { type: "string", format: "misskey:id" }, - }, - required: ["groupId", "userId"], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - // Fetch the group - const userGroup = await UserGroups.findOneBy({ - id: ps.groupId, - userId: me.id, - }); - - if (userGroup == null) { - throw new ApiError(meta.errors.noSuchGroup); - } - - // Fetch the user - const user = await getUser(ps.userId).catch((e) => { - if (e.id === "15348ddd-432d-49c2-8a5a-8069753becff") - throw new ApiError(meta.errors.noSuchUser); - throw e; - }); - - if (user.id === userGroup.userId) { - throw new ApiError(meta.errors.isOwner); - } - - // Pull the user - await UserGroupJoinings.delete({ - userGroupId: userGroup.id, - userId: user.id, - }); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/show.ts b/packages/backend/src/server/api/endpoints/users/groups/show.ts deleted file mode 100644 index 46f4410c84..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/show.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; -import define from "../../../define.js"; -import { ApiError } from "../../../error.js"; - -export const meta = { - tags: ["groups", "account"], - - requireCredential: true, - - kind: "read:user-groups", - - description: "Show the properties of a group.", - - res: { - type: "object", - optional: false, - nullable: false, - ref: "UserGroup", - }, - - errors: { - noSuchGroup: { - message: "No such group.", - code: "NO_SUCH_GROUP", - id: "ea04751e-9b7e-487b-a509-330fb6bd6b9b", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - groupId: { type: "string", format: "misskey:id" }, - }, - required: ["groupId"], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - // Fetch the group - const userGroup = await UserGroups.findOneBy({ - id: ps.groupId, - }); - - if (userGroup == null) { - throw new ApiError(meta.errors.noSuchGroup); - } - - const joining = await UserGroupJoinings.findOneBy({ - userId: me.id, - userGroupId: userGroup.id, - }); - - if (joining == null && userGroup.userId !== me.id) { - throw new ApiError(meta.errors.noSuchGroup); - } - - return await UserGroups.pack(userGroup); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/transfer.ts b/packages/backend/src/server/api/endpoints/users/groups/transfer.ts deleted file mode 100644 index 0322441574..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/transfer.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { UserGroups, UserGroupJoinings } from "@/models/index.js"; -import define from "../../../define.js"; -import { ApiError } from "../../../error.js"; -import { getUser } from "../../../common/getters.js"; - -export const meta = { - tags: ["groups", "users"], - - requireCredential: true, - - kind: "write:user-groups", - - description: - "Transfer ownership of a group from the authenticated user to another user.", - - res: { - type: "object", - optional: false, - nullable: false, - ref: "UserGroup", - }, - - errors: { - noSuchGroup: { - message: "No such group.", - code: "NO_SUCH_GROUP", - id: "8e31d36b-2f88-4ccd-a438-e2d78a9162db", - }, - - noSuchUser: { - message: "No such user.", - code: "NO_SUCH_USER", - id: "711f7ebb-bbb9-4dfa-b540-b27809fed5e9", - }, - - noSuchGroupMember: { - message: "No such group member.", - code: "NO_SUCH_GROUP_MEMBER", - id: "d31bebee-196d-42c2-9a3e-9474d4be6cc4", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - groupId: { type: "string", format: "misskey:id" }, - userId: { type: "string", format: "misskey:id" }, - }, - required: ["groupId", "userId"], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - // Fetch the group - const userGroup = await UserGroups.findOneBy({ - id: ps.groupId, - userId: me.id, - }); - - if (userGroup == null) { - throw new ApiError(meta.errors.noSuchGroup); - } - - // Fetch the user - const user = await getUser(ps.userId).catch((e) => { - if (e.id === "15348ddd-432d-49c2-8a5a-8069753becff") - throw new ApiError(meta.errors.noSuchUser); - throw e; - }); - - const joining = await UserGroupJoinings.findOneBy({ - userGroupId: userGroup.id, - userId: user.id, - }); - - if (joining == null) { - throw new ApiError(meta.errors.noSuchGroupMember); - } - - await UserGroups.update(userGroup.id, { - userId: ps.userId, - }); - - return await UserGroups.pack(userGroup.id); -}); diff --git a/packages/backend/src/server/api/endpoints/users/groups/update.ts b/packages/backend/src/server/api/endpoints/users/groups/update.ts deleted file mode 100644 index fa720c9c45..0000000000 --- a/packages/backend/src/server/api/endpoints/users/groups/update.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { UserGroups } from "@/models/index.js"; -import define from "../../../define.js"; -import { ApiError } from "../../../error.js"; - -export const meta = { - tags: ["groups"], - - requireCredential: true, - - kind: "write:user-groups", - - description: "Update the properties of a group.", - - res: { - type: "object", - optional: false, - nullable: false, - ref: "UserGroup", - }, - - errors: { - noSuchGroup: { - message: "No such group.", - code: "NO_SUCH_GROUP", - id: "9081cda3-7a9e-4fac-a6ce-908d70f282f6", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - groupId: { type: "string", format: "misskey:id" }, - name: { type: "string", minLength: 1, maxLength: 100 }, - }, - required: ["groupId", "name"], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - // Fetch the group - const userGroup = await UserGroups.findOneBy({ - id: ps.groupId, - userId: me.id, - }); - - if (userGroup == null) { - throw new ApiError(meta.errors.noSuchGroup); - } - - await UserGroups.update(userGroup.id, { - name: ps.name, - }); - - return await UserGroups.pack(userGroup.id); -}); diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts index 2ba6da2f7d..8f52c9864b 100644 --- a/packages/backend/src/types.ts +++ b/packages/backend/src/types.ts @@ -9,7 +9,6 @@ export const notificationTypes = [ "pollEnded", "receiveFollowRequest", "followRequestAccepted", - "groupInvited", "app", ] as const;