Skip to content

Commit 28625a4

Browse files
authored
Merge pull request #327 from t3chguy/msc2448
Fix MSC2448 implementation
2 parents 47226a3 + fe06d9c commit 28625a4

File tree

5 files changed

+2
-129
lines changed

5 files changed

+2
-129
lines changed

api/features/feature_routes.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import (
44
"net/http"
55
)
66

7-
const MSC2448UploadRoute = "/_matrix/media/unstable/xyz.amorgan/upload"
8-
const MSC2448GetHashRoute = "/_matrix/media/unstable/xyz.amorgan/download/{server:[a-zA-Z0-9.:\\-_]+}/{mediaId:[^/]+}/blurhash"
9-
const MSC2448AltRenderRoute = "/_matrix/media/unstable/io.t2bot.msc2448/blurhash/{blurhash:[^/]+}"
107
const IPFSDownloadRoute = "/_matrix/media/unstable/io.t2bot.ipfs/download/{server:[a-zA-Z0-9.:\\-_]+}/{ipfsContentId:[^/]+}"
118
const IPFSLiveDownloadRouteR0 = "/_matrix/media/r0/download/{server:[a-zA-Z0-9.:\\-_]+}/ipfs:{ipfsContentId:[^/]+}"
129
const IPFSLiveDownloadRouteV1 = "/_matrix/media/v1/download/{server:[a-zA-Z0-9.:\\-_]+}/ipfs:{ipfsContentId:[^/]+}"

api/r0/upload.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/sirupsen/logrus"
1111
"github.com/turt2live/matrix-media-repo/api"
12-
"github.com/turt2live/matrix-media-repo/api/features"
1312
"github.com/turt2live/matrix-media-repo/common"
1413
"github.com/turt2live/matrix-media-repo/common/rcontext"
1514
"github.com/turt2live/matrix-media-repo/controllers/info_controller"
@@ -20,7 +19,7 @@ import (
2019

2120
type MediaUploadedResponse struct {
2221
ContentUri string `json:"content_uri"`
23-
Blurhash string `json:"blurhash,omitempty"`
22+
Blurhash string `json:"xyz.amorgan.blurhash,omitempty"`
2423
}
2524

2625
func UploadMedia(r *http.Request, rctx rcontext.RequestContext, user api.UserInfo) interface{} {
@@ -73,7 +72,7 @@ func UploadMedia(r *http.Request, rctx rcontext.RequestContext, user api.UserInf
7372
return api.InternalServerError("Unexpected Error")
7473
}
7574

76-
if rctx.Config.Features.MSC2448Blurhash.Enabled && features.IsRoute(r, features.MSC2448UploadRoute) {
75+
if rctx.Config.Features.MSC2448Blurhash.Enabled {
7776
hash, err := info_controller.GetOrCalculateBlurhash(media, rctx)
7877
if err != nil {
7978
rctx.Log.Warn("Failed to calculate blurhash: " + err.Error())

api/unstable/blurhash_get.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

api/unstable/blurhash_render.go

Lines changed: 0 additions & 72 deletions
This file was deleted.

api/webserver/webserver.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ func Init() *sync.WaitGroup {
7979
appendToImportHandler := handler{api.RepoAdminRoute(custom.AppendToImport), "append_to_import", counter, false}
8080
stopImportHandler := handler{api.RepoAdminRoute(custom.StopImport), "stop_import", counter, false}
8181
versionHandler := handler{api.AccessTokenOptionalRoute(custom.GetVersion), "get_version", counter, false}
82-
blurhashRenderHandler := handler{api.AccessTokenRequiredRoute(unstable.RenderBlurhash), "render_blurhash", counter, false}
83-
blurhashCalcHandler := handler{api.AccessTokenRequiredRoute(unstable.GetBlurhash), "calculate_blurhash", counter, false}
8482
ipfsDownloadHandler := handler{api.AccessTokenOptionalRoute(unstable.IPFSDownload), "ipfs_download", counter, false}
8583
logoutHandler := handler{api.AccessTokenRequiredRoute(r0.Logout), "logout", counter, false}
8684
logoutAllHandler := handler{api.AccessTokenRequiredRoute(r0.LogoutAll), "logout_all", counter, false}
@@ -154,12 +152,6 @@ func Init() *sync.WaitGroup {
154152
}
155153
}
156154

157-
if config.Get().Features.MSC2448Blurhash.Enabled {
158-
routes[features.MSC2448UploadRoute] = route{"POST", uploadHandler}
159-
routes[features.MSC2448GetHashRoute] = route{"GET", blurhashCalcHandler}
160-
routes[features.MSC2448AltRenderRoute] = route{"GET", blurhashRenderHandler}
161-
}
162-
163155
if config.Get().Features.IPFS.Enabled {
164156
routes[features.IPFSDownloadRoute] = route{"GET", ipfsDownloadHandler}
165157
routes[features.IPFSLiveDownloadRouteR0] = route{"GET", ipfsDownloadHandler}

0 commit comments

Comments
 (0)