Skip to content

Commit

Permalink
#59 [FEATURE REQUEST]
Browse files Browse the repository at this point in the history
• renamed Environment Variables
  • Loading branch information
androidseb25 committed May 27, 2024
1 parent 221186f commit d75ea28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Models/DeviceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace iGotify_Notification_Assist.Models;

public class DeviceModel
{
public string ClientToken { get; set; }
public string DeviceToken { get; set; }
public string GotifyUrl { get; set; }
public string ClientToken { get; set; } = "";
public string DeviceToken { get; set; } = "";
public string GotifyUrl { get; set; } = "";

/// <summary>
/// Add device token to txt file
Expand Down
28 changes: 14 additions & 14 deletions Services/GotifySocketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,21 @@ public async void Start()

// [FEATURE REQUEST] #59 - https://github.com/androidseb25/iGotify-Notification-Assistent/issues/59
// First try of implementing local running instances without app configuration
var gotifyServers = Environment.GetEnvironmentVariable("GOTIFY_SERVERS") ?? "";
var gotifyClientTokens = Environment.GetEnvironmentVariable("GOTIFY_CLIENTS") ?? "";
var ntfyTokens = Environment.GetEnvironmentVariable("NTFY_TOKENS") ?? "";
var gotifyUrls = Environment.GetEnvironmentVariable("GOTIFY_URLS") ?? "";
var gotifyClientTokens = Environment.GetEnvironmentVariable("GOTIFY_CLIENT_TOKENS") ?? "";
var secntfyTokens = Environment.GetEnvironmentVariable("SECNTFY_TOKENS") ?? "";

var gotifyServerList = new List<string>();
var gotifyUrlList = new List<string>();
var gotifyClientList = new List<string>();
var ntfyTokenList = new List<string>();
var secntfyTokenList = new List<string>();

if (gotifyServers.Length > 0 && gotifyClientTokens.Length > 0 && ntfyTokens.Length > 0)
if (gotifyUrls.Length > 0 && gotifyClientTokens.Length > 0 && secntfyTokens.Length > 0)
{
try
{
gotifyServerList = gotifyServers.Split(";").ToList();
gotifyUrlList = gotifyUrls.Split(";").ToList();
gotifyClientList = gotifyClientTokens.Split(";").ToList();
ntfyTokenList = ntfyTokens.Split(";").ToList();
secntfyTokenList = secntfyTokens.Split(";").ToList();

var clientCounter = 0;
foreach (string client in gotifyClientList)
Expand All @@ -116,8 +116,8 @@ public async void Start()
dm.ClientToken = client;
if (!await DatabaseService.CheckIfUserExists(dm))
{
dm.GotifyUrl = gotifyServerList.ElementAt(clientCounter);
dm.DeviceToken = ntfyTokenList.ElementAt(clientCounter);
dm.GotifyUrl = gotifyUrlList.ElementAt(clientCounter);
dm.DeviceToken = secntfyTokenList.ElementAt(clientCounter);
if (!await DatabaseService.InsertUser(dm))
{
throw new ApplicationException("Insert Database Exception!");
Expand All @@ -136,12 +136,12 @@ public async void Start()
}
else
{
var statusServerList = gotifyServerList.Count == 0 ? "empty" : "filled";
Console.WriteLine($"Gotify Server list is: {statusServerList}");
var statusServerList = gotifyUrlList.Count == 0 ? "empty" : "filled";
Console.WriteLine($"Gotify Url list is: {statusServerList}");
var statusClientList = gotifyClientList.Count == 0 ? "empty" : "filled";
Console.WriteLine($"Gotify Client list is: {statusClientList}");
var statusNtfyList = ntfyTokenList.Count == 0 ? "empty" : "filled";
Console.WriteLine($"NTFY Token list is: {statusNtfyList}");
var statusNtfyList = secntfyTokenList.Count == 0 ? "empty" : "filled";
Console.WriteLine($"SecNtfy Token list is: {statusNtfyList}");
Console.WriteLine($"If one or more lists are empty please check the environment variable! GOTIFY_SERVERS or GOTIFY_CLIENTS or NTFY_TOKENS");
Console.WriteLine($"If all lists are empty do nothing, you will configure the gotify server over the iGotify app.");
}
Expand Down

0 comments on commit d75ea28

Please sign in to comment.