about summary refs log tree commit diff
path: root/login.go
diff options
context:
space:
mode:
authorhanemile <mail@emile.space>2020-07-10 16:37:52 +0200
committerhanemile <mail@emile.space>2020-07-10 16:37:52 +0200
commit6c242710d7b1e4ba7c7d9b76437529d1d00c7c67 (patch)
tree028706a516365e365dd9807ee6d0ab57433b4807 /login.go
parent162f9164fdd95281e8e559b5963a02a7a16d25b7 (diff)
the functions handling almost everything I need
Diffstat (limited to 'login.go')
-rw-r--r--login.go35
1 files changed, 2 insertions, 33 deletions
diff --git a/login.go b/login.go
index 3e35858..aa24db5 100644
--- a/login.go
+++ b/login.go
@@ -3,9 +3,8 @@ package matrix
 import (
 	"encoding/json"
 
-	"github.com/h2non/gentleman/plugins/body"
 	"gopkg.in/h2non/gentleman.v2"
-	"gopkg.in/h2non/gentleman.v2/plugins/query"
+	"gopkg.in/h2non/gentleman.v2/plugins/body"
 )
 
 // Login logs in to the homeserver and returns an Authinfo struct containing
@@ -38,38 +37,8 @@ func Login(username, password, homeserver string) (Authinfo, error) {
 	if err := json.Unmarshal(res.Bytes(), &authinfo); err != nil {
 		return Authinfo{}, err
 	}
-	return authinfo, nil
-}
 
-func Sync(authinfo Authinfo) {
-	cli := gentleman.New()
-	cli.URL(authinfo.HomeServer)
-
-	req := cli.Request()
-	req.Path("/_matrix/client/r0/sync")
-	req.Method("GET")
-
-    req.Use(query.Set("access_token", authinfo.AccessToken))
-
-	res, err := req.Send()
-	if err != nil {
-		return err
-	}
-	if !res.Ok {
-		return err
-	}
+	authinfo.HomeServer = homeserver
 
-	var authinfo Authinfo
-	if err := json.Unmarshal(res.Bytes(), &authinfo); err != nil {
-		return Authinfo{}, err
-	}
 	return authinfo, nil
 }
-
-// Authinfo defines the fields returned after logging in
-type Authinfo struct {
-	UserID      string `json:"user_id"`
-	HomeServer  string `json:"home_server"`
-	DeviceID    string `json:"device_id"`
-	AccessToken string `json:"access_token"`
-}