Merge pull request #133 from NiNiyas/lunasea-support
Adds support for LunaSea notifications
This commit is contained in:
		
						commit
						204624bfe9
					
				
					 2 changed files with 56 additions and 27 deletions
				
			
		|  | @ -235,6 +235,41 @@ class Notification { | ||||||
| 
 | 
 | ||||||
|             return Notification.apprise(notification, msg) |             return Notification.apprise(notification, msg) | ||||||
| 
 | 
 | ||||||
|  |         } else if (notification.type === "lunasea") { | ||||||
|  |             let lunaseadevice = "https://notify.lunasea.app/v1/custom/device/" + notification.lunaseaDevice | ||||||
|  | 
 | ||||||
|  |             try { | ||||||
|  |                 if (heartbeatJSON == null) { | ||||||
|  |                     let testdata = { | ||||||
|  |                         "title": "Uptime Kuma Alert", | ||||||
|  |                         "body": "Testing Successful.", | ||||||
|  |                     } | ||||||
|  |                     await axios.post(lunaseadevice, testdata) | ||||||
|  |                     return okMsg; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if (heartbeatJSON["status"] == 0) { | ||||||
|  |                     let downdata = { | ||||||
|  |                         "title": "UptimeKuma Alert:" + monitorJSON["name"], | ||||||
|  |                         "body": "[🔴 Down]" + heartbeatJSON["msg"] + "\nTime (UTC):" + heartbeatJSON["time"], | ||||||
|  |                     } | ||||||
|  |                     await axios.post(lunaseadevice, downdata) | ||||||
|  |                     return okMsg; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if (heartbeatJSON["status"] == 1) { | ||||||
|  |                     let updata = { | ||||||
|  |                         "title": "UptimeKuma Alert:" + monitorJSON["name"], | ||||||
|  |                         "body": "[✅ Up]" + heartbeatJSON["msg"] + "\nTime (UTC):" + heartbeatJSON["time"], | ||||||
|  |                     } | ||||||
|  |                     await axios.post(lunaseadevice, updata) | ||||||
|  |                     return okMsg; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |             } catch (error) { | ||||||
|  |                 throwGeneralAxiosError(error) | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|         } else { |         } else { | ||||||
|             throw new Error("Notification type is not supported") |             throw new Error("Notification type is not supported") | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -13,33 +13,16 @@ | ||||||
|                         <div class="mb-3"> |                         <div class="mb-3"> | ||||||
|                             <label for="type" class="form-label">Notification Type</label> |                             <label for="type" class="form-label">Notification Type</label> | ||||||
|                             <select id="type" v-model="notification.type" class="form-select"> |                             <select id="type" v-model="notification.type" class="form-select"> | ||||||
|                                 <option value="telegram"> |                                 <option value="telegram">Telegram</option> | ||||||
|                                     Telegram |                                 <option value="webhook">Webhook</option> | ||||||
|                                 </option> |                                 <option value="smtp">Email (SMTP)</option> | ||||||
|                                 <option value="webhook"> |                                 <option value="discord">Discord</option> | ||||||
|                                     Webhook |                                 <option value="signal">Signal</option> | ||||||
|                                 </option> |                                 <option value="gotify">Gotify</option> | ||||||
|                                 <option value="smtp"> |                                 <option value="slack">Slack</option> | ||||||
|                                     Email (SMTP) |                                 <option value="pushover">Pushover</option> | ||||||
|                                 </option> |                                 <option value="lunasea">LunaSea</option> | ||||||
|                                 <option value="discord"> |                                 <option value="apprise">Apprise (Support 50+ Notification services)</option> | ||||||
|                                     Discord |  | ||||||
|                                 </option> |  | ||||||
|                                 <option value="signal"> |  | ||||||
|                                     Signal |  | ||||||
|                                 </option> |  | ||||||
|                                 <option value="gotify"> |  | ||||||
|                                     Gotify |  | ||||||
|                                 </option> |  | ||||||
|                                 <option value="slack"> |  | ||||||
|                                     Slack |  | ||||||
|                                 </option> |  | ||||||
|                                 <option value="pushover"> |  | ||||||
|                                     Pushover |  | ||||||
|                                 </option> |  | ||||||
|                                 <option value="apprise"> |  | ||||||
|                                     Apprise (Support 50+ Notification services) |  | ||||||
|                                 </option> |  | ||||||
|                             </select> |                             </select> | ||||||
|                         </div> |                         </div> | ||||||
| 
 | 
 | ||||||
|  | @ -323,6 +306,17 @@ | ||||||
|                                 </p> |                                 </p> | ||||||
|                             </div> |                             </div> | ||||||
|                         </template> |                         </template> | ||||||
|  | 
 | ||||||
|  |                         <template v-if="notification.type === 'lunasea'"> | ||||||
|  |                             <div class="mb-3"> | ||||||
|  |                                 <label for="lunasea-device" class="form-label">LunaSea Device ID<span style="color:red;"><sup>*</sup></span></label> | ||||||
|  |                                 <input id="lunasea-device" v-model="notification.lunaseaDevice" type="text" class="form-control" required> | ||||||
|  |                                 <div class="form-text"> | ||||||
|  |                                     <p><span style="color:red;"><sup>*</sup></span>Required</p> | ||||||
|  |                                 </div> | ||||||
|  |                             </div> | ||||||
|  |                         </template> | ||||||
|  | 
 | ||||||
|                     </div> |                     </div> | ||||||
|                     <div class="modal-footer"> |                     <div class="modal-footer"> | ||||||
|                         <button v-if="id" type="button" class="btn btn-danger" :disabled="processing" @click="deleteConfirm"> |                         <button v-if="id" type="button" class="btn btn-danger" :disabled="processing" @click="deleteConfirm"> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue