diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-17 21:04:21 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-17 21:04:21 +0100 |
commit | 31bba8d946940df4858818f5efcc31cfd5a0a035 (patch) | |
tree | e9d2b7a6d6152fc45413648316a8ff7a514580b9 /connector | |
parent | 5ab2608ee8bd36b7c7b0d670d24b5851250e3887 (diff) | |
download | easybridge-31bba8d946940df4858818f5efcc31cfd5a0a035.tar.gz easybridge-31bba8d946940df4858818f5efcc31cfd5a0a035.zip |
Talking to Easybridge is now possible for some things
Diffstat (limited to 'connector')
-rw-r--r-- | connector/connector.go | 1 | ||||
-rw-r--r-- | connector/irc/irc.go | 8 | ||||
-rw-r--r-- | connector/xmpp/xmpp.go | 5 |
3 files changed, 12 insertions, 2 deletions
diff --git a/connector/connector.go b/connector/connector.go index 2b54258..5df010a 100644 --- a/connector/connector.go +++ b/connector/connector.go @@ -49,6 +49,7 @@ type Connector interface { Join(roomId RoomID) error // Try to invite someone to a channel + // Or if roomId == "", just try adding them as friends Invite(user UserID, roomId RoomID) error // Leave a channel diff --git a/connector/irc/irc.go b/connector/irc/irc.go index 318c663..aa9723f 100644 --- a/connector/irc/irc.go +++ b/connector/irc/irc.go @@ -102,7 +102,7 @@ func (irc *IRC) User() UserID { func (irc *IRC) checkRoomId(id RoomID) (string, error) { x := strings.Split(string(id), "@") - if len(x) != 2 || x[1] != irc.server || x[0][0] != '#' { + if x[0][0] != '#' || (len(x) == 2 && x[1] != irc.server) { return "", fmt.Errorf("Invalid room ID: %s", id) } return x[0], nil @@ -110,7 +110,7 @@ func (irc *IRC) checkRoomId(id RoomID) (string, error) { func (irc *IRC) checkUserId(id UserID) (string, error) { x := strings.Split(string(id), "@") - if len(x) != 2 || x[1] != irc.server || x[0][0] == '#' { + if x[0][0] == '#' || (len(x) == 2 && x[1] != irc.server) { return "", fmt.Errorf("Invalid user ID: %s", id) } return x[0], nil @@ -149,6 +149,10 @@ func (irc *IRC) Join(roomId RoomID) error { } func (irc *IRC) Invite(userId UserID, roomId RoomID) error { + if roomId == "" { + return nil + } + ch, err := irc.checkRoomId(roomId) if err != nil { return err diff --git a/connector/xmpp/xmpp.go b/connector/xmpp/xmpp.go index caeb993..b18e670 100644 --- a/connector/xmpp/xmpp.go +++ b/connector/xmpp/xmpp.go @@ -294,6 +294,11 @@ func (xm *XMPP) Join(roomId RoomID) error { } func (xm *XMPP) Invite(userId UserID, roomId RoomID) error { + if roomId == "" { + xm.conn.RequestSubscription(string(userId)) + xm.conn.ApproveSubscription(string(userId)) + return nil + } // TODO return fmt.Errorf("Not implemented") } |