-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API management for issue/pull and comment attachments (#21783)
Close #14601 Fix #3690 Revive of #14601. Updated to current code, cleanup and added more read/write checks. Signed-off-by: Andrew Thornton <[email protected]> Signed-off-by: Andre Bruch <[email protected]> Co-authored-by: zeripath <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: Norwin <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
- Loading branch information
1 parent
8fb1e53
commit 3c59d31
Showing
21 changed files
with
1,809 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2021 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package convert | ||
|
||
import ( | ||
repo_model "code.gitea.io/gitea/models/repo" | ||
api "code.gitea.io/gitea/modules/structs" | ||
) | ||
|
||
// ToAttachment converts models.Attachment to api.Attachment | ||
func ToAttachment(a *repo_model.Attachment) *api.Attachment { | ||
return &api.Attachment{ | ||
ID: a.ID, | ||
Name: a.Name, | ||
Created: a.CreatedUnix.AsTime(), | ||
DownloadCount: a.DownloadCount, | ||
Size: a.Size, | ||
UUID: a.UUID, | ||
DownloadURL: a.DownloadURL(), | ||
} | ||
} | ||
|
||
func ToAttachments(attachments []*repo_model.Attachment) []*api.Attachment { | ||
converted := make([]*api.Attachment, 0, len(attachments)) | ||
for _, attachment := range attachments { | ||
converted = append(converted, ToAttachment(attachment)) | ||
} | ||
return converted | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.