1
0

Add events (#777)

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/api/pulls/777
Co-authored-by: konrad <konrad@kola-entertainments.de>
Co-committed-by: konrad <konrad@kola-entertainments.de>
This commit is contained in:
konrad
2021-02-02 22:48:37 +00:00
parent a71aa0c898
commit 0ab9ce9ec4
70 changed files with 1636 additions and 283 deletions

View File

@ -80,7 +80,7 @@ func (ta *TaskAttachment) NewAttachment(s *xorm.Session, f io.ReadCloser, realna
}
// ReadOne returns a task attachment
func (ta *TaskAttachment) ReadOne(s *xorm.Session) (err error) {
func (ta *TaskAttachment) ReadOne(s *xorm.Session, a web.Auth) (err error) {
exists, err := s.Where("id = ?", ta.ID).Get(ta)
if err != nil {
return
@ -176,9 +176,9 @@ func (ta *TaskAttachment) ReadAll(s *xorm.Session, a web.Auth, search string, pa
// @Failure 404 {object} models.Message "The task does not exist."
// @Failure 500 {object} models.Message "Internal error"
// @Router /tasks/{id}/attachments/{attachmentID} [delete]
func (ta *TaskAttachment) Delete(s *xorm.Session) error {
func (ta *TaskAttachment) Delete(s *xorm.Session, a web.Auth) error {
// Load the attachment
err := ta.ReadOne(s)
err := ta.ReadOne(s, a)
if err != nil && !files.IsErrFileDoesNotExist(err) {
return err
}
@ -209,6 +209,10 @@ func getTaskAttachmentsByTaskIDs(s *xorm.Session, taskIDs []int64) (attachments
return
}
if len(attachments) == 0 {
return
}
fileIDs := []int64{}
userIDs := []int64{}
for _, a := range attachments {