mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-01 00:08:10 +09:00
parent
81efc7a77b
commit
71ce3ea61e
@ -21,6 +21,7 @@
|
||||
- クライアント: 新しいダークテーマを追加
|
||||
- クライアント: テーマコンパイラに hue と saturate 関数を追加
|
||||
- ActivityPub: HTML -> MFMの変換を強化
|
||||
- API: グループから抜ける users/groups/leave エンドポイントを実装
|
||||
- API: i/notifications に unreadOnly オプションを追加
|
||||
- API: ap系のエンドポイントをログイン必須化+レートリミット追加
|
||||
- MFM: Add tag syntaxes of bold <b></b> and strikethrough <s></s>
|
||||
|
50
src/server/api/endpoints/users/groups/leave.ts
Normal file
50
src/server/api/endpoints/users/groups/leave.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { ApiError } from '../../../error';
|
||||
import { UserGroups, UserGroupJoinings } from '@/models/index';
|
||||
|
||||
export const meta = {
|
||||
tags: ['groups', 'users'],
|
||||
|
||||
requireCredential: true as const,
|
||||
|
||||
kind: 'write:user-groups',
|
||||
|
||||
params: {
|
||||
groupId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
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'
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
export default define(meta, async (ps, me) => {
|
||||
// Fetch the group
|
||||
const userGroup = await UserGroups.findOne({
|
||||
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 });
|
||||
});
|
Loading…
Reference in New Issue
Block a user