MisskeyPagesにイベント送信ボタンを追加
This commit is contained in:
		
							
								
								
									
										44
									
								
								src/server/api/endpoints/page-push.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/server/api/endpoints/page-push.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| import $ from 'cafy'; | ||||
| import define from '../define'; | ||||
| import { ID } from '../../../misc/cafy-id'; | ||||
| import { publishMainStream } from '../../../services/stream'; | ||||
| import { Users, Pages } from '../../../models'; | ||||
| import { ApiError } from '../error'; | ||||
|  | ||||
| export const meta = { | ||||
| 	requireCredential: true, | ||||
| 	secure: true, | ||||
|  | ||||
| 	params: { | ||||
| 		pageId: { | ||||
| 			validator: $.type(ID) | ||||
| 		}, | ||||
|  | ||||
| 		event: { | ||||
| 			validator: $.str | ||||
| 		} | ||||
| 	}, | ||||
|  | ||||
| 	errors: { | ||||
| 		noSuchPage: { | ||||
| 			message: 'No such page.', | ||||
| 			code: 'NO_SUCH_PAGE', | ||||
| 			id: '4a13ad31-6729-46b4-b9af-e86b265c2e74' | ||||
| 		} | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| export default define(meta, async (ps, user) => { | ||||
| 	const page = await Pages.findOne(ps.pageId); | ||||
| 	if (page == null) { | ||||
| 		throw new ApiError(meta.errors.noSuchPage); | ||||
| 	} | ||||
|  | ||||
| 	publishMainStream(user.id, 'pageEvent', { | ||||
| 		pageId: ps.pageId, | ||||
| 		event: ps.event, | ||||
| 		user: await Users.pack(user, page.userId, { | ||||
| 			detail: true | ||||
| 		}) | ||||
| 	}); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user
	 syuilo
					syuilo