| 
						
						
						
					 | 
					@ -1,5 +1,5 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					const axios = require("axios"); | 
					 | 
					 | 
					const axios = require("axios"); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					const {R} = require("redbean-node"); | 
					 | 
					 | 
					const { R } = require("redbean-node"); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					const FormData = require('form-data'); | 
					 | 
					 | 
					const FormData = require('form-data'); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					const nodemailer = require("nodemailer"); | 
					 | 
					 | 
					const nodemailer = require("nodemailer"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -52,45 +52,61 @@ class Notification { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } else if (notification.type === "smtp") { | 
					 | 
					 | 
					        } else if (notification.type === "smtp") { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            return await Notification.smtp(notification, msg) | 
					 | 
					 | 
					            return await Notification.smtp(notification, msg) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } else if (notification.type === "signal") { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                let data = { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    "message": msg, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    "number": notification.signalNumber, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    "recipients": notification.signalRecipients.replace(/\s/g, '').split(",") | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                let config = {}; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                let res = await axios.post(notification.signalURL, data, config) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                return true; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } catch (error) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                console.log(error) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                return false; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } else if (notification.type === "discord") { | 
					 | 
					 | 
					        } else if (notification.type === "discord") { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            try { | 
					 | 
					 | 
					            try { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					              // If heartbeatJSON is null, assume we're testing.
 | 
					 | 
					 | 
					                // If heartbeatJSON is null, assume we're testing.
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              if(heartbeatJSON == null) { | 
					 | 
					 | 
					                if (heartbeatJSON == null) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    let data = { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        username: 'Uptime-Kuma', | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        content: msg | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    let res = await axios.post(notification.discordWebhookUrl, data) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    return true; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                // If heartbeatJSON is not null, we go into the normal alerting loop.
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                if (heartbeatJSON['status'] == 0) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    var alertColor = "16711680"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                } else if (heartbeatJSON['status'] == 1) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    var alertColor = "65280"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                let data = { | 
					 | 
					 | 
					                let data = { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  username: 'Uptime-Kuma', | 
					 | 
					 | 
					                    username: 'Uptime-Kuma', | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  content: msg | 
					 | 
					 | 
					                    embeds: [{ | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        title: "Uptime-Kuma Alert", | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        color: alertColor, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        fields: [ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                                name: "Time (UTC)", | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                                value: heartbeatJSON["time"] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                                name: "Message", | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                                value: msg | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        ] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    }] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                } | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                let res = await axios.post(notification.discordWebhookUrl, data) | 
					 | 
					 | 
					                let res = await axios.post(notification.discordWebhookUrl, data) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                return true; | 
					 | 
					 | 
					                return true; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					              } | 
					 | 
					 | 
					            } catch (error) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              // If heartbeatJSON is not null, we go into the normal alerting loop.
 | 
					 | 
					 | 
					                console.log(error) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              if(heartbeatJSON['status'] == 0) { | 
					 | 
					 | 
					                return false; | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                var alertColor = "16711680"; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              } else if(heartbeatJSON['status'] == 1) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                var alertColor = "65280"; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              let data = { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                username: 'Uptime-Kuma', | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                embeds: [{ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                  title: "Uptime-Kuma Alert", | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                  color: alertColor, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                  fields: [ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                      name: "Time (UTC)", | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                      value: heartbeatJSON["time"] | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    }, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                      name: "Message", | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                      value: msg | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                  ] | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                }] | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              let res = await axios.post(notification.discordWebhookUrl, data) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              return true; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } catch(error) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              console.log(error) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              return false; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } else { | 
					 | 
					 | 
					        } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            throw new Error("Notification type is not supported") | 
					 | 
					 | 
					            throw new Error("Notification type is not supported") | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -106,7 +122,7 @@ class Notification { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                userID, | 
					 | 
					 | 
					                userID, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            ]) | 
					 | 
					 | 
					            ]) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if (! bean) { | 
					 | 
					 | 
					            if (!bean) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                throw new Error("notification not found") | 
					 | 
					 | 
					                throw new Error("notification not found") | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -126,7 +142,7 @@ class Notification { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            userID, | 
					 | 
					 | 
					            userID, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        ]) | 
					 | 
					 | 
					        ]) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        if (! bean) { | 
					 | 
					 | 
					        if (!bean) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            throw new Error("notification not found") | 
					 | 
					 | 
					            throw new Error("notification not found") | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |