|
9 | 9 | "fmt" |
10 | 10 | "path" |
11 | 11 | "regexp" |
| 12 | + "strconv" |
12 | 13 | "strings" |
13 | 14 | "time" |
14 | 15 | "unicode" |
@@ -77,6 +78,9 @@ type Action struct { |
77 | 78 | ActUser *User `xorm:"-"` |
78 | 79 | RepoID int64 `xorm:"INDEX"` |
79 | 80 | Repo *Repository `xorm:"-"` |
| 81 | + CommentID int64 `xorm:"INDEX"` |
| 82 | + Comment *Comment `xorm:"-"` |
| 83 | + IsDeleted bool `xorm:"INDEX NOT NULL DEFAULT false"` |
80 | 84 | RefName string |
81 | 85 | IsPrivate bool `xorm:"INDEX NOT NULL DEFAULT false"` |
82 | 86 | Content string `xorm:"TEXT"` |
@@ -191,6 +195,35 @@ func (a *Action) GetRepoLink() string { |
191 | 195 | return "/" + a.GetRepoPath() |
192 | 196 | } |
193 | 197 |
|
| 198 | +// GetCommentLink returns link to action comment. |
| 199 | +func (a *Action) GetCommentLink() string { |
| 200 | + if a == nil { |
| 201 | + return "#" |
| 202 | + } |
| 203 | + if a.Comment == nil && a.CommentID != 0 { |
| 204 | + a.Comment, _ = GetCommentByID(a.CommentID) |
| 205 | + } |
| 206 | + if a.Comment != nil { |
| 207 | + return a.Comment.HTMLURL() |
| 208 | + } |
| 209 | + if len(a.GetIssueInfos()) == 0 { |
| 210 | + return "#" |
| 211 | + } |
| 212 | + //Return link to issue |
| 213 | + issueIDString := a.GetIssueInfos()[0] |
| 214 | + issueID, err := strconv.ParseInt(issueIDString, 10, 64) |
| 215 | + if err != nil { |
| 216 | + return "#" |
| 217 | + } |
| 218 | + |
| 219 | + issue, err := GetIssueByID(issueID) |
| 220 | + if err != nil { |
| 221 | + return "#" |
| 222 | + } |
| 223 | + |
| 224 | + return issue.HTMLURL() |
| 225 | +} |
| 226 | + |
194 | 227 | // GetBranch returns the action's repository branch. |
195 | 228 | func (a *Action) GetBranch() string { |
196 | 229 | return a.RefName |
@@ -678,6 +711,7 @@ type GetFeedsOptions struct { |
678 | 711 | RequestingUserID int64 |
679 | 712 | IncludePrivate bool // include private actions |
680 | 713 | OnlyPerformedBy bool // only actions performed by requested user |
| 714 | + IncludeDeleted bool // include deleted actions |
681 | 715 | } |
682 | 716 |
|
683 | 717 | // GetFeeds returns actions according to the provided options |
@@ -706,5 +740,11 @@ func GetFeeds(opts GetFeedsOptions) ([]*Action, error) { |
706 | 740 | if opts.RequestedUser.IsOrganization() { |
707 | 741 | sess.In("repo_id", repoIDs) |
708 | 742 | } |
| 743 | + |
| 744 | + if !opts.IncludeDeleted { |
| 745 | + sess.And("is_deleted = ?", false) |
| 746 | + |
| 747 | + } |
| 748 | + |
709 | 749 | return actions, sess.Find(&actions) |
710 | 750 | } |
0 commit comments