diff options
author | Wim <wim@42.be> | 2019-06-01 00:53:49 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2019-06-02 09:35:20 +0100 |
commit | 40f1d35415f5e3638a1972b4aa56365070d5ccb3 (patch) | |
tree | e7ec1cd0638436c61367448736f94e7fc0793a1e /vendor/maunium.net/go/mautrix-whatsapp/whatsapp-ext/jsonmessage.go | |
parent | b79bf7d4143f7a962faa00e10c2d6705524607ee (diff) | |
download | matterbridge-msglm-40f1d35415f5e3638a1972b4aa56365070d5ccb3.tar.gz matterbridge-msglm-40f1d35415f5e3638a1972b4aa56365070d5ccb3.tar.bz2 matterbridge-msglm-40f1d35415f5e3638a1972b4aa56365070d5ccb3.zip |
Fix go mod issue by removing whatsapp-ext
Diffstat (limited to 'vendor/maunium.net/go/mautrix-whatsapp/whatsapp-ext/jsonmessage.go')
-rw-r--r-- | vendor/maunium.net/go/mautrix-whatsapp/whatsapp-ext/jsonmessage.go | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/vendor/maunium.net/go/mautrix-whatsapp/whatsapp-ext/jsonmessage.go b/vendor/maunium.net/go/mautrix-whatsapp/whatsapp-ext/jsonmessage.go deleted file mode 100644 index 11748443..00000000 --- a/vendor/maunium.net/go/mautrix-whatsapp/whatsapp-ext/jsonmessage.go +++ /dev/null @@ -1,102 +0,0 @@ -// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. -// Copyright (C) 2019 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see <https://www.gnu.org/licenses/>. - -package whatsappExt - -import ( - "encoding/json" - - "github.com/Rhymen/go-whatsapp" -) - -type JSONMessage []json.RawMessage - -type JSONMessageType string - -const ( - MessageMsgInfo JSONMessageType = "MsgInfo" - MessageMsg JSONMessageType = "Msg" - MessagePresence JSONMessageType = "Presence" - MessageStream JSONMessageType = "Stream" - MessageConn JSONMessageType = "Conn" - MessageProps JSONMessageType = "Props" - MessageCmd JSONMessageType = "Cmd" - MessageChat JSONMessageType = "Chat" -) - -func (ext *ExtendedConn) AddHandler(handler whatsapp.Handler) { - ext.Conn.AddHandler(handler) - ext.handlers = append(ext.handlers, handler) -} - -func (ext *ExtendedConn) HandleError(error) {} - -type UnhandledJSONMessageHandler interface { - whatsapp.Handler - HandleUnhandledJSONMessage(string) -} - -type JSONParseErrorHandler interface { - whatsapp.Handler - HandleJSONParseError(error) -} - -func (ext *ExtendedConn) jsonParseError(err error) { - for _, handler := range ext.handlers { - errorHandler, ok := handler.(JSONParseErrorHandler) - if !ok { - continue - } - errorHandler.HandleJSONParseError(err) - } -} - -func (ext *ExtendedConn) HandleJsonMessage(message string) { - msg := JSONMessage{} - err := json.Unmarshal([]byte(message), &msg) - if err != nil || len(msg) < 2 { - ext.jsonParseError(err) - return - } - - var msgType JSONMessageType - json.Unmarshal(msg[0], &msgType) - - switch msgType { - case MessagePresence: - ext.handleMessagePresence(msg[1]) - case MessageStream: - ext.handleMessageStream(msg[1:]) - case MessageConn: - ext.handleMessageConn(msg[1]) - case MessageProps: - ext.handleMessageProps(msg[1]) - case MessageMsgInfo, MessageMsg: - ext.handleMessageMsgInfo(msgType, msg[1]) - case MessageCmd: - ext.handleMessageCommand(msg[1]) - case MessageChat: - ext.handleMessageChatUpdate(msg[1]) - default: - for _, handler := range ext.handlers { - ujmHandler, ok := handler.(UnhandledJSONMessageHandler) - if !ok { - continue - } - ujmHandler.HandleUnhandledJSONMessage(message) - } - } -} |