mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 18:58:38 +00:00
Show owner/poster tags of comments and fix #1312
This commit is contained in:
@@ -1231,6 +1231,15 @@ const (
|
||||
COMMENT_TYPE_PULL_REF
|
||||
)
|
||||
|
||||
type CommentTag int
|
||||
|
||||
const (
|
||||
COMMENT_TAG_NONE CommentTag = iota
|
||||
COMMENT_TAG_POSTER
|
||||
COMMENT_TAG_ADMIN
|
||||
COMMENT_TAG_OWNER
|
||||
)
|
||||
|
||||
// Comment represents a comment in commit and issue page.
|
||||
type Comment struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
@@ -1245,6 +1254,9 @@ type Comment struct {
|
||||
Created time.Time `xorm:"CREATED"`
|
||||
|
||||
Attachments []*Attachment `xorm:"-"`
|
||||
|
||||
// For view issue page.
|
||||
ShowTag CommentTag `xorm:"-"`
|
||||
}
|
||||
|
||||
// HashTag returns unique hash tag for comment.
|
||||
|
@@ -247,8 +247,8 @@ func (repo *Repository) HasAccess(u *User) bool {
|
||||
return has
|
||||
}
|
||||
|
||||
func (repo *Repository) IsOwnedBy(u *User) bool {
|
||||
return repo.OwnerID == u.Id
|
||||
func (repo *Repository) IsOwnedBy(userID int64) bool {
|
||||
return repo.OwnerID == userID
|
||||
}
|
||||
|
||||
// DescriptionHtml does special handles to description and return HTML string.
|
||||
|
@@ -222,6 +222,25 @@ func (u *User) UploadAvatar(data []byte) error {
|
||||
return sess.Commit()
|
||||
}
|
||||
|
||||
// IsAdminOfRepo returns true if user has admin or higher access of repository.
|
||||
func (u *User) IsAdminOfRepo(repo *Repository) bool {
|
||||
if err := repo.GetOwner(); err != nil {
|
||||
log.Error(3, "GetOwner: %v", err)
|
||||
return false
|
||||
}
|
||||
|
||||
if repo.Owner.IsOrganization() {
|
||||
has, err := HasAccess(u, repo, ACCESS_MODE_ADMIN)
|
||||
if err != nil {
|
||||
log.Error(3, "HasAccess: %v", err)
|
||||
return false
|
||||
}
|
||||
return has
|
||||
}
|
||||
|
||||
return repo.IsOwnedBy(u.Id)
|
||||
}
|
||||
|
||||
// IsOrganization returns true if user is actually a organization.
|
||||
func (u *User) IsOrganization() bool {
|
||||
return u.Type == ORGANIZATION
|
||||
|
Reference in New Issue
Block a user