From e633d6f29c76d32498ec65e8797435de04c97404 Mon Sep 17 00:00:00 2001 From: Egor Date: Fri, 16 Jan 2026 00:04:30 -0800 Subject: [PATCH] fix CI, clean up java --- .../java/com/lonecloud/sup/util/Emoji.java | 29 -------- .../com/lonecloud/sup/util/EmojiLoader.java | 70 ------------------- .../com/lonecloud/sup/util/EmojiManager.java | 46 ------------ proton-bridge/src/index.ts | 14 ++-- 4 files changed, 10 insertions(+), 149 deletions(-) delete mode 100644 android/app/src/main/java/com/lonecloud/sup/util/Emoji.java delete mode 100644 android/app/src/main/java/com/lonecloud/sup/util/EmojiLoader.java delete mode 100644 android/app/src/main/java/com/lonecloud/sup/util/EmojiManager.java diff --git a/android/app/src/main/java/com/lonecloud/sup/util/Emoji.java b/android/app/src/main/java/com/lonecloud/sup/util/Emoji.java deleted file mode 100644 index 12960ea..0000000 --- a/android/app/src/main/java/com/lonecloud/sup/util/Emoji.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.heckel.ntfy.util; - -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.List; - -/** - * This class represents an emoji. - * - * This class was originally written by Vincent DURMONT (vdurmont@gmail.com) as part of - * https://github.com/vdurmont/emoji-java, but has since been heavily stripped and modified. - */ -public class Emoji { - private final List aliases; - private final String unicode; - - protected Emoji(List aliases, byte... bytes) { - this.aliases = Collections.unmodifiableList(aliases); - this.unicode = new String(bytes, StandardCharsets.UTF_8); - } - - public List getAliases() { - return this.aliases; - } - - public String getUnicode() { - return this.unicode; - } -} diff --git a/android/app/src/main/java/com/lonecloud/sup/util/EmojiLoader.java b/android/app/src/main/java/com/lonecloud/sup/util/EmojiLoader.java deleted file mode 100644 index 1271263..0000000 --- a/android/app/src/main/java/com/lonecloud/sup/util/EmojiLoader.java +++ /dev/null @@ -1,70 +0,0 @@ -package io.heckel.ntfy.util; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - -/** - * Loads the emojis from a JSON database. - * - * This was originally written to load - * https://github.com/vdurmont/emoji-java/blob/master/src/main/resources/emojis.json - * - * But now uses - * https://github.com/github/gemoji/blob/master/db/emoji.json - * - * This class was originally written by Vincent DURMONT (vdurmont@gmail.com) as part of - * https://github.com/vdurmont/emoji-java, but has since been heavily stripped and modified. - */ -public class EmojiLoader { - public static List loadEmojis(InputStream stream) throws IOException, JSONException { - JSONArray emojisJSON = new JSONArray(inputStreamToString(stream)); - List emojis = new ArrayList(emojisJSON.length()); - for (int i = 0; i < emojisJSON.length(); i++) { - Emoji emoji = buildEmojiFromJSON(emojisJSON.getJSONObject(i)); - if (emoji != null) { - emojis.add(emoji); - } - } - return emojis; - } - - private static String inputStreamToString( - InputStream stream - ) throws IOException { - StringBuilder sb = new StringBuilder(); - InputStreamReader isr = new InputStreamReader(stream, StandardCharsets.UTF_8); - BufferedReader br = new BufferedReader(isr); - String read; - while((read = br.readLine()) != null) { - sb.append(read); - } - br.close(); - return sb.toString(); - } - - protected static Emoji buildEmojiFromJSON( - JSONObject json - ) throws JSONException { - if (!json.has("emoji")) { - return null; - } - - byte[] bytes = json.getString("emoji").getBytes(StandardCharsets.UTF_8); - List aliases = jsonArrayToStringList(json.getJSONArray("aliases")); - return new Emoji(aliases, bytes); - } - - private static List jsonArrayToStringList(JSONArray array) throws JSONException { - List strings = new ArrayList(array.length()); - for (int i = 0; i < array.length(); i++) { - strings.add(array.getString(i)); - } - return strings; - } -} diff --git a/android/app/src/main/java/com/lonecloud/sup/util/EmojiManager.java b/android/app/src/main/java/com/lonecloud/sup/util/EmojiManager.java deleted file mode 100644 index d0e763d..0000000 --- a/android/app/src/main/java/com/lonecloud/sup/util/EmojiManager.java +++ /dev/null @@ -1,46 +0,0 @@ -package io.heckel.ntfy.util; - -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Holds the loaded emojis and provides search functions. - * - * This class was originally written by Vincent DURMONT (vdurmont@gmail.com) as part of - * https://github.com/vdurmont/emoji-java, but has since been heavily stripped and modified. - */ -public class EmojiManager { - private static final String PATH = "/emoji.json"; // https://github.com/github/gemoji/blob/master/db/emoji.json - private static final Map EMOJIS_BY_ALIAS = new HashMap(); - - static { - try { - InputStream stream = EmojiLoader.class.getResourceAsStream(PATH); - List emojis = EmojiLoader.loadEmojis(stream); - for (Emoji emoji : emojis) { - for (String alias : emoji.getAliases()) { - EMOJIS_BY_ALIAS.put(alias, emoji); - } - } - stream.close(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static Emoji getForAlias(String alias) { - if (alias == null || alias.isEmpty()) { - return null; - } - return EMOJIS_BY_ALIAS.get(trimAlias(alias)); - } - - private static String trimAlias(String alias) { - int len = alias.length(); - return alias.substring( - alias.charAt(0) == ':' ? 1 : 0, - alias.charAt(len - 1) == ':' ? len - 1 : len); - } -} diff --git a/proton-bridge/src/index.ts b/proton-bridge/src/index.ts index a3c5181..51b3d2f 100644 --- a/proton-bridge/src/index.ts +++ b/proton-bridge/src/index.ts @@ -1,5 +1,5 @@ -import Imap from 'imap'; import chalk from 'chalk'; +import Imap from 'imap'; const PROTON_BRIDGE_HOST = process.env.PROTON_BRIDGE_HOST || 'protonmail-bridge'; const PROTON_BRIDGE_PORT = Number.parseInt(process.env.PROTON_BRIDGE_PORT || '143', 10); @@ -14,15 +14,21 @@ const VERBOSE = process.env.VERBOSE === 'true'; const log = (...args: unknown[]) => VERBOSE && console.log(...args); if (!BRIDGE_IMAP_USERNAME || !BRIDGE_IMAP_PASSWORD) { - console.error(chalk.red('Missing required env vars: BRIDGE_IMAP_USERNAME and BRIDGE_IMAP_PASSWORD')); console.error( - chalk.yellow('Run: docker run --rm -it -v proton-bridge-data:/root shenxn/protonmail-bridge init'), + chalk.red('Missing required env vars: BRIDGE_IMAP_USERNAME and BRIDGE_IMAP_PASSWORD'), + ); + console.error( + chalk.yellow( + 'Run: docker run --rm -it -v proton-bridge-data:/root shenxn/protonmail-bridge init', + ), ); console.error(chalk.yellow('Then use `login` and `info` commands to get IMAP credentials')); process.exit(1); } -console.log(chalk.blue(`🔗 Connecting to Proton Bridge at ${PROTON_BRIDGE_HOST}:${PROTON_BRIDGE_PORT}`)); +console.log( + chalk.blue(`🔗 Connecting to Proton Bridge at ${PROTON_BRIDGE_HOST}:${PROTON_BRIDGE_PORT}`), +); console.log(chalk.blue(`📨 Monitoring mailbox: ${BRIDGE_IMAP_USERNAME}`)); console.log(chalk.blue(`🔔 Sending notifications to: ${SUP_SERVER_URL}/notify/${SUP_TOPIC}`));