mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-15 05:32:25 +03:00
url preview test version
Signed-off-by: Aleksandr Dubovikov <d.lexand@gmail.com>
This commit is contained in:
parent
6cd1285ca0
commit
5845244aa9
7 changed files with 542 additions and 1 deletions
|
@ -30,6 +30,14 @@ type MediaAPI struct {
|
|||
|
||||
// A list of thumbnail sizes to be pre-generated for downloaded remote / uploaded content
|
||||
ThumbnailSizes []ThumbnailSize `yaml:"thumbnail_sizes"`
|
||||
|
||||
// The time in seconds to cache URL previews for
|
||||
UrlPreviewCacheTime int `yaml:"url_preview_cache_time"`
|
||||
|
||||
// The timeout in milliseconds for fetching URL previews
|
||||
UrlPreviewTimeout int `yaml:"url_preview_timeout"`
|
||||
|
||||
UrlPreviewThumbnailSize ThumbnailSize `yaml:"url_preview_thumbnail_size"`
|
||||
}
|
||||
|
||||
// DefaultMaxFileSizeBytes defines the default file size allowed in transfers
|
||||
|
@ -38,6 +46,9 @@ var DefaultMaxFileSizeBytes = FileSizeBytes(10485760)
|
|||
func (c *MediaAPI) Defaults(opts DefaultOpts) {
|
||||
c.MaxFileSizeBytes = DefaultMaxFileSizeBytes
|
||||
c.MaxThumbnailGenerators = 10
|
||||
c.UrlPreviewCacheTime = 10
|
||||
c.UrlPreviewTimeout = 10000
|
||||
|
||||
if opts.Generate {
|
||||
c.ThumbnailSizes = []ThumbnailSize{
|
||||
{
|
||||
|
@ -61,6 +72,12 @@ func (c *MediaAPI) Defaults(opts DefaultOpts) {
|
|||
}
|
||||
c.BasePath = "./media_store"
|
||||
}
|
||||
|
||||
c.UrlPreviewThumbnailSize = ThumbnailSize{
|
||||
Width: 200,
|
||||
Height: 200,
|
||||
ResizeMethod: "scale",
|
||||
}
|
||||
}
|
||||
|
||||
func (c *MediaAPI) Verify(configErrs *ConfigErrors) {
|
||||
|
@ -76,4 +93,11 @@ func (c *MediaAPI) Verify(configErrs *ConfigErrors) {
|
|||
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
||||
checkNotEmpty(configErrs, "media_api.database.connection_string", string(c.Database.ConnectionString))
|
||||
}
|
||||
|
||||
// If MaxFileSizeBytes overflows int64, default to DefaultMaxFileSizeBytes
|
||||
if c.MaxFileSizeBytes+1 <= 0 {
|
||||
c.MaxFileSizeBytes = DefaultMaxFileSizeBytes
|
||||
fmt.Printf("Configured MediaApi.MaxFileSizeBytes overflows int64, defaulting to %d bytes", DefaultMaxFileSizeBytes)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue