diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 51ff732..34c0e29 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,6 +27,18 @@ jobs: uses: docker/setup-buildx-action@v3 with: version: latest + - name: Get version informations + id: infos + run: | + versionGit=${{ steps.get-latest-tag.outputs.tag }} + versionProject=v$(grep '' 'iGotify Notification Assist.csproj' | cut -d '>' -f2 | cut -d '<' -f1 | xargs) + if [ "$versionGit" != "$versionProject" -a $(git tag | grep -c "$versionProject") -eq 0 ]; then + echo "version=$versionProject" >> $GITHUB_OUTPUT + echo "createtag=true" >> $GITHUB_OUTPUT + exit 0 + fi + echo "version=$versionGit" >> $GITHUB_OUTPUT + echo "createtag=false" >> $GITHUB_OUTPUT - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: @@ -36,11 +48,11 @@ jobs: - name: Run Buildx & Push Multi Arch for dev if: steps.extract_branch.outputs.branch == 'dev' run: | - docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t ghcr.io/androidseb25/igotify-notification-assist-dev:latest -f ./Dockerfile --provenance=false --sbom=false --output type=image,push=true . + docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t ghcr.io/androidseb25/igotify-notification-assist-dev:latest -t ghcr.io/androidseb25/igotify-notification-assist-dev:${{ steps.infos.outputs.version }} -f ./Dockerfile --provenance=false --sbom=false --output type=image,push=true . - name: Run Buildx & Push Multi Arch for public if: steps.extract_branch.outputs.branch != 'dev' run: | - docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t ghcr.io/androidseb25/igotify-notification-assist:latest -f ./Dockerfile --provenance=false --sbom=false --output type=image,push=true . + docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t ghcr.io/androidseb25/igotify-notification-assist:latest -t ghcr.io/androidseb25/igotify-notification-assist:${{ steps.infos.outputs.version }} -f ./Dockerfile --provenance=false --sbom=false --output type=image,push=true . - name: Gotify Notification SUCCESS if: success() uses: eikendev/gotify-action@master diff --git a/Models/CustomHeaders.cs b/Models/CustomHeaders.cs index 218df8e..b1f7cf3 100644 --- a/Models/CustomHeaders.cs +++ b/Models/CustomHeaders.cs @@ -2,6 +2,6 @@ namespace iGotify_Notification_Assist.Models; public class CustomHeaders { - public string Key { get; set; } - public string Value { get; set; } + public string? Key { get; set; } + public string? Value { get; set; } } \ No newline at end of file diff --git a/README.md b/README.md index 21a1304..f61b67c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ [![Donate with PayPal](https://raw.githubusercontent.com/androidseb25/iGotify-Notification-Assistent/main/paypal-donate-icon-7_20.png)](https://www.paypal.com/donate/?hosted_button_id=VFSL9ZECRD6D6) ![Stars](https://img.shields.io/github/stars/androidseb25/iGotify-Notification-Assistent?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAEsWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS41LjAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgIHhtbG5zOnBob3Rvc2hvcD0iaHR0cDovL25zLmFkb2JlLmNvbS9waG90b3Nob3AvMS4wLyIKICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIKICAgIHhtbG5zOnhtcE1NPSJod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UVORK5CYII=) [![Crowdin](https://badges.crowdin.net/igotify/localized.svg)](https://crowdin.com/project/igotify) -[![Qodana](https://github.com/androidseb25/iGotify-Notification-Assistent/actions/workflows/code_quality.yml/badge.svg?branch=main)](https://github.com/androidseb25/iGotify-Notification-Assistent/actions/workflows/code_quality.yml) # iGotify diff --git a/Services/DatabaseService.cs b/Services/DatabaseService.cs index 0731d7f..0cb59c7 100644 --- a/Services/DatabaseService.cs +++ b/Services/DatabaseService.cs @@ -25,7 +25,7 @@ public static bool CreateDatebase(string path) // Create a sample table const string createTableQuery = - "create table if not exists Users (Uid integer primary key, ClientToken text not null, DeviceToken text not null, Headers text not null);"; + "create table if not exists Users (Uid integer primary key, ClientToken text not null, DeviceToken text not null, GotifyUrl text not null, Headers text not null);"; dbConnection.Execute(createTableQuery); // Perform other database operations as needed diff --git a/Services/GotifySocketService.cs b/Services/GotifySocketService.cs index 550d0be..cbad7e6 100644 --- a/Services/GotifySocketService.cs +++ b/Services/GotifySocketService.cs @@ -37,7 +37,7 @@ public void Init() isInit = isDbFileExists; } - public static async void KillWsThread(string clientToken) + public static void KillWsThread(string clientToken) { if (_threadSockets != null) { @@ -47,24 +47,24 @@ public static async void KillWsThread(string clientToken) try { // 1) Signal termination - threadSocket.cts.Cancel(); + threadSocket.cts?.Cancel(); // 2) If you have a WebSocket, close it actively so that blocking reads wake up threadSocket.ws!.Stop(); // 3) Wait for thread end (short timeout so nothing hangs) - if (threadSocket.thread.IsAlive) + if (threadSocket.thread!.IsAlive) threadSocket.thread.Join(millisecondsTimeout: 500); } finally { - threadSocket.cts.Dispose(); + threadSocket.cts?.Dispose(); _threadSockets.Remove(threadSocket); } } } - public static async void KillAllWsThread() + public static void KillAllWsThread() { if (_threadSockets != null) { @@ -73,13 +73,13 @@ public static async void KillAllWsThread() try { // 1) Signal termination - threadSocket.cts.Cancel(); + threadSocket.cts?.Cancel(); // 2) If you have a WebSocket, close it actively so that blocking reads wake up threadSocket.ws!.Stop(); // 3) Wait for thread end (short timeout so nothing hangs) - if (threadSocket.thread.IsAlive) + if (threadSocket.thread!.IsAlive) threadSocket.thread.Join(millisecondsTimeout: 500); } catch (Exception e) @@ -88,7 +88,7 @@ public static async void KillAllWsThread() } finally { - threadSocket.cts.Dispose(); + threadSocket.cts?.Dispose(); } } @@ -136,7 +136,7 @@ public static void StartWsThread(Users user) private static void StartWsConn(ThreadSocket threadSocket, Users user) { - while (!threadSocket.cts.IsCancellationRequested) + while (!threadSocket.cts!.IsCancellationRequested) { try { @@ -170,7 +170,7 @@ private static void StartWsConn(ThreadSocket threadSocket, Users user) private static void StartWsConn(ThreadSocket threadSocket, string gotifyServerUrl, string clientToken) { - while (!threadSocket.cts.IsCancellationRequested) + while (!threadSocket.cts!.IsCancellationRequested) { try { diff --git a/Services/WebSockClient.cs b/Services/WebSockClient.cs index 4243077..deb0d6a 100644 --- a/Services/WebSockClient.cs +++ b/Services/WebSockClient.cs @@ -30,6 +30,8 @@ public void Start(string clientToken, bool isRestart = false) var client = new ClientWebSocket(); foreach (var header in customHeaders) { + if (header.Key == null || header.Value == null) + continue; client.Options.SetRequestHeader(header.Key, header.Value); } diff --git a/iGotify Notification Assist.csproj b/iGotify Notification Assist.csproj index 7d4d562..66bda2c 100644 --- a/iGotify Notification Assist.csproj +++ b/iGotify Notification Assist.csproj @@ -6,9 +6,9 @@ enable true iGotify_Notification_Assist - 1.5.0.0 - 1.5.0.0 - 1.5.0.0 + 1.5.0.1 + 1.5.0.1 + 1.5.0.1 default @@ -19,8 +19,10 @@ - + + +