diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-05-25 13:37:15 +0100 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-05-25 13:37:15 +0100 |
commit | 9ce3898d03445df97e5dba3701628100ef8b3051 (patch) | |
tree | 18c1dab918accec6f400a0d5bc5ca874f96480fb /cmd | |
parent | 81843e8836e6f8f334c7b5fd1433c427c10a9443 (diff) |
Fix the `resolve-state` tool
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/resolve-state/main.go | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/cmd/resolve-state/main.go b/cmd/resolve-state/main.go index c52fd6c4..3a9f3ce4 100644 --- a/cmd/resolve-state/main.go +++ b/cmd/resolve-state/main.go @@ -4,13 +4,14 @@ import ( "context" "flag" "fmt" - "os" "strconv" "github.com/matrix-org/dendrite/internal/caching" "github.com/matrix-org/dendrite/roomserver/storage" "github.com/matrix-org/dendrite/roomserver/types" "github.com/matrix-org/dendrite/setup" + "github.com/matrix-org/dendrite/setup/base" + "github.com/matrix-org/dendrite/setup/config" "github.com/matrix-org/gomatrixserverlib" ) @@ -23,11 +24,17 @@ import ( // e.g. ./resolve-state --roomversion=5 1254 1235 1282 var roomVersion = flag.String("roomversion", "5", "the room version to parse events as") +var filterType = flag.String("filtertype", "", "the event types to filter on") func main() { ctx := context.Background() cfg := setup.ParseFlags(true) - args := os.Args[1:] + cfg.Logging = append(cfg.Logging[:0], config.LogrusHook{ + Type: "std", + Level: "error", + }) + base := base.NewBaseDendrite(cfg, "ResolveState", base.DisableMetrics) + args := flag.Args() fmt.Println("Room version", *roomVersion) @@ -45,7 +52,7 @@ func main() { panic(err) } - roomserverDB, err := storage.Open(nil, &cfg.RoomServer.Database, cache) + roomserverDB, err := storage.Open(base, &cfg.RoomServer.Database, cache) if err != nil { panic(err) } @@ -113,9 +120,18 @@ func main() { } fmt.Println("Resolved state contains", len(resolved), "events") + filteringEventType := *filterType + count := 0 for _, event := range resolved { + if filteringEventType != "" && event.Type() != filteringEventType { + continue + } + count++ fmt.Println() fmt.Printf("* %s %s %q\n", event.EventID(), event.Type(), *event.StateKey()) fmt.Printf(" %s\n", string(event.Content())) } + + fmt.Println() + fmt.Println("Returned", count, "state events after filtering") } |