Compare commits
1 Commits
master
...
bmw/get-it
Author | SHA1 | Date | |
---|---|---|---|
c8a127ddef |
@ -10,7 +10,7 @@ steps:
|
||||
from_secret: docker_user
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: gitea.watsonlabs.net/watsonb8/groupme
|
||||
repo: gitea.watsonlabs.net/mautrix-groupme
|
||||
registry: gitea.watsonlabs.net
|
||||
dockerfile: Dockerfile
|
||||
auto_tag: true
|
||||
|
@ -1,34 +0,0 @@
|
||||
name: Build and Publish Docker Image
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build_and_publish:
|
||||
name: Build and Publish Docker
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Log in to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.watsonlabs.net/watsonb8/groupme
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: gitea.watsonlabs.net/watsonb8/groupme
|
||||
|
||||
- name: Build and push Docker image
|
||||
id: push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
@ -86,12 +86,6 @@ var cmdLogin = &commands.FullHandler{
|
||||
}
|
||||
|
||||
func fnLogin(ce *WrappedCommandEvent) {
|
||||
if ce.Args != nil && len(ce.Args) > 0 {
|
||||
_, err := ce.Bot.RedactEvent(ce.RoomID, ce.EventID)
|
||||
if err != nil {
|
||||
ce.User.log.Errorln("Failed to redact auth token")
|
||||
}
|
||||
}
|
||||
if ce.User.Client != nil {
|
||||
if ce.User.IsConnected() {
|
||||
ce.Reply("You're already logged in")
|
||||
@ -106,6 +100,8 @@ func fnLogin(ce *WrappedCommandEvent) {
|
||||
return
|
||||
}
|
||||
|
||||
defer ce.Bot.RedactEvent(ce.RoomID, ce.EventID)
|
||||
|
||||
err := ce.User.Login(ce.Args[0])
|
||||
if err != nil {
|
||||
ce.Reply("Failed to log in: %v", err)
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"maunium.net/go/mautrix/event"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
)
|
||||
|
||||
type DeferredConfig struct {
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
log "maunium.net/go/maulogger/v2"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
)
|
||||
|
||||
type MessageQuery struct {
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
log "maunium.net/go/maulogger/v2"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
)
|
||||
|
||||
// GMID is the puppet or the group
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
)
|
||||
|
||||
type PuppetQuery struct {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"go.mau.fi/util/dbutil"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
log "maunium.net/go/maulogger/v2"
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
|
||||
log "maunium.net/go/maulogger/v2"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
|
9
go.mod
9
go.mod
@ -3,7 +3,10 @@ module github.com/beeper/groupme
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/gabriel-vasile/mimetype v0.3.23
|
||||
github.com/beeper/groupme-lib v0.2.1-0.20221021205945-8f23e04eea71
|
||||
//github.com/beeper/groupme-lib v0.2.1-0.20221021205945-8f23e04eea71 => "../groupme-lib"
|
||||
github.com/gabriel-vasile/mimetype v1.1.2
|
||||
github.com/karmanyaahm/wray v0.0.0-20210303233435-756d58657c14
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/mattn/go-sqlite3 v1.14.17
|
||||
github.com/prometheus/client_golang v1.11.1
|
||||
@ -14,14 +17,12 @@ require (
|
||||
require go.mau.fi/util v0.0.0-20230805171708-199bf3eec776
|
||||
|
||||
require (
|
||||
gitea.watsonlabs.net/watsonb8/fayec v0.0.5 // indirect
|
||||
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.7 // 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
|
||||
github.com/golang/protobuf v1.4.3 // indirect
|
||||
github.com/google/go-cmp v0.5.8 // indirect
|
||||
github.com/google/uuid v1.3.1 // indirect
|
||||
github.com/google/uuid v1.2.0 // indirect
|
||||
github.com/gorilla/mux v1.8.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||
|
72
go.sum
72
go.sum
@ -1,43 +1,9 @@
|
||||
cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
gitea.watsonlabs.net/watsonb8/fayec v0.0.0-20230919020138-8f0db7048755 h1:FEhNSjSNvZ+nVg5Z3ds6X8ys3qjM+mmyLTSqKhCUHuQ=
|
||||
gitea.watsonlabs.net/watsonb8/fayec v0.0.0-20230919020138-8f0db7048755/go.mod h1:gv8CWMq6dFJQhH30u8bO3u4k2irKlclZktLNYDebQ/0=
|
||||
gitea.watsonlabs.net/watsonb8/fayec v0.0.0-20230919151904-5ca9ade6f946 h1:loc70tiaFs1U4sqn+lKMSBlo5OfvVfClYnWjfGLXaSg=
|
||||
gitea.watsonlabs.net/watsonb8/fayec v0.0.0-20230919151904-5ca9ade6f946/go.mod h1:gv8CWMq6dFJQhH30u8bO3u4k2irKlclZktLNYDebQ/0=
|
||||
gitea.watsonlabs.net/watsonb8/fayec v0.0.2 h1:tqbgr1vRZ6Wq4W81xBg+FTOywSv3EJpK263SAVXXTco=
|
||||
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/fayec v0.0.5 h1:9+UHzUuEcLuZ5Gx5S/NTBxYshUhsiQ5M3vzUF8RAKxw=
|
||||
gitea.watsonlabs.net/watsonb8/fayec v0.0.5/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=
|
||||
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.0/go.mod h1:vddDne/D5rrUUQkiIXveB7R3rONGEy4wtAIpGL+yFXA=
|
||||
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.1 h1:2HE8pyjczDZ74rhUE2fLvubiknR9Aj+izTcCewiTdik=
|
||||
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.1/go.mod h1:7pn2rsi3Axc15rW24idJfBjuXAFxvjLRmMK/0Ex0dKM=
|
||||
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.2 h1:QJLwAqYoIxhTtZIzMsjZGiLcml6NCS91DLvnmt/N7bM=
|
||||
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=
|
||||
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.6 h1:eITXFX7JHleKD7e2BAUjdX9eDxlxHeMGDRSA/wQa9xI=
|
||||
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.6/go.mod h1:3tsM98NYRgbrGrHokW/FYSoETCIaZVhfV+UGcDymQGg=
|
||||
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.7 h1:/rPp/sNfPqVomm950dL5ANooTTJ501ehvV3y/tC307g=
|
||||
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.7/go.mod h1:opuYpFdMeeGB87rS0KBkawDb74Hiaw24Lg+EOT6SlKY=
|
||||
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=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/autogrowsystems/wray v0.0.0-20160519030252-f36984f6648c/go.mod h1:druJ8QMeBCUmwJ7ZSFowx77dWxEWF3SYlQlsqZaLZQg=
|
||||
github.com/beeper/groupme-lib v0.2.0 h1:d/RSHPso6qjG80cH4nFEBeGnoEo7LJfKdvM+nCBLkqk=
|
||||
@ -56,24 +22,16 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/densestvoid/groupme v0.2.0/go.mod h1:i+bzB18n8RntitrMbr65boSHU0HfjDcbEUEIPPAV+QU=
|
||||
github.com/gabriel-vasile/mimetype v0.3.23 h1:4qH4dGPSe+MBFBkWDag41c+5YFasJjyP4KwI+t6Ukz8=
|
||||
github.com/gabriel-vasile/mimetype v0.3.23/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
|
||||
github.com/gabriel-vasile/mimetype v1.1.2 h1:gaPnPcNor5aZSVCJVSGipcpbgMWiAAj9z182ocSGbHU=
|
||||
github.com/gabriel-vasile/mimetype v1.1.2/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0 h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@ -93,39 +51,30 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
|
||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
|
||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
|
||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/karmanyaahm/wray v0.0.0-20210303233435-756d58657c14 h1:NrATjZKvkY+ojL8FXTWa3fQ+wihFrAxLNE6T+wOkIcY=
|
||||
github.com/karmanyaahm/wray v0.0.0-20210303233435-756d58657c14/go.mod h1:ysD86MIEevmAkdfdg5s6Qt3I07RN6fvMAyna7jCGG2o=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
@ -140,17 +89,13 @@ github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@ -172,13 +117,11 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
|
||||
github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
@ -186,7 +129,6 @@ 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 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
|
||||
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=
|
||||
@ -216,8 +158,6 @@ golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
||||
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
||||
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad h1:g0bG7Z4uG+OgH2QDODnjp6ggkk1bJDsINcuWmJN1iJU=
|
||||
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
|
||||
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
|
||||
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@ -227,12 +167,10 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@ -249,19 +187,11 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
|
||||
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
|
||||
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
@ -271,7 +201,6 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1 h1:7QnIQpGRHE5RnLKnESfDoxm2dTapTZua5a0kS0A+VXQ=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
@ -282,7 +211,6 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
@ -3,7 +3,7 @@ package groupmeext
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
@ -11,35 +11,35 @@ type Client struct {
|
||||
}
|
||||
|
||||
// NewClient creates a new GroupMe API Client
|
||||
func NewClient() *Client {
|
||||
func NewClient(authToken string) *Client {
|
||||
n := Client{
|
||||
Client: groupme.NewClient(),
|
||||
Client: groupme.NewClient(authToken),
|
||||
}
|
||||
return &n
|
||||
}
|
||||
func (c Client) IndexAllGroups(authToken string) ([]*groupme.Group, error) {
|
||||
func (c Client) IndexAllGroups() ([]*groupme.Group, error) {
|
||||
return c.IndexGroups(context.TODO(), &groupme.GroupsQuery{
|
||||
// Omit: "memberships",
|
||||
PerPage: 100, //TODO: Configurable and add multipage support
|
||||
}, authToken)
|
||||
})
|
||||
}
|
||||
|
||||
func (c Client) IndexAllRelations(authToken string) ([]*groupme.User, error) {
|
||||
return c.IndexRelations(context.TODO(), authToken)
|
||||
func (c Client) IndexAllRelations() ([]*groupme.User, error) {
|
||||
return c.IndexRelations(context.TODO())
|
||||
}
|
||||
|
||||
func (c Client) IndexAllChats(authToken string) ([]*groupme.Chat, error) {
|
||||
func (c Client) IndexAllChats() ([]*groupme.Chat, error) {
|
||||
return c.IndexChats(context.TODO(), &groupme.IndexChatsQuery{
|
||||
PerPage: 100, //TODO?
|
||||
}, authToken)
|
||||
})
|
||||
}
|
||||
|
||||
func (c Client) LoadMessagesAfter(groupID groupme.ID, lastMessageID string, lastMessageFromMe bool, private bool, authToken string) ([]*groupme.Message, error) {
|
||||
func (c Client) LoadMessagesAfter(groupID groupme.ID, lastMessageID string, lastMessageFromMe bool, private bool) ([]*groupme.Message, error) {
|
||||
if private {
|
||||
ans, e := c.IndexDirectMessages(context.TODO(), groupID.String(), &groupme.IndexDirectMessagesQuery{
|
||||
SinceID: groupme.ID(lastMessageID),
|
||||
//Limit: num,
|
||||
}, authToken)
|
||||
})
|
||||
//fmt.Println(groupID, lastMessageID, num, i.Count, e)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
@ -54,7 +54,7 @@ func (c Client) LoadMessagesAfter(groupID groupme.ID, lastMessageID string, last
|
||||
AfterID: groupme.ID(lastMessageID),
|
||||
//20 for consistency with dms
|
||||
Limit: 20,
|
||||
}, authToken)
|
||||
})
|
||||
//fmt.Println(groupID, lastMessageID, num, i.Count, e)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
@ -63,12 +63,12 @@ func (c Client) LoadMessagesAfter(groupID groupme.ID, lastMessageID string, last
|
||||
}
|
||||
}
|
||||
|
||||
func (c Client) LoadMessagesBefore(groupID, lastMessageID string, private bool, authToken string) ([]*groupme.Message, error) {
|
||||
func (c Client) LoadMessagesBefore(groupID, lastMessageID string, private bool) ([]*groupme.Message, error) {
|
||||
if private {
|
||||
i, e := c.IndexDirectMessages(context.TODO(), groupID, &groupme.IndexDirectMessagesQuery{
|
||||
BeforeID: groupme.ID(lastMessageID),
|
||||
//Limit: num,
|
||||
}, authToken)
|
||||
})
|
||||
//fmt.Println(groupID, lastMessageID, num, i.Count, e)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
@ -80,7 +80,7 @@ func (c Client) LoadMessagesBefore(groupID, lastMessageID string, private bool,
|
||||
BeforeID: groupme.ID(lastMessageID),
|
||||
//20 for consistency with dms
|
||||
Limit: 20,
|
||||
}, authToken)
|
||||
})
|
||||
//fmt.Println(groupID, lastMessageID, num, i.Count, e)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
@ -89,10 +89,10 @@ func (c Client) LoadMessagesBefore(groupID, lastMessageID string, private bool,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) RemoveFromGroup(uid, groupID groupme.ID, authToken string) error {
|
||||
group, err := c.ShowGroup(context.TODO(), groupID, authToken)
|
||||
func (c *Client) RemoveFromGroup(uid, groupID groupme.ID) error {
|
||||
group, err := c.ShowGroup(context.TODO(), groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.RemoveMember(context.TODO(), groupID, group.GetMemberByUserID(uid).ID, authToken)
|
||||
return c.RemoveMember(context.TODO(), groupID, group.GetMemberByUserID(uid).ID)
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
)
|
||||
|
||||
type Message struct{ groupme.Message }
|
||||
|
59
groupmeext/subscription.go
Normal file
59
groupmeext/subscription.go
Normal file
@ -0,0 +1,59 @@
|
||||
package groupmeext
|
||||
|
||||
import (
|
||||
log "maunium.net/go/maulogger/v2"
|
||||
|
||||
"github.com/karmanyaahm/wray"
|
||||
|
||||
"github.com/beeper/groupme-lib"
|
||||
)
|
||||
|
||||
type fayeLogger struct {
|
||||
log.Logger
|
||||
}
|
||||
|
||||
func (f fayeLogger) Debugf(i string, a ...interface{}) {
|
||||
f.Logger.Debugfln(i, a...)
|
||||
}
|
||||
func (f fayeLogger) Errorf(i string, a ...interface{}) {
|
||||
f.Logger.Errorfln(i, a...)
|
||||
}
|
||||
func (f fayeLogger) Warnf(i string, a ...interface{}) {
|
||||
f.Logger.Warnfln(i, a...)
|
||||
}
|
||||
func (f fayeLogger) Infof(i string, a ...interface{}) {
|
||||
f.Logger.Infofln(i, a...)
|
||||
}
|
||||
|
||||
type FayeClient struct {
|
||||
*wray.FayeClient
|
||||
}
|
||||
|
||||
func (fc FayeClient) WaitSubscribe(channel string, msgChannel chan groupme.PushMessage) {
|
||||
c_new := make(chan wray.Message)
|
||||
fc.FayeClient.WaitSubscribe(channel, c_new)
|
||||
//converting between types because channels don't support interfaces well
|
||||
go func() {
|
||||
for i := range c_new {
|
||||
msgChannel <- i
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// for authentication, specific implementation will vary based on faye library
|
||||
type AuthExt struct{}
|
||||
|
||||
func (a *AuthExt) In(wray.Message) {}
|
||||
func (a *AuthExt) Out(m wray.Message) {
|
||||
groupme.OutMsgProc(m)
|
||||
}
|
||||
|
||||
func NewFayeClient(logger log.Logger) *FayeClient {
|
||||
|
||||
fc := &FayeClient{wray.NewFayeClient(groupme.PushServer)}
|
||||
fc.SetLogger(fayeLogger{logger.Sub("FayeClient")})
|
||||
fc.AddExtension(&AuthExt{})
|
||||
fc.AddExtension(fc.FayeClient)
|
||||
|
||||
return fc
|
||||
}
|
9
main.go
9
main.go
@ -17,11 +17,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme/groupmeext"
|
||||
"github.com/beeper/groupme-lib"
|
||||
"go.mau.fi/util/configupgrade"
|
||||
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
||||
"maunium.net/go/mautrix/event"
|
||||
@ -120,14 +118,11 @@ func (br *GMBridge) Start() {
|
||||
func (br *GMBridge) StartUsers() {
|
||||
br.Log.Debugln("Starting users")
|
||||
foundAnySessions := false
|
||||
gmc := groupmeext.NewClient()
|
||||
conn := groupme.NewPushSubscription(context.Background())
|
||||
conn.Connect(context.Background())
|
||||
for _, user := range br.GetAllUsers() {
|
||||
if user.GMID.Valid() {
|
||||
foundAnySessions = true
|
||||
}
|
||||
go user.Connect(gmc, &conn)
|
||||
go user.Connect()
|
||||
}
|
||||
if !foundAnySessions {
|
||||
br.SendGlobalBridgeState(status.BridgeState{StateEvent: status.StateUnconfigured}.Fill(nil))
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
log "maunium.net/go/maulogger/v2"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
|
||||
"maunium.net/go/mautrix/event"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
253
portal.go
253
portal.go
@ -38,7 +38,7 @@ import (
|
||||
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
||||
"maunium.net/go/mautrix/crypto/attachment"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
|
||||
"maunium.net/go/mautrix"
|
||||
"maunium.net/go/mautrix/appservice"
|
||||
@ -149,6 +149,8 @@ func (portal *Portal) SyncDM(user *User, dm *groupme.Chat) {
|
||||
}
|
||||
|
||||
if len(portal.MXID) == 0 {
|
||||
|
||||
// "" for overall user not related to one group
|
||||
puppet := portal.bridge.GetPuppetByGMID(portal.Key.GMID)
|
||||
meta, err := portal.bridge.StateStore.TryGetMember("", puppet.MXID)
|
||||
if err {
|
||||
@ -188,7 +190,13 @@ func (portal *Portal) SyncDM(user *User, dm *groupme.Chat) {
|
||||
portal.ensureUserInvited(user)
|
||||
}
|
||||
|
||||
//if portal.IsPrivateChat() {
|
||||
// return
|
||||
//}
|
||||
|
||||
update := false
|
||||
|
||||
update = portal.updateMetadata(user) || update
|
||||
update = portal.UpdateAvatar(user, dm.OtherUser.AvatarURL, false) || update
|
||||
|
||||
if update {
|
||||
@ -352,8 +360,7 @@ 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)), user.Token)
|
||||
group, err := user.Client.ShowGroup(context.TODO(), groupme.ID(strings.Replace(portal.Key.GMID.String(), groupmeext.NewUserSuffix, "", 1)))
|
||||
if err != nil {
|
||||
portal.log.Errorln(err)
|
||||
return false
|
||||
@ -567,7 +574,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, sender.Token)
|
||||
err := sender.Client.RemoveFromGroup(sender.GMID, portal.Key.GMID)
|
||||
if err != nil {
|
||||
portal.log.Errorfln("Failed to leave group as %s: %v", sender.MXID, err)
|
||||
return
|
||||
@ -617,6 +624,7 @@ func (portal *Portal) handleMessage(msg PortalMessage) {
|
||||
return
|
||||
}
|
||||
portal.HandleTextMessage(msg.source, msg.data)
|
||||
portal.handleReaction(msg.data.ID, msg.data.SenderID, msg.data.FavoritedBy)
|
||||
}
|
||||
|
||||
func (portal *Portal) handleAttachment(intent *appservice.IntentAPI, attachment *groupme.Attachment, source *User, message *groupme.Message) (msg *event.MessageEventContent, sendText bool, err error) {
|
||||
@ -679,7 +687,7 @@ func (portal *Portal) handleAttachment(intent *appservice.IntentAPI, attachment
|
||||
case "video":
|
||||
vidContents, mime := groupmeext.DownloadVideo(attachment.VideoPreviewURL, attachment.URL, source.Token)
|
||||
if mime == "" {
|
||||
mime, _ = mimetype.Detect(vidContents)
|
||||
mime = mimetype.Detect(vidContents).String()
|
||||
}
|
||||
|
||||
data, uploadMimeType, file := portal.encryptFile(vidContents, mime)
|
||||
@ -702,6 +710,9 @@ func (portal *Portal) handleAttachment(intent *appservice.IntentAPI, attachment
|
||||
Info: &event.FileInfo{
|
||||
Size: len(data),
|
||||
MimeType: mime,
|
||||
//Width: width,
|
||||
//Height: height,
|
||||
//Duration: int(msg.length),
|
||||
},
|
||||
}
|
||||
if content.File != nil {
|
||||
@ -716,7 +727,7 @@ func (portal *Portal) handleAttachment(intent *appservice.IntentAPI, attachment
|
||||
case "file":
|
||||
fileData, fname, fmime := groupmeext.DownloadFile(portal.Key.GMID, attachment.FileID, source.Token)
|
||||
if fmime == "" {
|
||||
fmime, _ = mimetype.Detect(fileData)
|
||||
fmime = mimetype.Detect(fileData).String()
|
||||
}
|
||||
data, uploadMimeType, file := portal.encryptFile(fileData, fmime)
|
||||
|
||||
@ -738,6 +749,9 @@ func (portal *Portal) handleAttachment(intent *appservice.IntentAPI, attachment
|
||||
Info: &event.FileInfo{
|
||||
Size: len(data),
|
||||
MimeType: fmime,
|
||||
//Width: width,
|
||||
//Height: height,
|
||||
//Duration: int(msg.length),
|
||||
},
|
||||
}
|
||||
if content.File != nil {
|
||||
@ -792,6 +806,91 @@ func (portal *Portal) handleAttachment(intent *appservice.IntentAPI, attachment
|
||||
// return nil, true, errors.New("Unknown type")
|
||||
}
|
||||
|
||||
func (portal *Portal) handleReaction(msgID groupme.ID, senderId groupme.ID, ppl []string) {
|
||||
fmt.Println("hello")
|
||||
//reactions := portal.bridge.DB.Reaction.GetByTargetGMID(portal.Key, msgID, senderId)
|
||||
//newLikes := newReactions(reactions, ppl)
|
||||
//removeLikes := oldReactions(reactions, ppl)
|
||||
//
|
||||
//var eventID id.EventID
|
||||
//if len(newLikes) > 0 {
|
||||
// message := portal.bridge.DB.Message.GetByGMID(portal.Key, msgID)
|
||||
// if message == nil {
|
||||
// portal.log.Errorln("Received reaction for unknown message", msgID)
|
||||
// return
|
||||
// }
|
||||
// eventID = message.MXID
|
||||
//}
|
||||
//
|
||||
//for _, gmid := range newLikes {
|
||||
// intent := portal.getReactionIntent(gmid)
|
||||
// resp, err := portal.sendReaction(intent, eventID, "❤")
|
||||
// if err != nil {
|
||||
// portal.log.Errorln("Something wrong with sending reaction", msgID, gmid, err)
|
||||
// continue
|
||||
// }
|
||||
//
|
||||
// newReaction := portal.bridge.DB.Reaction.New()
|
||||
// newReaction.MXID = resp.EventID
|
||||
// newReaction.GMID = msgID
|
||||
// newReaction.MXID = eventID
|
||||
// newReaction.Chat.GMID = gmid
|
||||
//
|
||||
// portal.bridge.DB.Reaction.Insert()
|
||||
// newReaction.Insert()
|
||||
//
|
||||
//}
|
||||
//
|
||||
//for _, reaction := range removeLikes {
|
||||
// if len(reaction.Chat.GMID) == 0 {
|
||||
// portal.log.Warnln("Reaction user state wrong", reaction.MXID, msgID)
|
||||
// continue
|
||||
// }
|
||||
// intent := portal.getReactionIntent(reaction.Chat.GMID)
|
||||
// _, err := intent.RedactEvent(portal.MXID, reaction.MXID)
|
||||
// if err != nil {
|
||||
// portal.log.Errorln("Something wrong with reaction redaction", reaction.MXID)
|
||||
// continue
|
||||
// }
|
||||
// reaction.Delete()
|
||||
//
|
||||
//}
|
||||
}
|
||||
|
||||
//func oldReactions(a []*database.Reaction, b []string) (ans []*database.Reaction) {
|
||||
// for _, i := range a {
|
||||
// flag := false
|
||||
// for _, j := range b {
|
||||
// if i.Chat.GMID == j {
|
||||
// flag = true
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// if !flag {
|
||||
// ans = append(ans, i)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//func newReactions(a []*database.Reaction, b []string) (ans []string) {
|
||||
// for _, j := range b {
|
||||
// flag := false
|
||||
// for _, i := range a {
|
||||
// if i.PuppetJID == j {
|
||||
// flag = true
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// if !flag {
|
||||
// ans = append(ans, j)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return
|
||||
//}
|
||||
|
||||
// Private Methods
|
||||
|
||||
func (portal *Portal) createMatrixRoom(user *User) error {
|
||||
@ -824,25 +923,7 @@ func (portal *Portal) createMatrixRoom(user *User) error {
|
||||
Type: event.StateHalfShotBridge,
|
||||
Content: event.Content{Parsed: bridgeInfo},
|
||||
StateKey: &bridgeInfoStateKey,
|
||||
}, {
|
||||
Type: event.StateSpaceParent,
|
||||
StateKey: &user.SpaceId,
|
||||
Content: event.Content{Parsed: &event.SpaceParentEventContent{
|
||||
Via: []string{portal.bridge.AS.HomeserverDomain},
|
||||
Canonical: true,
|
||||
}},
|
||||
}, {
|
||||
Type: event.StateJoinRules,
|
||||
Content: event.Content{Parsed: &event.JoinRulesEventContent{
|
||||
JoinRule: event.JoinRuleRestricted,
|
||||
Allow: []event.JoinRuleAllow{{
|
||||
RoomID: id.RoomID(user.SpaceId),
|
||||
Type: event.JoinRuleAllowRoomMembership,
|
||||
}},
|
||||
}},
|
||||
}}
|
||||
|
||||
//initialState = append(initialState, event.Event)
|
||||
if !portal.AvatarURL.IsEmpty() {
|
||||
initialState = append(initialState, &event.Event{
|
||||
Type: event.StateRoomAvatar,
|
||||
@ -896,8 +977,6 @@ func (portal *Portal) createMatrixRoom(user *User) error {
|
||||
portal.bridge.StateStore.SetMembership(portal.MXID, user, event.MembershipInvite)
|
||||
}
|
||||
|
||||
user.addPortalToSpace(portal)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -990,6 +1069,12 @@ func (portal *Portal) ensureMXIDInvited(mxid id.UserID) {
|
||||
}
|
||||
|
||||
func (portal *Portal) ensureUserInvited(user *User) bool {
|
||||
portal.userMXIDAction(user, portal.ensureMXIDInvited)
|
||||
|
||||
customPuppet := portal.bridge.GetPuppetByCustomMXID(user.MXID)
|
||||
if customPuppet != nil && customPuppet.CustomIntent() != nil {
|
||||
_ = customPuppet.CustomIntent().EnsureJoined(portal.MXID)
|
||||
}
|
||||
return user.ensureInvited(portal.MainIntent(), portal.MXID, portal.IsPrivateChat())
|
||||
}
|
||||
|
||||
@ -1061,6 +1146,89 @@ func (portal *Portal) sendMessage(intent *appservice.IntentAPI, eventType event.
|
||||
}
|
||||
}
|
||||
|
||||
// func (portal *Portal) handleReaction(msgID groupme.ID, ppl []groupme.ID) {
|
||||
// reactions := portal.bridge.DB.Reaction.GetByGMID(msgID)
|
||||
// newLikes := newReactions(reactions, ppl)
|
||||
// removeLikes := oldReactions(reactions, ppl)
|
||||
|
||||
// var eventID id.EventID
|
||||
// if len(newLikes) > 0 {
|
||||
// message := portal.bridge.DB.Message.GetByGMID(portal.Key, msgID)
|
||||
// if message == nil {
|
||||
// portal.log.Errorln("Received reaction for unknown message", msgID)
|
||||
// return
|
||||
// }
|
||||
// eventID = message.MXID
|
||||
// }
|
||||
|
||||
// for _, jid := range newLikes {
|
||||
// intent := portal.getReactionIntent(jid)
|
||||
// resp, err := portal.sendReaction(intent, eventID, "❤")
|
||||
// if err != nil {
|
||||
// portal.log.Errorln("Something wrong with sending reaction", msgID, jid, err)
|
||||
// continue
|
||||
// }
|
||||
|
||||
// newReaction := portal.bridge.DB.Reaction.New()
|
||||
// newReaction.MXID = resp.EventID
|
||||
// newReaction.MessageJID = msgID
|
||||
// newReaction.MessageMXID = eventID
|
||||
// newReaction.PuppetJID = jid
|
||||
|
||||
// newReaction.Insert()
|
||||
|
||||
// }
|
||||
|
||||
// for _, reaction := range removeLikes {
|
||||
// if len(reaction.Puppet.JID) == 0 {
|
||||
// portal.log.Warnln("Reaction user state wrong", reaction.MXID, msgID)
|
||||
// continue
|
||||
// }
|
||||
// intent := portal.getReactionIntent(reaction.PuppetJID)
|
||||
// _, err := intent.RedactEvent(portal.MXID, reaction.MXID)
|
||||
// if err != nil {
|
||||
// portal.log.Errorln("Something wrong with reaction redaction", reaction.MXID)
|
||||
// continue
|
||||
// }
|
||||
// reaction.Delete()
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// func oldReactions(a []*database.Reaction, b []string) (ans []*database.Reaction) {
|
||||
// for _, i := range a {
|
||||
// flag := false
|
||||
// for _, j := range b {
|
||||
// if i.PuppetJID == j {
|
||||
// flag = true
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// if !flag {
|
||||
// ans = append(ans, i)
|
||||
// }
|
||||
// }
|
||||
|
||||
// return
|
||||
// }
|
||||
|
||||
// func newReactions(a []*database.Reaction, b []string) (ans []string) {
|
||||
// for _, j := range b {
|
||||
// flag := false
|
||||
// for _, i := range a {
|
||||
// if i.GMID == j {
|
||||
// flag = true
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// if !flag {
|
||||
// ans = append(ans, j)
|
||||
// }
|
||||
// }
|
||||
|
||||
// return
|
||||
// }
|
||||
|
||||
func (portal *Portal) sendMediaBridgeFailure(source *User, intent *appservice.IntentAPI, message groupme.Message, bridgeErr error) {
|
||||
portal.log.Errorfln("Failed to bridge media for %s: %v", message.UserID.String(), bridgeErr)
|
||||
resp, err := portal.sendMessage(intent, event.EventMessage, &event.MessageEventContent{
|
||||
@ -1122,12 +1290,36 @@ func (portal *Portal) convertMatrixMessage(sender *User, evt *event.Event) ([]*g
|
||||
return nil, sender
|
||||
}
|
||||
|
||||
//ts := uint64(evt.Timestamp / 1000)
|
||||
//status := waProto.WebMessageInfo_ERROR
|
||||
//fromMe := true
|
||||
// info := &waProto.WebMessageInfo{
|
||||
// Key: &waProto.MessageKey{
|
||||
// FromMe: &fromMe,
|
||||
// Id: makeMessageID(),
|
||||
// RemoteJid: &portal.Key.JID,
|
||||
// },
|
||||
// MessageTimestamp: &ts,
|
||||
// Message: &waProto.Message{},
|
||||
// Status: &status,
|
||||
// }
|
||||
//
|
||||
info := groupme.Message{
|
||||
GroupID: groupme.ID(portal.Key.String()),
|
||||
ConversationID: groupme.ID(portal.Key.String()),
|
||||
ChatID: groupme.ID(portal.Key.String()),
|
||||
RecipientID: groupme.ID(portal.Key.GMID),
|
||||
}
|
||||
replyToID := content.GetReplyTo()
|
||||
if len(replyToID) > 0 {
|
||||
// content.RemoveReplyFallback()
|
||||
// msg := portal.bridge.DB.Message.GetByMXID(replyToID)
|
||||
// if msg != nil && msg.Content != nil {
|
||||
// ctxInfo.StanzaId = &msg.JID
|
||||
// ctxInfo.Participant = &msg.Sender
|
||||
// ctxInfo.QuotedMessage = msg.Content
|
||||
// }
|
||||
}
|
||||
relaybotFormatted := false
|
||||
|
||||
if evt.Type == event.EventSticker {
|
||||
@ -1163,9 +1355,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, sender.Token)
|
||||
m, err = sender.Client.CreateDirectMessage(context.TODO(), info)
|
||||
} else {
|
||||
m, err = sender.Client.CreateMessage(context.TODO(), info.GroupID, info, sender.Token)
|
||||
m, err = sender.Client.CreateMessage(context.TODO(), info.GroupID, info)
|
||||
}
|
||||
|
||||
id := ""
|
||||
@ -1296,6 +1488,11 @@ func (portal *Portal) syncParticipants(group *groupme.Group) {
|
||||
}
|
||||
|
||||
expectedLevel := 0
|
||||
// if participant.IsSuperAdmin {
|
||||
// expectedLevel = 95
|
||||
// } else if participant.IsAdmin {
|
||||
// expectedLevel = 50
|
||||
// }
|
||||
changed = levels.EnsureUserLevel(puppet.MXID, expectedLevel) || changed
|
||||
if user != nil {
|
||||
changed = levels.EnsureUserLevel(user.MXID, expectedLevel) || changed
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
|
||||
log "maunium.net/go/maulogger/v2"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
|
||||
"maunium.net/go/mautrix/appservice"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
304
user.go
304
user.go
@ -35,7 +35,7 @@ import (
|
||||
"maunium.net/go/mautrix/format"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
||||
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||
"github.com/beeper/groupme-lib"
|
||||
|
||||
"github.com/beeper/groupme/database"
|
||||
"github.com/beeper/groupme/groupmeext"
|
||||
@ -56,7 +56,7 @@ type User struct {
|
||||
|
||||
Client *groupmeext.Client
|
||||
ConnectionErrors int
|
||||
SpaceId string
|
||||
CommunityID string
|
||||
|
||||
ChatList map[groupme.ID]*groupme.Chat
|
||||
GroupList map[groupme.ID]*groupme.Group
|
||||
@ -90,8 +90,6 @@ type Chat struct {
|
||||
|
||||
type ChatList []Chat
|
||||
|
||||
var connectWaitGroup = sync.WaitGroup{}
|
||||
|
||||
func (cl ChatList) Len() int {
|
||||
return len(cl)
|
||||
}
|
||||
@ -119,8 +117,8 @@ func (user *User) GetMXID() id.UserID {
|
||||
}
|
||||
|
||||
func (user *User) GetGMID() groupme.ID {
|
||||
if user.GMID == "" {
|
||||
u, err := user.Client.MyUser(context.TODO(), user.Token)
|
||||
if len(user.GMID) == 0 {
|
||||
u, err := user.Client.MyUser(context.TODO())
|
||||
if err != nil {
|
||||
user.log.Errorln("Failed to get own GroupMe ID:", err)
|
||||
return ""
|
||||
@ -143,7 +141,7 @@ func (user *User) GetIDoublePuppet() bridge.DoublePuppet {
|
||||
}
|
||||
|
||||
func (user *User) GetIGhost() bridge.Ghost {
|
||||
if user.GMID == "" {
|
||||
if user.GMID.String() == "" {
|
||||
return nil
|
||||
}
|
||||
p := user.bridge.GetPuppetByGMID(user.GMID)
|
||||
@ -154,7 +152,53 @@ func (user *User) GetIGhost() bridge.Ghost {
|
||||
}
|
||||
|
||||
func (user *User) GetSpaceRoom() id.RoomID {
|
||||
return user.getSpaceRoom(&user.SpaceRoom, "GroupMe", "Your GroupMe bridged chats", "")
|
||||
if !user.bridge.Config.Bridge.PersonalFilteringSpaces {
|
||||
return ""
|
||||
}
|
||||
|
||||
if len(user.SpaceRoom) == 0 {
|
||||
user.spaceCreateLock.Lock()
|
||||
defer user.spaceCreateLock.Unlock()
|
||||
if len(user.SpaceRoom) > 0 {
|
||||
return user.SpaceRoom
|
||||
}
|
||||
|
||||
resp, err := user.bridge.Bot.CreateRoom(&mautrix.ReqCreateRoom{
|
||||
Visibility: "private",
|
||||
Name: "GroupMe",
|
||||
Topic: "Your GroupMe bridged chats",
|
||||
InitialState: []*event.Event{{
|
||||
Type: event.StateRoomAvatar,
|
||||
Content: event.Content{
|
||||
Parsed: &event.RoomAvatarEventContent{
|
||||
URL: user.bridge.Config.AppService.Bot.ParsedAvatar,
|
||||
},
|
||||
},
|
||||
}},
|
||||
CreationContent: map[string]interface{}{
|
||||
"type": event.RoomTypeSpace,
|
||||
},
|
||||
PowerLevelOverride: &event.PowerLevelsEventContent{
|
||||
Users: map[id.UserID]int{
|
||||
user.bridge.Bot.UserID: 9001,
|
||||
user.MXID: 50,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
user.log.Errorln("Failed to auto-create space room:", err)
|
||||
} else {
|
||||
user.SpaceRoom = resp.RoomID
|
||||
user.Update()
|
||||
user.ensureInvited(user.bridge.Bot, user.SpaceRoom, false)
|
||||
}
|
||||
} else if !user.spaceMembershipChecked && !user.bridge.StateStore.IsInRoom(user.SpaceRoom, user.MXID) {
|
||||
user.ensureInvited(user.bridge.Bot, user.SpaceRoom, false)
|
||||
}
|
||||
user.spaceMembershipChecked = true
|
||||
|
||||
return user.SpaceRoom
|
||||
}
|
||||
|
||||
func (user *User) GetManagementRoom() id.RoomID {
|
||||
@ -224,11 +268,10 @@ func (user *User) GetPortalByGMID(gmid groupme.ID) *Portal {
|
||||
|
||||
func (user *User) Login(token string) error {
|
||||
user.Token = token
|
||||
user.Update()
|
||||
|
||||
user.addToGMIDMap()
|
||||
if user.Connect(user.Client, user.Conn) {
|
||||
user.PostLogin()
|
||||
user.PostLogin()
|
||||
if user.Connect() {
|
||||
return nil
|
||||
}
|
||||
return errors.New("failed to connect")
|
||||
@ -244,9 +287,7 @@ func (user *User) PostLogin() {
|
||||
go user.intPostLogin()
|
||||
}
|
||||
|
||||
func (user *User) Connect(gmClient *groupmeext.Client, pushSub *groupme.PushSubscription) bool {
|
||||
user.SpaceId = "GroupMe"
|
||||
user.Client = gmClient
|
||||
func (user *User) Connect() bool {
|
||||
if user.Conn != nil {
|
||||
return true
|
||||
} else if len(user.Token) == 0 {
|
||||
@ -259,17 +300,11 @@ func (user *User) Connect(gmClient *groupmeext.Client, pushSub *groupme.PushSubs
|
||||
timeout = 20
|
||||
}
|
||||
|
||||
user.Conn = pushSub
|
||||
conn := groupme.NewPushSubscription(context.Background())
|
||||
user.Conn = &conn
|
||||
user.Conn.StartListening(context.Background(), groupmeext.NewFayeClient(user.log))
|
||||
|
||||
if user.GMID == "" {
|
||||
myuser, err := user.Client.MyUser(context.TODO(), user.Token)
|
||||
if err != nil {
|
||||
log.Fatal(err) //TODO
|
||||
}
|
||||
user.GMID = myuser.ID
|
||||
}
|
||||
|
||||
user.Conn.AddFullHandler(user, user.Token)
|
||||
user.Conn.AddFullHandler(user)
|
||||
|
||||
//TODO: typing notification?
|
||||
return user.RestoreSession()
|
||||
@ -277,18 +312,15 @@ func (user *User) Connect(gmClient *groupmeext.Client, pushSub *groupme.PushSubs
|
||||
|
||||
func (user *User) RestoreSession() bool {
|
||||
if len(user.Token) > 0 {
|
||||
|
||||
err := user.Conn.SubscribeToUser(context.TODO(), user.GMID, user.Token)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
//TODO: typing notifics
|
||||
user.ConnectionErrors = 0
|
||||
//user.SetSession(&sess)
|
||||
user.log.Debugln("Session restored successfully")
|
||||
user.PostLogin()
|
||||
|
||||
return true
|
||||
} else {
|
||||
user.log.Debugln("tried login but no token")
|
||||
@ -353,11 +385,7 @@ func (user *User) HandleTextMessage(message groupme.Message) {
|
||||
id := database.ParsePortalKey(message.GroupID.String())
|
||||
|
||||
if id == nil {
|
||||
if user.GMID == message.UserID {
|
||||
id = database.ParsePortalKey(message.UserID.String() + "+" + message.RecipientID.String())
|
||||
} else {
|
||||
id = database.ParsePortalKey(message.RecipientID.String() + "+" + message.UserID.String())
|
||||
}
|
||||
id = database.ParsePortalKey(message.ConversationID.String())
|
||||
}
|
||||
if id == nil {
|
||||
user.log.Errorln("Error parsing conversationid/portalkey", message.ConversationID.String(), "ignoring message")
|
||||
@ -432,33 +460,38 @@ func (user *User) HandleJSONParseError(err error) {
|
||||
|
||||
func (user *User) HandleChatList() {
|
||||
chatMap := map[groupme.ID]*groupme.Group{}
|
||||
chats, err := user.Client.IndexAllGroups(user.Token)
|
||||
chats, err := user.Client.IndexAllGroups()
|
||||
if err != nil {
|
||||
user.log.Errorln("chat sync error", err) //TODO: handle
|
||||
return
|
||||
}
|
||||
user.log.Debugln("Group")
|
||||
for _, chat := range chats {
|
||||
user.log.Debugln(" " + chat.Name)
|
||||
for _, mem := range chat.Members {
|
||||
user.log.Debugln(" " + mem.Nickname)
|
||||
}
|
||||
|
||||
chatMap[chat.ID] = chat
|
||||
}
|
||||
user.GroupList = chatMap
|
||||
|
||||
dmMap := map[groupme.ID]*groupme.Chat{}
|
||||
dms, err := user.Client.IndexAllChats(user.Token)
|
||||
dms, err := user.Client.IndexAllChats()
|
||||
if err != nil {
|
||||
user.log.Errorln("chat sync error", err) //TODO: handle
|
||||
return
|
||||
}
|
||||
for _, dm := range dms {
|
||||
dmMap[dm.LastMessage.ConversationID] = dm
|
||||
dmMap[dm.OtherUser.ID] = dm
|
||||
}
|
||||
user.ChatList = dmMap
|
||||
|
||||
userMap := map[groupme.ID]*groupme.User{}
|
||||
users, err := user.Client.IndexAllRelations(user.Token)
|
||||
users, err := user.Client.IndexAllRelations()
|
||||
if err != nil {
|
||||
user.log.Errorln("Error syncing user list, continuing sync", err)
|
||||
}
|
||||
|
||||
for _, u := range users {
|
||||
puppet := user.bridge.GetPuppetByGMID(u.ID)
|
||||
// "" for overall user not related to one group
|
||||
@ -469,17 +502,6 @@ func (user *User) HandleChatList() {
|
||||
}, false, false)
|
||||
userMap[u.ID] = u
|
||||
}
|
||||
|
||||
for _, dm := range dms {
|
||||
puppet := user.bridge.GetPuppetByGMID(dm.OtherUser.ID)
|
||||
|
||||
puppet.Sync(user, &groupme.Member{
|
||||
UserID: dm.OtherUser.ID,
|
||||
Nickname: dm.OtherUser.Name,
|
||||
ImageURL: dm.OtherUser.AvatarURL,
|
||||
}, false, false)
|
||||
userMap[dm.OtherUser.ID] = &dm.OtherUser
|
||||
}
|
||||
user.RelationList = userMap
|
||||
|
||||
user.log.Infoln("Chat list received")
|
||||
@ -604,26 +626,41 @@ func (user *User) sendMarkdownBridgeAlert(formatString string, args ...interface
|
||||
}
|
||||
}
|
||||
|
||||
//func (user *User) postConnPing() bool {
|
||||
// user.log.Debugln("Making post-connection ping")
|
||||
// if !user.Conn.Connected() {
|
||||
// user.log.Errorfln("Post-connection ping failed: %v. Disconnecting and then reconnecting after a second")
|
||||
// user.bridge.Metrics.TrackDisconnection(user.MXID)
|
||||
// go func() {
|
||||
// time.Sleep(1 * time.Second)
|
||||
// user.Connect()
|
||||
// }()
|
||||
// return false
|
||||
// } else {
|
||||
// user.log.Debugln("Post-connection ping OK")
|
||||
// return true
|
||||
// }
|
||||
//}
|
||||
func (user *User) postConnPing() bool {
|
||||
//user.log.Debugln("Making post-connection ping")
|
||||
//err := user.Conn.AdminTest()
|
||||
//if err != nil {
|
||||
// user.log.Errorfln("Post-connection ping failed: %v. Disconnecting and then reconnecting after a second", err)
|
||||
// sess, disconnectErr := user.Conn.Disconnect()
|
||||
// if disconnectErr != nil {
|
||||
// user.log.Warnln("Error while disconnecting after failed post-connection ping:", disconnectErr)
|
||||
// } else {
|
||||
// user.Session = &sess
|
||||
// }
|
||||
// user.bridge.Metrics.TrackDisconnection(user.MXID)
|
||||
// go func() {
|
||||
// time.Sleep(1 * time.Second)
|
||||
// user.tryReconnect(fmt.Sprintf("Post-connection ping failed: %v", err))
|
||||
// }()
|
||||
// return false
|
||||
//} else {
|
||||
// user.log.Debugln("Post-connection ping OK")
|
||||
// return true
|
||||
//}
|
||||
return true
|
||||
}
|
||||
|
||||
func (user *User) intPostLogin() {
|
||||
defer user.syncWait.Done()
|
||||
user.lastReconnection = time.Now().Unix()
|
||||
|
||||
user.Client = groupmeext.NewClient(user.Token)
|
||||
if len(user.GMID) == 0 {
|
||||
myuser, err := user.Client.MyUser(context.TODO())
|
||||
if err != nil {
|
||||
log.Fatal(err) //TODO
|
||||
}
|
||||
user.GMID = myuser.ID
|
||||
}
|
||||
user.Update()
|
||||
|
||||
user.tryAutomaticDoublePuppeting()
|
||||
@ -633,9 +670,14 @@ func (user *User) intPostLogin() {
|
||||
select {
|
||||
case <-user.chatListReceived:
|
||||
user.log.Debugln("Chat list receive confirmation received in PostLogin")
|
||||
case <-time.After(time.Duration(10000 /**user.bridge.Config.Bridge.ChatListWait**/) * time.Second):
|
||||
case <-time.After(time.Duration(1000 /**user.bridge.Config.Bridge.ChatListWait**/) * time.Second):
|
||||
user.log.Warnln("Timed out waiting for chat list to arrive!")
|
||||
//user.postConnPing()
|
||||
user.postConnPing()
|
||||
return
|
||||
}
|
||||
|
||||
if !user.postConnPing() {
|
||||
user.log.Debugln("Post-connection ping failed, unlocking processing of incoming messages.")
|
||||
return
|
||||
}
|
||||
|
||||
@ -677,16 +719,17 @@ func (user *User) syncPortals(createAll bool) {
|
||||
}
|
||||
|
||||
//for _, chat := range chats {
|
||||
// if user.IsInSpace(chat.Portal.Key) {
|
||||
// user.MarkInSpace(chat.Portal.Key)
|
||||
// if chat.Portal.IsPrivateChat() {
|
||||
// user.addPortalToSpace(chat.Portal)
|
||||
// }
|
||||
//var inSpace, ok bool
|
||||
//if inSpace, ok = existingKeys[chat.Portal.Key]; !ok || !inCommunity {
|
||||
// inCommunity = user.addPortalToCommunity(chat.Portal)
|
||||
// if chat.Portal.IsPrivateChat() {
|
||||
// puppet := user.bridge.GetPuppetByGMID(chat.Portal.Key.GMID)
|
||||
// user.ad.addPuppetToCommunity(puppet)
|
||||
// }
|
||||
//
|
||||
// portalKeys = append(portalKeys, chat.Portal.Key)
|
||||
//}
|
||||
user.log.Infoln("Read chat list, updating user-portal mapping")
|
||||
//portalKeys = append(portalKeys, chat.Portal.Key)
|
||||
//}
|
||||
//user.log.Infoln("Read chat list, updating user-portal mapping")
|
||||
|
||||
err := user.SetPortalKeys(portalKeys)
|
||||
if err != nil {
|
||||
@ -730,47 +773,6 @@ func (user *User) syncPortals(createAll bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (user *User) addPuppetToSpace(puppet *Puppet) bool {
|
||||
bot := user.bridge.Bot
|
||||
url := bot.BuildURL(mautrix.ClientURLPath{"groups", user.SpaceId, "admin", "users", "invite", puppet.MXID})
|
||||
blankReqBody := map[string]interface{}{}
|
||||
_, err := bot.MakeRequest(http.MethodPut, url, &blankReqBody, nil)
|
||||
if err != nil {
|
||||
user.log.Warnfln("Failed to invite %s to %s: %v", puppet.MXID, user.SpaceId, err)
|
||||
return false
|
||||
}
|
||||
reqBody := map[string]map[string]string{
|
||||
"m.visibility": {
|
||||
"type": "private",
|
||||
},
|
||||
}
|
||||
url = bot.BuildURLWithQuery(mautrix.ClientURLPath{"groups", user.SpaceId, "self", "accept_invite"}, map[string]string{
|
||||
"user_id": puppet.MXID.String(),
|
||||
})
|
||||
_, err = bot.MakeRequest(http.MethodPut, url, &reqBody, nil)
|
||||
if err != nil {
|
||||
user.log.Warnfln("Failed to join %s as %s: %v", user.SpaceId, puppet.MXID, err)
|
||||
return false
|
||||
}
|
||||
user.log.Debugln("Added", puppet.MXID, "to", user.SpaceId)
|
||||
return true
|
||||
}
|
||||
|
||||
func (user *User) addPortalToSpace(portal *Portal) bool {
|
||||
if portal.MXID == "" {
|
||||
return false
|
||||
}
|
||||
_, err := user.bridge.Bot.SendStateEvent(user.GetSpaceRoom(), event.StateSpaceChild, portal.MXID.String(), &event.SpaceChildEventContent{
|
||||
Via: []string{user.bridge.AS.HomeserverDomain},
|
||||
})
|
||||
if err != nil {
|
||||
user.log.Errorln("Failed to add portal space. RoomId: ", portal.MXID.String())
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (user *User) getDirectChats() map[id.UserID][]id.RoomID {
|
||||
res := make(map[id.UserID][]id.RoomID)
|
||||
privateChats := user.bridge.DB.Portal.FindPrivateChats(user.GMID)
|
||||
@ -782,78 +784,6 @@ func (user *User) getDirectChats() map[id.UserID][]id.RoomID {
|
||||
return res
|
||||
}
|
||||
|
||||
func (user *User) getSpaceRoom(ptr *id.RoomID, name, topic string, parent id.RoomID) id.RoomID {
|
||||
if len(*ptr) > 0 {
|
||||
return *ptr
|
||||
}
|
||||
user.spaceCreateLock.Lock()
|
||||
defer user.spaceCreateLock.Unlock()
|
||||
if len(*ptr) > 0 {
|
||||
return *ptr
|
||||
}
|
||||
|
||||
initialState := []*event.Event{{
|
||||
Type: event.StateRoomAvatar,
|
||||
Content: event.Content{
|
||||
Parsed: &event.RoomAvatarEventContent{
|
||||
URL: user.bridge.Config.AppService.Bot.ParsedAvatar,
|
||||
},
|
||||
},
|
||||
}}
|
||||
|
||||
if parent != "" {
|
||||
parentIDStr := parent.String()
|
||||
initialState = append(initialState, &event.Event{
|
||||
Type: event.StateSpaceParent,
|
||||
StateKey: &parentIDStr,
|
||||
Content: event.Content{
|
||||
Parsed: &event.SpaceParentEventContent{
|
||||
Canonical: true,
|
||||
Via: []string{user.bridge.AS.HomeserverDomain},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
resp, err := user.bridge.Bot.CreateRoom(&mautrix.ReqCreateRoom{
|
||||
Visibility: "private",
|
||||
Name: name,
|
||||
Topic: topic,
|
||||
InitialState: initialState,
|
||||
CreationContent: map[string]interface{}{
|
||||
"type": event.RoomTypeSpace,
|
||||
},
|
||||
PowerLevelOverride: &event.PowerLevelsEventContent{
|
||||
Users: map[id.UserID]int{
|
||||
user.bridge.Bot.UserID: 9001,
|
||||
user.MXID: 50,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
user.log.Errorln("Failed to auto-create space room", err)
|
||||
} else {
|
||||
*ptr = resp.RoomID
|
||||
user.Update()
|
||||
user.ensureInvited(user.bridge.Bot, resp.RoomID, true)
|
||||
|
||||
//if parent != "" {
|
||||
// _, err = user.bridge.Bot.SendStateEvent(parent, event.StateSpaceChild, resp.RoomID.String(), &event.SpaceChildEventContent{
|
||||
// Via: []string{user.bridge.AS.HomeserverDomain},
|
||||
// Order: " 0000",
|
||||
// })
|
||||
// if err != nil {
|
||||
// user.log.Error().Err(err).
|
||||
// Str("created_space_id", resp.RoomID.String()).
|
||||
// Str("parent_space_id", parent.String()).
|
||||
// Msg("Failed to add created space room to parent space")
|
||||
// }
|
||||
//}
|
||||
}
|
||||
return *ptr
|
||||
}
|
||||
|
||||
func (user *User) updateAvatar(gmdi groupme.ID, avatarID *string, avatarURL *id.ContentURI, avatarSet *bool,
|
||||
log log.Logger, intent *appservice.IntentAPI) bool {
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user