OpType int // Operations: CREATE DELETE STAR ...
ActUserId int64 // Action user id.
ActUserName string // Action user name.
+ ActEmail string
RepoId int64
RepoName string
RefName string
return a.ActUserName
}
+func (a Action) GetActEmail() string {
+ return a.ActEmail
+}
+
func (a Action) GetRepoName() string {
return a.RepoName
}
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
}
// 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
}
type Actioner interface {
GetOpType() int
GetActUserName() string
+ GetActEmail() string
GetRepoName() string
GetBranch() string
GetContent() string
// 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()
}
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))
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"
}
}
// 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)
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)
}
{{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}}
{{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}}