From e20fbc9b2b310843d55308739bee17a98a1ee494 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 22 Nov 2023 20:20:45 -0700 Subject: [PATCH] Add Dendrite importer --- .../import_dendrite/main.go | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cmd/homeserver_live_importers/import_dendrite/main.go diff --git a/cmd/homeserver_live_importers/import_dendrite/main.go b/cmd/homeserver_live_importers/import_dendrite/main.go new file mode 100644 index 00000000..9555827e --- /dev/null +++ b/cmd/homeserver_live_importers/import_dendrite/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "github.com/turt2live/matrix-media-repo/cmd/homeserver_live_importers/_common" + "github.com/turt2live/matrix-media-repo/common/rcontext" + "github.com/turt2live/matrix-media-repo/homeserver_interop/dendrite" +) + +func main() { + cfg := _common.InitImportPsqlMatrixDownload("Dendrite") + ctx := rcontext.InitialNoConfig() + + ctx.Log.Debug("Connecting to homeserver database...") + hsDb, err := dendrite.OpenDatabase(cfg.ConnectionString, cfg.ServerName) + if err != nil { + panic(err) + } + + _common.PsqlMatrixDownloadCopy[dendrite.LocalMedia](ctx, cfg, hsDb, func(record *dendrite.LocalMedia) (*_common.MediaMetadata, error) { + return &_common.MediaMetadata{ + MediaId: record.MediaId, + ContentType: record.ContentType, + FileName: record.UploadName, + UploaderUserId: record.UserId, + SizeBytes: record.FileSizeBytes, + }, nil + }) +}