mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 19:33:09 -06:00
Rely on EventBuilder in gmsl to generate the event IDs for us
This commit is contained in:
parent
2d10757653
commit
5530f16e3f
|
|
@ -379,16 +379,8 @@ func buildEvent(
|
|||
return nil, err
|
||||
}
|
||||
builder.AuthEvents = refs
|
||||
eventID := ""
|
||||
eventIDFormat, err := roomVersion.EventIDFormat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if eventIDFormat == gomatrixserverlib.EventIDFormatV1 {
|
||||
eventID = fmt.Sprintf("$%s:%s", util.RandomString(16), cfg.Matrix.ServerName)
|
||||
}
|
||||
event, err := builder.Build(
|
||||
eventID, evTime, cfg.Matrix.ServerName, cfg.Matrix.KeyID,
|
||||
evTime, cfg.Matrix.ServerName, cfg.Matrix.KeyID,
|
||||
cfg.Matrix.PrivateKey, roomVersion,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -342,16 +342,8 @@ func (r joinRoomReq) joinRoomUsingServer(roomID string, server gomatrixserverlib
|
|||
}, nil
|
||||
}
|
||||
|
||||
eventIDFormat, err := respMakeJoin.RoomVersion.EventIDFormat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
eventID := ""
|
||||
if eventIDFormat == gomatrixserverlib.EventIDFormatV1 {
|
||||
eventID = fmt.Sprintf("$%s:%s", util.RandomString(16), r.cfg.Matrix.ServerName)
|
||||
}
|
||||
event, err := respMakeJoin.JoinEvent.Build(
|
||||
eventID, r.evTime, r.cfg.Matrix.ServerName, r.cfg.Matrix.KeyID,
|
||||
r.evTime, r.cfg.Matrix.ServerName, r.cfg.Matrix.KeyID,
|
||||
r.cfg.Matrix.PrivateKey, respMakeJoin.RoomVersion,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -103,13 +103,12 @@ func main() {
|
|||
// Build an event and write the event to the output.
|
||||
func buildAndOutput() gomatrixserverlib.EventReference {
|
||||
eventID++
|
||||
id := fmt.Sprintf("$%d:%s", eventID, *serverName)
|
||||
now = time.Unix(0, 0)
|
||||
name := gomatrixserverlib.ServerName(*serverName)
|
||||
key := gomatrixserverlib.KeyID(*keyID)
|
||||
|
||||
event, err := b.Build(
|
||||
id, now, name, key, privateKey,
|
||||
now, name, key, privateKey,
|
||||
gomatrixserverlib.RoomVersionV1,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -17,14 +17,12 @@ package common
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/dendrite/common/config"
|
||||
"github.com/matrix-org/dendrite/roomserver/api"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/util"
|
||||
)
|
||||
|
||||
// ErrRoomNoExists is returned when trying to lookup the state of a room that
|
||||
|
|
@ -51,17 +49,8 @@ func BuildEvent(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
eventID := ""
|
||||
eventIDFormat, err := queryRes.RoomVersion.EventIDFormat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if eventIDFormat == gomatrixserverlib.EventIDFormatV1 {
|
||||
eventID = fmt.Sprintf("$%s:%s", util.RandomString(16), cfg.Matrix.ServerName)
|
||||
}
|
||||
|
||||
event, err := builder.Build(
|
||||
eventID, evTime, cfg.Matrix.ServerName, cfg.Matrix.KeyID,
|
||||
evTime, cfg.Matrix.ServerName, cfg.Matrix.KeyID,
|
||||
cfg.Matrix.PrivateKey, queryRes.RoomVersion,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
|
@ -310,16 +309,8 @@ func buildMembershipEvent(
|
|||
}
|
||||
builder.AuthEvents = refs
|
||||
|
||||
eventID := ""
|
||||
eventIDFormat, err := queryRes.RoomVersion.EventIDFormat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if eventIDFormat == gomatrixserverlib.EventIDFormatV1 {
|
||||
eventID = fmt.Sprintf("$%s:%s", util.RandomString(16), cfg.Matrix.ServerName)
|
||||
}
|
||||
event, err := builder.Build(
|
||||
eventID, time.Now(), cfg.Matrix.ServerName, cfg.Matrix.KeyID,
|
||||
time.Now(), cfg.Matrix.ServerName, cfg.Matrix.KeyID,
|
||||
cfg.Matrix.PrivateKey, queryRes.RoomVersion,
|
||||
)
|
||||
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -9,7 +9,7 @@ require (
|
|||
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200318135427-31631a9ef51f
|
||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20200304164012-aa524245b658
|
||||
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200327141825-4c04d7773f61
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200327143012-be83dab84222
|
||||
github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1
|
||||
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7
|
||||
github.com/mattn/go-sqlite3 v2.0.2+incompatible
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -168,6 +168,8 @@ github.com/matrix-org/gomatrixserverlib v0.0.0-20200327141230-2e491c5d6d12 h1:le
|
|||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200327141230-2e491c5d6d12/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200327141825-4c04d7773f61 h1:9ctc7P784fnLURt+5PV04cpbpX9o6qZRHATmXS75w7c=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200327141825-4c04d7773f61/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200327143012-be83dab84222 h1:b8u7o03EGemkblBgAvwtpCjVXKwzBZ794uCco/Urv6Y=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200327143012-be83dab84222/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1 h1:osLoFdOy+ChQqVUn2PeTDETFftVkl4w9t/OW18g3lnk=
|
||||
github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1/go.mod h1:cXoYQIENbdWIQHt1SyCo6Bl3C3raHwJ0wgVrXHSqf+A=
|
||||
github.com/matrix-org/util v0.0.0-20171127121716-2e2df66af2f5 h1:W7l5CP4V7wPyPb4tYE11dbmeAOwtFQBTW0rf4OonOS8=
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ package alias
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
|
@ -250,17 +249,9 @@ func (r *RoomserverAliasAPI) sendUpdatedAliasesEvent(
|
|||
}
|
||||
|
||||
// Build the event
|
||||
eventID := ""
|
||||
eventIDFormat, err := roomVersion.EventIDFormat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if eventIDFormat == gomatrixserverlib.EventIDFormatV1 {
|
||||
eventID = fmt.Sprintf("$%s:%s", util.RandomString(16), r.Cfg.Matrix.ServerName)
|
||||
}
|
||||
now := time.Now()
|
||||
event, err := builder.Build(
|
||||
eventID, now, r.Cfg.Matrix.ServerName, r.Cfg.Matrix.KeyID,
|
||||
now, r.Cfg.Matrix.ServerName, r.Cfg.Matrix.KeyID,
|
||||
r.Cfg.Matrix.PrivateKey, roomVersion,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue