Add config options for task attachments (#125)
Add config options for task attachments Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/125
This commit is contained in:
parent
b2b1546a8f
commit
fc65052ba0
5 changed files with 41 additions and 31 deletions
|
@ -24,6 +24,8 @@ service:
|
||||||
enablelinksharing: true
|
enablelinksharing: true
|
||||||
# Whether to let new users registering themselves or not
|
# Whether to let new users registering themselves or not
|
||||||
enableregistration: true
|
enableregistration: true
|
||||||
|
# Whether to enable task attachments or not
|
||||||
|
enabletaskattachments: true
|
||||||
|
|
||||||
database:
|
database:
|
||||||
# Database type to use. Supported types are mysql and sqlite.
|
# Database type to use. Supported types are mysql and sqlite.
|
||||||
|
|
|
@ -67,6 +67,8 @@ service:
|
||||||
enablelinksharing: true
|
enablelinksharing: true
|
||||||
# Whether to let new users registering themselves or not
|
# Whether to let new users registering themselves or not
|
||||||
enableregistration: true
|
enableregistration: true
|
||||||
|
# Whether to enable task attachments or not
|
||||||
|
enabletaskattachments: true
|
||||||
|
|
||||||
database:
|
database:
|
||||||
# Database type to use. Supported types are mysql and sqlite.
|
# Database type to use. Supported types are mysql and sqlite.
|
||||||
|
|
|
@ -33,16 +33,17 @@ type Key string
|
||||||
|
|
||||||
// These constants hold all config value keys
|
// These constants hold all config value keys
|
||||||
const (
|
const (
|
||||||
ServiceJWTSecret Key = `service.JWTSecret`
|
ServiceJWTSecret Key = `service.JWTSecret`
|
||||||
ServiceInterface Key = `service.interface`
|
ServiceInterface Key = `service.interface`
|
||||||
ServiceFrontendurl Key = `service.frontendurl`
|
ServiceFrontendurl Key = `service.frontendurl`
|
||||||
ServiceEnableCaldav Key = `service.enablecaldav`
|
ServiceEnableCaldav Key = `service.enablecaldav`
|
||||||
ServiceRootpath Key = `service.rootpath`
|
ServiceRootpath Key = `service.rootpath`
|
||||||
ServiceMaxItemsPerPage Key = `service.maxitemsperpage`
|
ServiceMaxItemsPerPage Key = `service.maxitemsperpage`
|
||||||
ServiceEnableMetrics Key = `service.enablemetrics`
|
ServiceEnableMetrics Key = `service.enablemetrics`
|
||||||
ServiceMotd Key = `service.motd`
|
ServiceMotd Key = `service.motd`
|
||||||
ServiceEnableLinkSharing Key = `service.enablelinksharing`
|
ServiceEnableLinkSharing Key = `service.enablelinksharing`
|
||||||
ServiceEnableRegistration Key = `service.enableregistration`
|
ServiceEnableRegistration Key = `service.enableregistration`
|
||||||
|
ServiceEnableTaskAttachments Key = `service.enabletaskattachments`
|
||||||
|
|
||||||
DatabaseType Key = `database.type`
|
DatabaseType Key = `database.type`
|
||||||
DatabaseHost Key = `database.host`
|
DatabaseHost Key = `database.host`
|
||||||
|
@ -166,6 +167,7 @@ func InitDefaultConfig() {
|
||||||
ServiceMotd.setDefault("")
|
ServiceMotd.setDefault("")
|
||||||
ServiceEnableLinkSharing.setDefault(true)
|
ServiceEnableLinkSharing.setDefault(true)
|
||||||
ServiceEnableRegistration.setDefault(true)
|
ServiceEnableRegistration.setDefault(true)
|
||||||
|
ServiceEnableTaskAttachments.setDefault(true)
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
DatabaseType.setDefault("sqlite")
|
DatabaseType.setDefault("sqlite")
|
||||||
|
|
|
@ -24,13 +24,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type vikunjaInfos struct {
|
type vikunjaInfos struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
FrontendURL string `json:"frontend_url"`
|
FrontendURL string `json:"frontend_url"`
|
||||||
Motd string `json:"motd"`
|
Motd string `json:"motd"`
|
||||||
LinkSharingEnabled bool `json:"link_sharing_enabled"`
|
LinkSharingEnabled bool `json:"link_sharing_enabled"`
|
||||||
MaxFileSize string `json:"max_file_size"`
|
MaxFileSize string `json:"max_file_size"`
|
||||||
RegistrationEnabled bool `json:"registration_enabled"`
|
RegistrationEnabled bool `json:"registration_enabled"`
|
||||||
AvailableMigrators []string `json:"available_migrators"`
|
AvailableMigrators []string `json:"available_migrators"`
|
||||||
|
TaskAttachmentsEnabled bool `json:"task_attachments_enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info is the handler to get infos about this vikunja instance
|
// Info is the handler to get infos about this vikunja instance
|
||||||
|
@ -42,12 +43,13 @@ type vikunjaInfos struct {
|
||||||
// @Router /info [get]
|
// @Router /info [get]
|
||||||
func Info(c echo.Context) error {
|
func Info(c echo.Context) error {
|
||||||
infos := vikunjaInfos{
|
infos := vikunjaInfos{
|
||||||
Version: version.Version,
|
Version: version.Version,
|
||||||
FrontendURL: config.ServiceFrontendurl.GetString(),
|
FrontendURL: config.ServiceFrontendurl.GetString(),
|
||||||
Motd: config.ServiceMotd.GetString(),
|
Motd: config.ServiceMotd.GetString(),
|
||||||
LinkSharingEnabled: config.ServiceEnableLinkSharing.GetBool(),
|
LinkSharingEnabled: config.ServiceEnableLinkSharing.GetBool(),
|
||||||
MaxFileSize: config.FilesMaxSize.GetString(),
|
MaxFileSize: config.FilesMaxSize.GetString(),
|
||||||
RegistrationEnabled: config.ServiceEnableRegistration.GetBool(),
|
RegistrationEnabled: config.ServiceEnableRegistration.GetBool(),
|
||||||
|
TaskAttachmentsEnabled: config.ServiceEnableTaskAttachments.GetBool(),
|
||||||
}
|
}
|
||||||
if config.MigrationWunderlistEnable.GetBool() {
|
if config.MigrationWunderlistEnable.GetBool() {
|
||||||
infos.AvailableMigrators = append(infos.AvailableMigrators, "wunderlist")
|
infos.AvailableMigrators = append(infos.AvailableMigrators, "wunderlist")
|
||||||
|
|
|
@ -288,15 +288,17 @@ func registerAPIRoutes(a *echo.Group) {
|
||||||
a.PUT("/tasks/:task/relations", taskRelationHandler.CreateWeb)
|
a.PUT("/tasks/:task/relations", taskRelationHandler.CreateWeb)
|
||||||
a.DELETE("/tasks/:task/relations", taskRelationHandler.DeleteWeb)
|
a.DELETE("/tasks/:task/relations", taskRelationHandler.DeleteWeb)
|
||||||
|
|
||||||
taskAttachmentHandler := &handler.WebHandler{
|
if config.ServiceEnableTaskAttachments.GetBool() {
|
||||||
EmptyStruct: func() handler.CObject {
|
taskAttachmentHandler := &handler.WebHandler{
|
||||||
return &models.TaskAttachment{}
|
EmptyStruct: func() handler.CObject {
|
||||||
},
|
return &models.TaskAttachment{}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
a.GET("/tasks/:task/attachments", taskAttachmentHandler.ReadAllWeb)
|
||||||
|
a.DELETE("/tasks/:task/attachments/:attachment", taskAttachmentHandler.DeleteWeb)
|
||||||
|
a.PUT("/tasks/:task/attachments", apiv1.UploadTaskAttachment)
|
||||||
|
a.GET("/tasks/:task/attachments/:attachment", apiv1.GetTaskAttachment)
|
||||||
}
|
}
|
||||||
a.GET("/tasks/:task/attachments", taskAttachmentHandler.ReadAllWeb)
|
|
||||||
a.DELETE("/tasks/:task/attachments/:attachment", taskAttachmentHandler.DeleteWeb)
|
|
||||||
a.PUT("/tasks/:task/attachments", apiv1.UploadTaskAttachment)
|
|
||||||
a.GET("/tasks/:task/attachments/:attachment", apiv1.GetTaskAttachment)
|
|
||||||
|
|
||||||
labelHandler := &handler.WebHandler{
|
labelHandler := &handler.WebHandler{
|
||||||
EmptyStruct: func() handler.CObject {
|
EmptyStruct: func() handler.CObject {
|
||||||
|
|
Loading…
Reference in a new issue