@@ -9,13 +9,6 @@ namespace iGotify_Notification_Assist.Controller;
99[ Route ( "[controller]" ) ]
1010public class DeviceController : ControllerBase
1111{
12- private readonly ILogger < DeviceController > _logger ;
13-
14- public DeviceController ( ILogger < DeviceController > logger )
15- {
16- _logger = logger ;
17- }
18-
1912 /// <summary>
2013 /// Add device token to the TXT for sending the push notificcation
2114 /// </summary>
@@ -24,17 +17,17 @@ public DeviceController(ILogger<DeviceController> logger)
2417 [ HttpPost ]
2518 public async Task < IActionResult > PostDeviceModel ( DeviceModel deviceModel )
2619 {
27- string result = "" ;
28- bool resultBool = false ;
20+ string result ;
21+ bool resultBool ;
2922
3023 Console . WriteLine ( $ "ClientToken: { deviceModel . ClientToken } ") ;
3124 Console . WriteLine ( $ "DeviceToken: { deviceModel . DeviceToken } ") ;
3225 Console . WriteLine ( $ "GotifyUrl: { deviceModel . GotifyUrl } ") ;
3326
3427 if (
35- deviceModel . ClientToken ! . Length == 0 || deviceModel . ClientToken == "string" ||
36- deviceModel . DeviceToken ! . Length == 0 || deviceModel . DeviceToken . Length < 60 || deviceModel . DeviceToken == "string" ||
37- deviceModel . GotifyUrl ! . Length == 0 || deviceModel . GotifyUrl == "string"
28+ deviceModel . ClientToken . Length == 0 || deviceModel . ClientToken == "string" ||
29+ deviceModel . DeviceToken . Length == 0 || deviceModel . DeviceToken . Length < 60 || deviceModel . DeviceToken == "string" ||
30+ deviceModel . GotifyUrl . Length == 0 || deviceModel . GotifyUrl == "string"
3831 )
3932 {
4033 result = "Fehler beim hinzugefügen des Gerätes!" ;
@@ -44,8 +37,8 @@ public async Task<IActionResult> PostDeviceModel(DeviceModel deviceModel)
4437
4538 if ( await deviceModel . Insert ( ) )
4639 {
47- GotifySocketService gss = GotifySocketService . getInstance ( ) ;
48- gss . StartWSThread ( deviceModel . GotifyUrl , deviceModel . ClientToken ) ;
40+ GotifySocketService . getInstance ( ) ;
41+ GotifySocketService . StartWsThread ( deviceModel . GotifyUrl , deviceModel . ClientToken ) ;
4942 result = "Gerät erfolgreich hinzugefügt" ;
5043 resultBool = true ;
5144 } else {
@@ -64,8 +57,8 @@ public async Task<IActionResult> PostDeviceModel(DeviceModel deviceModel)
6457 [ HttpDelete ]
6558 public async Task < IActionResult > DeleteDevcice ( string token )
6659 {
67- string result = "" ;
68- bool resultBool = false ;
60+ string result ;
61+ bool resultBool ;
6962
7063 Console . WriteLine ( $ "Delete Token: { token } ") ;
7164 if ( token . Length == 0 || token == "string" )
@@ -75,15 +68,14 @@ public async Task<IActionResult> DeleteDevcice(string token)
7568 return Ok ( new { Message = result , Successful = resultBool } ) ;
7669 }
7770
78- DeviceModel deviceModel = new DeviceModel ( ) ;
79- deviceModel . ClientToken = token ;
80- Users usr = await DatabaseService . GetUser ( token ) ;
71+ var deviceModel = new DeviceModel { ClientToken = token } ;
72+ var usr = await DatabaseService . GetUser ( token ) ;
8173 if ( await deviceModel . Delete ( ) )
8274 {
8375 if ( usr . Uid > 0 )
8476 {
85- GotifySocketService gss = GotifySocketService . getInstance ( ) ;
86- gss . KillWsThread ( usr . ClientToken ) ;
77+ GotifySocketService . getInstance ( ) ;
78+ GotifySocketService . KillWsThread ( usr . ClientToken ) ;
8779 }
8880
8981 result = "Gerät erfolgreich gelöscht" ;
@@ -99,9 +91,9 @@ public async Task<IActionResult> DeleteDevcice(string token)
9991 [ HttpGet ( "Test/{deviceToken}" ) ]
10092 public async Task < IActionResult > Test ( string deviceToken )
10193 {
102- SecNtfy ntfy = new SecNtfy ( Environment . GetEnvironmentVariable ( "SECNTFY_SERVER_URL" ) ?? "https://api.secntfy.app" ) ;
94+ var ntfy = new SecNtfy ( Environment . GetEnvironmentVariable ( "SECNTFY_SERVER_URL" ) ?? "https://api.secntfy.app" ) ;
10395 if ( deviceToken . Length > 0 )
104- _ = await ntfy . SendNotification ( deviceToken , "Test" , "Test Nachricht" , false , "" , 0 ) ;
96+ _ = await ntfy . SendNotification ( deviceToken , "Test" , "Test Nachricht" ) ;
10597 Console . WriteLine ( ntfy . encTitle ) ;
10698
10799 return Ok ( ) ;
0 commit comments