From d4e7152ddec8194e625a80ef3c896758395e2e56 Mon Sep 17 00:00:00 2001 From: watsonb8 Date: Thu, 21 Sep 2023 11:58:36 -0500 Subject: [PATCH] Using latest fayec which only sends events to the explicit user with matching token --- go.mod | 4 ++-- go.sum | 6 ++++++ portal.go | 20 ++++++++------------ user.go | 16 ++++++---------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index cff8a66..5251ae6 100644 --- a/go.mod +++ b/go.mod @@ -14,8 +14,8 @@ require ( require go.mau.fi/util v0.0.0-20230805171708-199bf3eec776 require ( - gitea.watsonlabs.net/watsonb8/fayec v0.0.3 // indirect - gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.3 // indirect + gitea.watsonlabs.net/watsonb8/fayec v0.0.4 // indirect + gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect diff --git a/go.sum b/go.sum index 5e96381..b8106b2 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ gitea.watsonlabs.net/watsonb8/fayec v0.0.2 h1:tqbgr1vRZ6Wq4W81xBg+FTOywSv3EJpK26 gitea.watsonlabs.net/watsonb8/fayec v0.0.2/go.mod h1:gv8CWMq6dFJQhH30u8bO3u4k2irKlclZktLNYDebQ/0= gitea.watsonlabs.net/watsonb8/fayec v0.0.3 h1:YpaZBIee8Ix6uGm1UoEtBix1dEU1TURChAsJGJ3pVRo= gitea.watsonlabs.net/watsonb8/fayec v0.0.3/go.mod h1:gv8CWMq6dFJQhH30u8bO3u4k2irKlclZktLNYDebQ/0= +gitea.watsonlabs.net/watsonb8/fayec v0.0.4 h1:SLvwip1DQy13QngVsEgoLtN7T6bS+X6348p6PQhUF2A= +gitea.watsonlabs.net/watsonb8/fayec v0.0.4/go.mod h1:gv8CWMq6dFJQhH30u8bO3u4k2irKlclZktLNYDebQ/0= gitea.watsonlabs.net/watsonb8/groupme-lib v0.2.1-0.20230919023741-5727a20506fa h1:dFNaDeztJzo26t7URiOvaWNUDxve80tAAEHTKpi5JEk= gitea.watsonlabs.net/watsonb8/groupme-lib v0.2.1-0.20230919023741-5727a20506fa/go.mod h1:QRCibl6Tpr/uBtXD46qXqEkxqR5tQa5vdw+0j7hn+Mw= gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.0 h1:Uz5TIIF9tFf0LYEbCJqP8axufdBfsVorAYOaal2NmPw= @@ -18,6 +20,10 @@ gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.2 h1:QJLwAqYoIxhTtZIzMsjZGiLcml6N gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.2/go.mod h1:htgKMGvk2QieyYT69DWnTLABFc/6ttMlIRIr6zPXNfo= gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.3 h1:sBmF/10Zk0iyKs1nakHfOeB9BUoSyemCpDUEux+BpMk= gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.3/go.mod h1:htgKMGvk2QieyYT69DWnTLABFc/6ttMlIRIr6zPXNfo= +gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.4 h1:RnvQlgcBIyTSnrG7E311Zuy/A3avSuBYUb8lDN9sw5Q= +gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.4/go.mod h1:htgKMGvk2QieyYT69DWnTLABFc/6ttMlIRIr6zPXNfo= +gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.5 h1:J8r/xl8mcQ5mkR/3+gWxu0WdD4CecX42iqB+GLRhNt4= +gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.5/go.mod h1:3tsM98NYRgbrGrHokW/FYSoETCIaZVhfV+UGcDymQGg= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= diff --git a/portal.go b/portal.go index c9c33bc..ef40148 100644 --- a/portal.go +++ b/portal.go @@ -143,12 +143,10 @@ func (portal *Portal) SyncDM(user *User, dm *groupme.Chat) { } portal.log.Infoln("Syncing portal for", user.MXID) - go func() { - err := user.Conn.SubscribeToDM(context.TODO(), dm.LastMessage.ConversationID, user.Token) - if err != nil { - portal.log.Errorln("Subscribing failed, live metadata updates won't work", err) - } - }() + err := user.Conn.SubscribeToDM(context.TODO(), dm.LastMessage.ConversationID, user.Token) + if err != nil { + portal.log.Errorln("Subscribing failed, live metadata updates won't work", err) + } if len(portal.MXID) == 0 { puppet := portal.bridge.GetPuppetByGMID(portal.Key.GMID) @@ -206,12 +204,10 @@ func (portal *Portal) SyncGroup(user *User, group *groupme.Group) { } portal.log.Infoln("Syncing portal for", user.MXID) - go func() { - err := user.Conn.SubscribeToGroup(context.TODO(), portal.Key.GMID, user.Token) - if err != nil { - portal.log.Errorln("Subscribing failed, live metadata updates won't work", err) - } - }() + err := user.Conn.SubscribeToGroup(context.TODO(), portal.Key.GMID, user.Token) + if err != nil { + portal.log.Errorln("Subscribing failed, live metadata updates won't work", err) + } if len(portal.MXID) == 0 { portal.Name = group.Name diff --git a/user.go b/user.go index 4375449..e28a4ea 100644 --- a/user.go +++ b/user.go @@ -269,7 +269,7 @@ func (user *User) Connect(gmClient *groupmeext.Client, pushSub *groupme.PushSubs user.GMID = myuser.ID } - user.Conn.AddFullHandler(user) + user.Conn.AddFullHandler(user, user.Token) //TODO: typing notification? return user.RestoreSession() @@ -277,15 +277,11 @@ func (user *User) Connect(gmClient *groupmeext.Client, pushSub *groupme.PushSubs func (user *User) RestoreSession() bool { if len(user.Token) > 0 { - go func() { - err := user.Conn.SubscribeToUser(context.TODO(), user.GMID, user.Token) - if err != nil { - fmt.Println(err) - } - }() - //if err != nil { - // fmt.Println(err) - //} + + err := user.Conn.SubscribeToUser(context.TODO(), user.GMID, user.Token) + if err != nil { + fmt.Println(err) + } //TODO: typing notifics user.ConnectionErrors = 0