Add support for setting group description from Matrix

This commit is contained in:
Tulir Asokan 2020-03-31 16:27:42 +03:00
parent 3f60a6f28e
commit 78d3d22cd4
4 changed files with 8 additions and 6 deletions

View file

@ -18,7 +18,7 @@
* [ ] Room metadata changes
* [x] Name
* [ ] Avatar<sup>[1]</sup>
* [ ] Topic<sup>[1]</sup>
* [x] Topic
* [ ] Initial room metadata
* WhatsApp → Matrix
* [x] Message content

5
go.mod
View file

@ -5,8 +5,7 @@ go 1.14
require (
github.com/Rhymen/go-whatsapp v0.1.0
github.com/chai2010/webp v1.1.0
github.com/gorilla/mux v1.7.4
github.com/gorilla/websocket v1.4.2
github.com/gorilla/websocket v1.4.1
github.com/lib/pq v1.3.0
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/pkg/errors v0.9.1
@ -19,4 +18,4 @@ require (
maunium.net/go/mautrix-appservice v0.1.0-alpha.6
)
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.2.1
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.2.2

3
go.sum
View file

@ -6,6 +6,7 @@ github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
@ -31,6 +32,8 @@ github.com/tulir/go-whatsapp v0.2.0 h1:JWK/Xxrc1qsZsVz6gYVX5AtvzYmqaHNjt34Ipnrgz
github.com/tulir/go-whatsapp v0.2.0/go.mod h1:gyw9zGup1/Y3ZQUueZaqz3iR/WX9a2Lth4aqEbXjkok=
github.com/tulir/go-whatsapp v0.2.1 h1:Owoss2AbvZMgt3nxoFlsG+bqLHDnO+PhXNhhoCmb/3M=
github.com/tulir/go-whatsapp v0.2.1/go.mod h1:gyw9zGup1/Y3ZQUueZaqz3iR/WX9a2Lth4aqEbXjkok=
github.com/tulir/go-whatsapp v0.2.2 h1:uF2NQC6JSFUjA1Roj2KgFFzMHiSOrejk4Af/eLygr7I=
github.com/tulir/go-whatsapp v0.2.2/go.mod h1:gyw9zGup1/Y3ZQUueZaqz3iR/WX9a2Lth4aqEbXjkok=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

View file

@ -157,9 +157,9 @@ func (mx *MatrixHandler) HandleRoomMetadata(evt *mautrix.Event) {
switch evt.Type {
case mautrix.StateRoomName:
resp, err = user.Conn.UpdateGroupSubject(evt.Content.Name, portal.Key.JID)
case mautrix.StateRoomAvatar:
return
case mautrix.StateTopic:
resp, err = user.Conn.UpdateGroupDescription(portal.Key.JID, evt.Content.Topic)
case mautrix.StateRoomAvatar:
return
}
if err != nil {