summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-29 07:50:25 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-29 07:50:25 -0400
commit828282882066aa4e8bd8fb0c083c530607bc34bb (patch)
tree4ac056c6d088a046d5b848c872c363cd6bc0276b
parent879ef8d81fa7dd194a7482c870cecab5a5ac964b (diff)
downloadgitea-828282882066aa4e8bd8fb0c083c530607bc34bb.tar.gz
gitea-828282882066aa4e8bd8fb0c083c530607bc34bb.zip
Fix action email bug
-rw-r--r--models/action.go13
-rw-r--r--modules/base/tool.go8
-rw-r--r--routers/repo/issue.go2
-rw-r--r--routers/user/user.go2
-rw-r--r--templates/user/dashboard.tmpl2
-rw-r--r--templates/user/profile.tmpl2
6 files changed, 18 insertions, 11 deletions
diff --git a/models/action.go b/models/action.go
index 9d99df8546..894855784f 100644
--- a/models/action.go
+++ b/models/action.go
@@ -31,6 +31,7 @@ type Action struct {
OpType int // Operations: CREATE DELETE STAR ...
ActUserId int64 // Action user id.
ActUserName string // Action user name.
+ ActEmail string
RepoId int64
RepoName string
RefName string
@@ -46,6 +47,10 @@ func (a Action) GetActUserName() string {
return a.ActUserName
}
+func (a Action) GetActEmail() string {
+ return a.ActEmail
+}
+
func (a Action) GetRepoName() string {
return a.RepoName
}
@@ -69,8 +74,8 @@ func CommitRepoAction(userId int64, userName string,
return err
}
- if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, OpType: OP_COMMIT_REPO,
- Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil {
+ if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: "",
+ OpType: OP_COMMIT_REPO, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil {
log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
return err
}
@@ -93,8 +98,8 @@ func CommitRepoAction(userId int64, userName string,
// NewRepoAction adds new action for creating repository.
func NewRepoAction(user *User, repo *Repository) (err error) {
- if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, OpType: OP_CREATE_REPO,
- RepoId: repo.Id, RepoName: repo.Name}); err != nil {
+ if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
+ OpType: OP_CREATE_REPO, RepoId: repo.Id, RepoName: repo.Name}); err != nil {
log.Error("action.NewRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
return err
}
diff --git a/modules/base/tool.go b/modules/base/tool.go
index d005ffe355..6876da7625 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -478,6 +478,7 @@ func (a argInt) Get(i int, args ...int) (r int) {
type Actioner interface {
GetOpType() int
GetActUserName() string
+ GetActEmail() string
GetRepoName() string
GetBranch() string
GetContent() string
@@ -520,8 +521,9 @@ type PushCommits struct {
// ActionDesc accepts int that represents action operation type
// and returns the description.
-func ActionDesc(act Actioner, avatarLink string) string {
+func ActionDesc(act Actioner) string {
actUserName := act.GetActUserName()
+ email := act.GetActEmail()
repoName := act.GetRepoName()
repoLink := actUserName + "/" + repoName
branch := act.GetBranch()
@@ -536,7 +538,7 @@ func ActionDesc(act Actioner, avatarLink string) string {
}
buf := bytes.NewBuffer([]byte("\n"))
for _, commit := range push.Commits {
- buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n")
+ buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n")
}
if push.Len > 3 {
buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
@@ -546,7 +548,7 @@ func ActionDesc(act Actioner, avatarLink string) string {
case 6: // Create issue.
infos := strings.SplitN(content, "|", 2)
return fmt.Sprintf(TPL_CREATE_Issue, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0],
- avatarLink, infos[1])
+ AvatarLink(email), infos[1])
default:
return "invalid type"
}
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 14876e1863..c89c8b5685 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -105,7 +105,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
}
// Notify watchers.
- if err = models.NotifyWatchers(&models.Action{ActUserId: ctx.User.Id, ActUserName: ctx.User.Name,
+ if err = models.NotifyWatchers(&models.Action{ActUserId: ctx.User.Id, ActUserName: ctx.User.Name, ActEmail: ctx.User.Email,
OpType: models.OP_CREATE_ISSUE, Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name),
RepoId: ctx.Repo.Repository.Id, RepoName: ctx.Repo.Repository.Name, RefName: ""}); err != nil {
ctx.Handle(200, "issue.CreateIssue", err)
diff --git a/routers/user/user.go b/routers/user/user.go
index b0fc583978..114169e606 100644
--- a/routers/user/user.go
+++ b/routers/user/user.go
@@ -279,7 +279,7 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
feeds := make([]string, len(actions))
for i := range actions {
feeds[i] = fmt.Sprintf(TPL_FEED, base.ActionIcon(actions[i].OpType),
- base.TimeSince(actions[i].Created), base.ActionDesc(actions[i], ctx.User.AvatarLink()))
+ base.TimeSince(actions[i].Created), base.ActionDesc(actions[i]))
}
ctx.JSON(200, &feeds)
}
diff --git a/templates/user/dashboard.tmpl b/templates/user/dashboard.tmpl
index 6064095b11..bc0853fb0d 100644
--- a/templates/user/dashboard.tmpl
+++ b/templates/user/dashboard.tmpl
@@ -18,7 +18,7 @@
{{range .Feeds}}
<li>
<i class="icon fa fa-{{ActionIcon .OpType}}"></i>
- <div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . $.SignedUser.AvatarLink | str2html}}</div>
+ <div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . | str2html}}</div>
<span class="clearfix"></span>
</li>
{{else}}
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl
index 5ac8121f8b..97549d481c 100644
--- a/templates/user/profile.tmpl
+++ b/templates/user/profile.tmpl
@@ -35,7 +35,7 @@
{{range .Feeds}}
<li>
<i class="icon fa fa-{{ActionIcon .OpType}}"></i>
- <div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . $.Owner.AvatarLink | str2html}}</div>
+ <div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . | str2html}}</div>
<span class="clearfix"></span>
</li>
{{else}}