mirror of
				https://github.com/Mestima/GM-Discord.git
				synced 2025-10-31 00:52:34 +00:00 
			
		
		
		
	node webpart request security fix
This commit is contained in:
		
							
								
								
									
										12
									
								
								web/nodejs/dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								web/nodejs/dist/index.js
									
									
									
									
										vendored
									
									
								
							| @ -12,6 +12,7 @@ const port = config.port; | ||||
| const webhook = config.webhook; | ||||
| const channel = config.channel; | ||||
| const token = config.token; | ||||
| const security = config.security; | ||||
| const debug = config.debug; | ||||
| app.post("/send", (req, res) => { | ||||
|     const content = req.query.content; | ||||
| @ -42,6 +43,17 @@ app.post("/send", (req, res) => { | ||||
|     }); | ||||
| }); | ||||
| app.get("/request", (req, res) => { | ||||
|     if (security) { | ||||
|         const postToken = req.query.token; | ||||
|         const postChannel = req.query.channel; | ||||
|         if (channel != postChannel || token != postToken) { | ||||
|             const err = `error: unknown token or channel`; | ||||
|             if (debug) { | ||||
|                 console.log(err); | ||||
|             } | ||||
|             return res.send(err); | ||||
|         } | ||||
|     } | ||||
|     node_fetch_1.default(`https://discordapp.com/api/channels/${channel}/messages?token=Bot ${token}`) | ||||
|         .then(discordRes => discordRes.json()) | ||||
|         .then(json => { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user