diff --git a/.drone.yml b/.drone.yml index 0ddf9fa4..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: @@ -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/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) diff --git a/upload-releases.sh b/upload-releases.sh new file mode 100755 index 00000000..7239ab3c --- /dev/null +++ b/upload-releases.sh @@ -0,0 +1,24 @@ +#!/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 +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" +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