From 9f65ad172cb5d1db37eda5482c72d3c74e3916e9 Mon Sep 17 00:00:00 2001 From: watsonb8 Date: Mon, 4 Sep 2023 18:43:32 -0500 Subject: [PATCH] WIP --- database/message.go | 4 ++-- go.sum | 2 ++ user.go | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/database/message.go b/database/message.go index 0ff59e8..f0c3ddc 100644 --- a/database/message.go +++ b/database/message.go @@ -43,12 +43,12 @@ func (mq *MessageQuery) New() *Message { const ( getAllMessagesSelect = ` SELECT chat_gmid, chat_receiver, gmid, mxid, sender, timestamp, sent - FROM messages + FROM message ` getAllMessagesQuery = getAllMessagesSelect + ` WHERE chat_gmid=$1 AND chat_receiver=$2 ` - getByGMIDQuery = getAllMessagesQuery + "AND jid=$3" + getByGMIDQuery = getAllMessagesQuery + "AND gmid=$3" getByMXIDQuery = getAllMessagesSelect + "WHERE mxid=$1" getLastMessageInChatQuery = getAllMessagesQuery + ` AND timestamp<=$3 AND sent=true diff --git a/go.sum b/go.sum index 989f5f4..61b8a2e 100644 --- a/go.sum +++ b/go.sum @@ -128,6 +128,7 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -215,3 +216,4 @@ maunium.net/go/maulogger/v2 v2.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho= maunium.net/go/mautrix v0.15.0 h1:gkK9HXc1SSPwY7qOAqchzj2xxYqiOYeee8lr28A2g/o= maunium.net/go/mautrix v0.15.0/go.mod h1:1v8QVDd7q/eJ+eg4sgeOSEafBAFhkt4ab2i97M3IkNQ= +maunium.net/go/mautrix v0.16.0/go.mod h1:XAjE9pTSGcr6vXaiNgQGiip7tddJ8FQV1a29u2QdBG4= diff --git a/user.go b/user.go index 08eace9..444cffc 100644 --- a/user.go +++ b/user.go @@ -324,7 +324,7 @@ func (user *User) SetManagementRoom(roomID id.RoomID) { existingUser.ManagementRoom = "" existingUser.Update() } - + // user.ManagementRoom = roomID user.bridge.managementRooms[user.ManagementRoom] = user user.Update() @@ -342,11 +342,12 @@ func (user *User) Connect() bool { if timeout == 0 { timeout = 20 } + conn := groupme.NewPushSubscription(context.Background()) user.Conn = &conn user.Conn.StartListening(context.Background(), groupmeext.NewFayeClient(user.log)) + user.Conn.AddFullHandler(user) - user.intPostLogin() //TODO: typing notification? return user.RestoreSession() @@ -408,6 +409,7 @@ func (user *User) Login(token string) error { if user.Connect() { return nil } + user.intPostLogin() return errors.New("failed to connect") }