Updating to latest groupme-lib which shares a single websocket for all faye subscriptions for all users
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
29
portal.go
29
portal.go
@ -143,10 +143,12 @@ func (portal *Portal) SyncDM(user *User, dm *groupme.Chat) {
|
||||
}
|
||||
portal.log.Infoln("Syncing portal for", user.MXID)
|
||||
|
||||
err := user.Conn.SubscribeToDM(context.TODO(), dm.LastMessage.ConversationID)
|
||||
if err != nil {
|
||||
portal.log.Errorln("Subscribing failed, live metadata updates won't work", err)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}()
|
||||
|
||||
if len(portal.MXID) == 0 {
|
||||
puppet := portal.bridge.GetPuppetByGMID(portal.Key.GMID)
|
||||
@ -204,10 +206,12 @@ func (portal *Portal) SyncGroup(user *User, group *groupme.Group) {
|
||||
}
|
||||
portal.log.Infoln("Syncing portal for", user.MXID)
|
||||
|
||||
err := user.Conn.SubscribeToGroup(context.TODO(), portal.Key.GMID)
|
||||
if err != nil {
|
||||
portal.log.Errorln("Subscribing failed, live metadata updates won't work", err)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}()
|
||||
|
||||
if len(portal.MXID) == 0 {
|
||||
portal.Name = group.Name
|
||||
@ -352,7 +356,8 @@ func (portal *Portal) updateMetadata(user *User) bool {
|
||||
if portal.IsPrivateChat() {
|
||||
return false
|
||||
}
|
||||
group, err := user.Client.ShowGroup(context.TODO(), groupme.ID(strings.Replace(portal.Key.GMID.String(), groupmeext.NewUserSuffix, "", 1)))
|
||||
group, err := user.Client.ShowGroup(context.TODO(), groupme.ID(strings.Replace(portal.Key.GMID.String(),
|
||||
groupmeext.NewUserSuffix, "", 1)), user.Token)
|
||||
if err != nil {
|
||||
portal.log.Errorln(err)
|
||||
return false
|
||||
@ -566,7 +571,7 @@ func (portal *Portal) HandleMatrixLeave(sender *User) {
|
||||
return
|
||||
} else {
|
||||
// TODO should we somehow deduplicate this call if this leave was sent by the bridge?
|
||||
err := sender.Client.RemoveFromGroup(sender.GMID, portal.Key.GMID)
|
||||
err := sender.Client.RemoveFromGroup(sender.GMID, portal.Key.GMID, sender.Token)
|
||||
if err != nil {
|
||||
portal.log.Errorfln("Failed to leave group as %s: %v", sender.MXID, err)
|
||||
return
|
||||
@ -1162,9 +1167,9 @@ func (portal *Portal) sendRaw(sender *User, evt *event.Event, info *groupme.Mess
|
||||
var err error
|
||||
|
||||
if portal.IsPrivateChat() {
|
||||
m, err = sender.Client.CreateDirectMessage(context.TODO(), info)
|
||||
m, err = sender.Client.CreateDirectMessage(context.TODO(), info, sender.Token)
|
||||
} else {
|
||||
m, err = sender.Client.CreateMessage(context.TODO(), info.GroupID, info)
|
||||
m, err = sender.Client.CreateMessage(context.TODO(), info.GroupID, info, sender.Token)
|
||||
}
|
||||
|
||||
id := ""
|
||||
|
Reference in New Issue
Block a user