aboutsummaryrefslogtreecommitdiff
path: root/connector
diff options
context:
space:
mode:
Diffstat (limited to 'connector')
-rw-r--r--connector/connector.go1
-rw-r--r--connector/irc/irc.go8
-rw-r--r--connector/xmpp/xmpp.go5
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")
}