summaryrefslogtreecommitdiffstats
path: root/models/action.go
diff options
context:
space:
mode:
authorJonas Franz <info@jonasfranz.software>2017-06-25 20:20:29 +0200
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-06-25 20:20:29 +0200
commit441986a473a666e0a6a34ec49c50b5aa19245cf8 (patch)
tree67d45e4b2268a896649ef093cdd0b01ffed5aa1e /models/action.go
parent735676267e48e6a57b250825e2e77edbb513e11d (diff)
downloadgitea-441986a473a666e0a6a34ec49c50b5aa19245cf8.tar.gz
gitea-441986a473a666e0a6a34ec49c50b5aa19245cf8.zip
Fix "Dashboard shows deleted comments" (#1995)
Diffstat (limited to 'models/action.go')
-rw-r--r--models/action.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/models/action.go b/models/action.go
index bf3ce027cf..9a12e9229b 100644
--- a/models/action.go
+++ b/models/action.go
@@ -9,6 +9,7 @@ import (
"fmt"
"path"
"regexp"
+ "strconv"
"strings"
"time"
"unicode"
@@ -77,6 +78,9 @@ type Action struct {
ActUser *User `xorm:"-"`
RepoID int64 `xorm:"INDEX"`
Repo *Repository `xorm:"-"`
+ CommentID int64 `xorm:"INDEX"`
+ Comment *Comment `xorm:"-"`
+ IsDeleted bool `xorm:"INDEX NOT NULL DEFAULT false"`
RefName string
IsPrivate bool `xorm:"INDEX NOT NULL DEFAULT false"`
Content string `xorm:"TEXT"`
@@ -191,6 +195,35 @@ func (a *Action) GetRepoLink() string {
return "/" + a.GetRepoPath()
}
+// GetCommentLink returns link to action comment.
+func (a *Action) GetCommentLink() string {
+ if a == nil {
+ return "#"
+ }
+ if a.Comment == nil && a.CommentID != 0 {
+ a.Comment, _ = GetCommentByID(a.CommentID)
+ }
+ if a.Comment != nil {
+ return a.Comment.HTMLURL()
+ }
+ if len(a.GetIssueInfos()) == 0 {
+ return "#"
+ }
+ //Return link to issue
+ issueIDString := a.GetIssueInfos()[0]
+ issueID, err := strconv.ParseInt(issueIDString, 10, 64)
+ if err != nil {
+ return "#"
+ }
+
+ issue, err := GetIssueByID(issueID)
+ if err != nil {
+ return "#"
+ }
+
+ return issue.HTMLURL()
+}
+
// GetBranch returns the action's repository branch.
func (a *Action) GetBranch() string {
return a.RefName
@@ -678,6 +711,7 @@ type GetFeedsOptions struct {
RequestingUserID int64
IncludePrivate bool // include private actions
OnlyPerformedBy bool // only actions performed by requested user
+ IncludeDeleted bool // include deleted actions
}
// GetFeeds returns actions according to the provided options
@@ -706,5 +740,11 @@ func GetFeeds(opts GetFeedsOptions) ([]*Action, error) {
if opts.RequestedUser.IsOrganization() {
sess.In("repo_id", repoIDs)
}
+
+ if !opts.IncludeDeleted {
+ sess.And("is_deleted = ?", false)
+
+ }
+
return actions, sess.Find(&actions)
}