Show private repository activities in dashboard if has access
This commit is contained in:
parent
a742ee543e
commit
914ffa496f
6 changed files with 54 additions and 13 deletions
|
@ -178,10 +178,20 @@ func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.C
|
|||
}
|
||||
}
|
||||
|
||||
act := &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,
|
||||
RepoUserName: ctx.Repo.Owner.Name,
|
||||
RepoName: ctx.Repo.Repository.Name,
|
||||
RefName: ctx.Repo.BranchName,
|
||||
IsPrivate: ctx.Repo.Repository.IsPrivate,
|
||||
}
|
||||
// Notify watchers.
|
||||
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 {
|
||||
if err := models.NotifyWatchers(act); err != nil {
|
||||
ctx.Handle(500, "issue.CreateIssue(NotifyWatchers)", err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -27,11 +27,23 @@ func Dashboard(ctx *middleware.Context) {
|
|||
}
|
||||
ctx.Data["MyRepos"] = repos
|
||||
|
||||
feeds, err := models.GetFeeds(ctx.User.Id, 0, false)
|
||||
actions, err := models.GetFeeds(ctx.User.Id, 0, false)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "user.Dashboard", err)
|
||||
return
|
||||
}
|
||||
|
||||
feeds := make([]*models.Action, 0, len(actions))
|
||||
for _, act := range actions {
|
||||
if act.IsPrivate {
|
||||
if has, _ := models.HasAccess(ctx.User.Name, act.RepoUserName+"/"+act.RepoName,
|
||||
models.AU_READABLE); !has {
|
||||
continue
|
||||
}
|
||||
}
|
||||
feeds = append(feeds, act)
|
||||
}
|
||||
|
||||
ctx.Data["Feeds"] = feeds
|
||||
ctx.HTML(200, "user/dashboard")
|
||||
}
|
||||
|
@ -39,7 +51,6 @@ func Dashboard(ctx *middleware.Context) {
|
|||
func Profile(ctx *middleware.Context, params martini.Params) {
|
||||
ctx.Data["Title"] = "Profile"
|
||||
|
||||
// TODO: Need to check view self or others.
|
||||
user, err := models.GetUserByName(params["username"])
|
||||
if err != nil {
|
||||
ctx.Handle(500, "user.Profile", err)
|
||||
|
@ -95,12 +106,19 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
|
|||
actions, err := models.GetFeeds(form.UserId, form.Page*20, false)
|
||||
if err != nil {
|
||||
ctx.JSON(500, err)
|
||||
return
|
||||
}
|
||||
|
||||
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]))
|
||||
feeds := make([]string, 0, len(actions))
|
||||
for _, act := range actions {
|
||||
if act.IsPrivate {
|
||||
if has, _ := models.HasAccess(ctx.User.Name, act.RepoUserName+"/"+act.RepoName,
|
||||
models.AU_READABLE); !has {
|
||||
continue
|
||||
}
|
||||
}
|
||||
feeds = append(feeds, fmt.Sprintf(TPL_FEED, base.ActionIcon(act.OpType),
|
||||
base.TimeSince(act.Created), base.ActionDesc(act)))
|
||||
}
|
||||
ctx.JSON(200, &feeds)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue