1
0

Fixed a bug where deleting an attachment would cause a nil panic

This commit is contained in:
kolaente
2019-11-19 23:07:48 +01:00
parent c203d73b33
commit dcec9511dc
3 changed files with 65 additions and 8 deletions

View File

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