From caf85f337bbbbeb0e04f602e3a0db59aacc80139 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Fri, 23 Feb 2024 13:06:26 -0800 Subject: [PATCH 1/4] Automatically Upload Nightly Artifacts if a Release is Cut --- .drone.yml | 2 ++ upload-releases.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 upload-releases.sh diff --git a/.drone.yml b/.drone.yml index 0ddf9fa4..c684aedf 100644 --- a/.drone.yml +++ b/.drone.yml @@ -139,6 +139,8 @@ steps: - scp -r -o StrictHostKeyChecking=no -i ~/id_rsa $DIR buildfiles@build.openprivacy.ca:/home/buildfiles/buildfiles/ - ./gen-nightly-index.sh $DIR - scp -r -o StrictHostKeyChecking=no -i ~/id_rsa cwtch-nightly.html buildfiles@build.openprivacy.ca:/home/buildfiles/buildfiles/ + # Upload Files to releases...if a release has been cut... + - ./uploaded-releases.sh deploy/cwtch-`cat VERSION`.apk application/vnd.android.package-archive - name: notify-gogs image: openpriv/drone-gogs diff --git a/upload-releases.sh b/upload-releases.sh new file mode 100755 index 00000000..af4e50a6 --- /dev/null +++ b/upload-releases.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +VERSION=$(cat VERSION) +echo "Grabbing Release Data From:" "https://git.openprivacy.ca/api/v1/repos/$DRONE_REPO/releases/tags/$VERSION" +RELEASEID=$(curl -s -X 'GET' "https://git.openprivacy.ca/api/v1/repos/$DRONE_REPO/releases/tags/$VERSION" -H 'accept: application/json' | jq '.id') +echo $RELEASEID + +URL="$PLUGIN_GOGS_URL/api/v1/repos/$DRONE_REPO/releases/$RELEASEID/assets?name=$1" +FILE="@$1" +RESULT=$(curl -o /dev/null -w "%{http_code}" -X POST -H "Authorization: token $GOGS_ACCOUNT_TOKEN" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "attachment=$FILE;type=$2" $URL) + + +if [ $RESULT -eq 201 ] +then + echo "Success posting to $URL" +else + echo "ERROR HTTP $RESULT posting to $URL" + exit 1 +fi From 5627f6a438ce9ede88bb0c138a07ec8a80b51c34 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Fri, 23 Feb 2024 13:48:05 -0800 Subject: [PATCH 2/4] Used drone-gogs for building --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index c684aedf..6bcd7254 100644 --- a/.drone.yml +++ b/.drone.yml @@ -115,7 +115,7 @@ steps: - genhtml coverage/lcov.info -o coverage/html - name: deploy-buildfiles - image: kroniak/ssh-client + image: openpriv/drone-gogs pull: if-not-exists environment: BUILDFILES_KEY: From 11e7e58109939ddbccfed346c519b05b2a6ea332 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Fri, 23 Feb 2024 15:05:59 -0800 Subject: [PATCH 3/4] Fix Notifications for ConversationInfor --- .../kotlin/im/cwtch/flwtch/FlwtchWorker.kt | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt index f9e05bec..66f429ff 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt @@ -23,6 +23,13 @@ import io.flutter.FlutterInjector import org.json.JSONObject import java.nio.file.Files import java.nio.file.Paths +import java.io.FileInputStream + + +import java.io.File + + + class FlwtchWorker(context: Context, parameters: WorkerParameters) : CoroutineWorker(context, parameters) { @@ -138,7 +145,19 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : Log.i(TAG, "notification for " + evt.EventType + " " + handle + " " + conversationId + " " + channelId) Log.i(TAG, data.toString()); val key = loader.getLookupKeyForAsset(data.getString("picture"))//"assets/profiles/001-centaur.png") - val fh = applicationContext.assets.open(key) + var fh : java.io.InputStream? = null; + try { + fh = applicationContext.assets.open(key) + } catch (e: Exception) { + Log.d("FlwtchWorker->ContactInfo", e.toString() + " :: " + e.getStackTrace()); + } + + try { + val file = File(data.getString("picture")) + fh = FileInputStream(file) + } catch (e: Exception) { + Log.d("FlwtchWorker->ContactInfo", e.toString() + " :: " + e.getStackTrace()); + } val clickIntent = Intent(applicationContext, MainActivity::class.java).also { intent -> intent.action = Intent.ACTION_RUN @@ -146,12 +165,12 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : intent.putExtra("ProfileOnion", data.getString("ProfileOnion")) intent.putExtra("Handle", handle) } - + val image : android.graphics.Bitmap? = if (fh != null) BitmapFactory.decodeStream(fh ) else null; val newNotification = NotificationCompat.Builder(applicationContext, channelId) .setContentTitle(data.getString("Nick")) .setContentText((notificationConversationInfo ?: "New Message From %1").replace("%1", data.getString("Nick"))) - .setLargeIcon(BitmapFactory.decodeStream(fh)) + .setLargeIcon(image) .setSmallIcon(R.mipmap.knott_transparent) .setContentIntent(PendingIntent.getActivity(applicationContext, 1, clickIntent, flags)) .setAutoCancel(true) From 098adc46e6374506b31909a0d2d58a990bffb590 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Fri, 23 Feb 2024 20:36:14 -0800 Subject: [PATCH 4/4] Add Check for Empty Release and Exit Early --- upload-releases.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/upload-releases.sh b/upload-releases.sh index af4e50a6..7239ab3c 100755 --- a/upload-releases.sh +++ b/upload-releases.sh @@ -4,6 +4,11 @@ VERSION=$(cat VERSION) echo "Grabbing Release Data From:" "https://git.openprivacy.ca/api/v1/repos/$DRONE_REPO/releases/tags/$VERSION" RELEASEID=$(curl -s -X 'GET' "https://git.openprivacy.ca/api/v1/repos/$DRONE_REPO/releases/tags/$VERSION" -H 'accept: application/json' | jq '.id') echo $RELEASEID +if [ "$RELEASEID" = "null" ]; then + # $var is empty + exit 1 +fi + URL="$PLUGIN_GOGS_URL/api/v1/repos/$DRONE_REPO/releases/$RELEASEID/assets?name=$1" FILE="@$1"