From ad5707408cca17130d3e8efa1eb298c0baad5618 Mon Sep 17 00:00:00 2001 From: Mark Joshwel Date: Wed, 19 Jun 2024 01:31:35 +0800 Subject: [PATCH] whatsapp: check comply, make native built default --- src/spow-whatsapp-bridge/bridge.go | 21 +++++++++++---------- src/spow-whatsapp-bridge/flake.nix | 5 +++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/spow-whatsapp-bridge/bridge.go b/src/spow-whatsapp-bridge/bridge.go index 5272b32..624d2dd 100644 --- a/src/spow-whatsapp-bridge/bridge.go +++ b/src/spow-whatsapp-bridge/bridge.go @@ -224,19 +224,20 @@ func parseJID(arg string) (types.JID, bool) { if arg[0] == '+' { arg = arg[1:] } + if !strings.ContainsRune(arg, '@') { return types.NewJID(arg, types.DefaultUserServer), true - } else { - recipient, err := types.ParseJID(arg) - if err != nil { - log.Errorf("s+ow-whatsapp-bridge: Invalid JID %s: %v", arg, err) - return recipient, false - } else if recipient.User == "" { - log.Errorf("s+ow-whatsapp-bridge: Invalid JID %s: no server specified", arg) - return recipient, false - } - return recipient, true } + + recipient, err := types.ParseJID(arg) + if err != nil { + log.Errorf("s+ow-whatsapp-bridge: Invalid JID %s: %v", arg, err) + return recipient, false + } else if recipient.User == "" { + log.Errorf("s+ow-whatsapp-bridge: Invalid JID %s: no server specified", arg) + return recipient, false + } + return recipient, true } func handleCmd(cmd string, args []string) { diff --git a/src/spow-whatsapp-bridge/flake.nix b/src/spow-whatsapp-bridge/flake.nix index ba5ef94..c99bb16 100644 --- a/src/spow-whatsapp-bridge/flake.nix +++ b/src/spow-whatsapp-bridge/flake.nix @@ -83,6 +83,7 @@ devShells.default = mkShell { buildInputs = [ go + golint gomod2nix.packages.${system}.default ]; }; @@ -99,8 +100,8 @@ ''; }; - # nix build .#native - packages.native = stdenvNoCC.mkDerivation { + # nix build + packages.default = stdenvNoCC.mkDerivation { pname = bridge.name; version = bridge.version; src = bridgeBuildNative;