Task Attachments #104

Merged
konrad merged 63 commits from feature/attachments into master 2019-10-16 20:52:31 +00:00
2 changed files with 18 additions and 5 deletions
Showing only changes of commit 7d6e6d49fd - Show all commits

View File

@ -20,18 +20,27 @@ import "code.vikunja.io/web"
// CanRead checks if the user can see an attachment
func (ta *TaskAttachment) CanRead(a web.Auth) (bool, error) {
t := Task{ID: ta.TaskID}
t, err := GetTaskByIDSimple(ta.TaskID)
if err != nil {
return false, err
}
return t.CanRead(a)
}
// CanDelete checks if the user can delete an attachment
func (ta *TaskAttachment) CanDelete(a web.Auth) (bool, error) {
t := Task{ID: ta.TaskID}
t, err := GetTaskByIDSimple(ta.TaskID)
if err != nil {
return false, err
}
return t.CanWrite(a)
}
// CanCreate checks if the user can create an attachment
func (ta *TaskAttachment) CanCreate(a web.Auth) (bool, error) {
t := Task{ID: ta.TaskID}
t, err := GetTaskByIDSimple(ta.TaskID)
if err != nil {
return false, err
}
return t.CanCreate(a)
}

View File

@ -99,8 +99,12 @@ func GetTaskAttachment(c echo.Context) error {
return handler.HandleHTTPError(err, c)
}
// Send the file to the client
taskAttachment.File.LoadFileByID()
// Open an send the file to the client
err = taskAttachment.File.LoadFileByID()
if err != nil {
return handler.HandleHTTPError(err, c)
}
http.ServeContent(c.Response(), c.Request(), taskAttachment.File.Name, taskAttachment.File.Created, taskAttachment.File.File)
return nil
}