aboutsummaryrefslogtreecommitdiff
path: root/connector
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-10-04 21:20:22 +0200
committerAlex Auvolat <alex@adnab.me>2020-10-04 21:20:22 +0200
commit07f9f640f0f18541760adb8746cd563a504d6609 (patch)
tree5e8bc029ace33b826d63546677096a65fc570732 /connector
parent7130c7b7d6d0c4f49229df33825e2861eb463457 (diff)
downloadeasybridge-07f9f640f0f18541760adb8746cd563a504d6609.tar.gz
easybridge-07f9f640f0f18541760adb8746cd563a504d6609.zip
Looks like 2FA works in facebook messenger :o
Diffstat (limited to 'connector')
-rw-r--r--connector/connector.go4
-rw-r--r--connector/external/external.go13
-rw-r--r--connector/irc/irc.go4
-rw-r--r--connector/mattermost/mattermost.go4
-rw-r--r--connector/xmpp/xmpp.go4
5 files changed, 28 insertions, 1 deletions
diff --git a/connector/connector.go b/connector/connector.go
index 55e0e34..0819bd7 100644
--- a/connector/connector.go
+++ b/connector/connector.go
@@ -71,6 +71,10 @@ type Connector interface {
// in which case the backend is free to re-use the ID or select a new one.
Send(event *Event) (string, error)
+ // Used to send user commands directly
+ // (first use case: receive 2-factor authentication codes)
+ UserCommand(string)
+
// Close the connection
Close()
}
diff --git a/connector/external/external.go b/connector/external/external.go
index 9aae0f1..92339b9 100644
--- a/connector/external/external.go
+++ b/connector/external/external.go
@@ -51,10 +51,12 @@ const (
LEAVE = "leave"
SEARCH = "search"
SEND = "send"
+ USER_COMMAND = "user_command"
CLOSE = "close"
// external -> ezbr
SAVE_CONFIG = "save_config"
+ SYSTEM_MESSAGE = "system_message"
JOINED = "joined"
LEFT = "left"
USER_INFO_UPDATED = "user_info_updated"
@@ -249,7 +251,7 @@ func (m *extMessageWithData) UnmarshalJSON(jj []byte) error {
}
m.Data = sr.Data
return nil
- case JOINED, LEFT, CACHE_PUT, CACHE_GET, REP_OK, REP_ERROR:
+ case SYSTEM_MESSAGE, JOINED, LEFT, CACHE_PUT, CACHE_GET, REP_OK, REP_ERROR:
return nil
default:
return fmt.Errorf("Invalid message type for message from external program: '%s'", c.MsgType)
@@ -377,6 +379,8 @@ func (ext *External) handleCmd(msg *extMessageWithData) {
switch msg.MsgType {
case SAVE_CONFIG:
ext.handler.SaveConfig(msg.Data.(Configuration))
+ case SYSTEM_MESSAGE:
+ ext.handler.SystemMessage(msg.Value)
case JOINED:
ext.handler.Joined(msg.Room)
case LEFT:
@@ -475,3 +479,10 @@ func (ext *External) Send(event *Event) (string, error) {
}
return rep.EventId, nil
}
+
+func (ext *External) UserCommand(cm string) {
+ ext.cmd(extMessage{
+ MsgType: USER_COMMAND,
+ Value: cm,
+ }, nil)
+}
diff --git a/connector/irc/irc.go b/connector/irc/irc.go
index 77388e7..1327eaa 100644
--- a/connector/irc/irc.go
+++ b/connector/irc/irc.go
@@ -271,6 +271,10 @@ func (irc *IRC) Send(event *Event) (string, error) {
return "", nil
}
+func (irc *IRC) UserCommand(cm string) {
+ irc.handler.SystemMessage("Command not supported.")
+}
+
func (irc *IRC) Close() {
conn := irc.conn
irc.conn = nil
diff --git a/connector/mattermost/mattermost.go b/connector/mattermost/mattermost.go
index 9f8bbaf..86bf6b5 100644
--- a/connector/mattermost/mattermost.go
+++ b/connector/mattermost/mattermost.go
@@ -334,6 +334,10 @@ func (mm *Mattermost) Send(event *Event) (string, error) {
return created_post.Id, nil
}
+func (mm *Mattermost) UserCommand(cm string) {
+ mm.handler.SystemMessage("Command not supported.")
+}
+
func (mm *Mattermost) Close() {
if mm.conn != nil {
mm.conn.WsQuit = true
diff --git a/connector/xmpp/xmpp.go b/connector/xmpp/xmpp.go
index 64c53d9..2d0260c 100644
--- a/connector/xmpp/xmpp.go
+++ b/connector/xmpp/xmpp.go
@@ -367,6 +367,10 @@ func (xm *XMPP) Send(event *Event) (string, error) {
}
}
+func (xm *XMPP) UserCommand(cmd string) {
+ xm.handler.SystemMessage("Command not supported.")
+}
+
func (xm *XMPP) Close() {
if xm.conn != nil {
xm.conn.Close()