| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-04-28 14:14:45 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-04-28 14:14:45 UTC |
| parent | 47b99c0448e07a40ceca35c574bc64fe3c350406 |
| borogove/Status.hx | +36 | -0 |
diff --git a/borogove/Status.hx b/borogove/Status.hx new file mode 100644 index 0000000..d377a5a --- /dev/null +++ b/borogove/Status.hx @@ -0,0 +1,36 @@ +package borogove; + +#if cpp +import HaxeCBridge; +#end + +@:expose +@:nullSafety(StrictThreaded) +#if cpp +@:build(HaxeCBridge.expose()) +@:build(HaxeSwiftBridge.expose()) +#end +class Status { + public final emoji: String; + public final text: String; + + public function new(emoji: String, text: String) { + this.emoji = emoji; + this.text = text; + } + + public function toString() { + return emoji + (emoji == "" || text == "" ? "" : " ") + text; + } + + public function toStanza() { + final s = new Stanza("activity", { xmlns: "http://jabber.org/protocol/activity" }); + if (text != "") s.textTag("text", text); + if (emoji == "") { + s.tag("undefined").tag("other").up().up(); + } else { + s.tag("undefined").textTag("emoji", emoji, { xmlns: "https://ns.borogove.dev/" }).up(); + } + return s; + } +}