aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/access.go6
-rw-r--r--models/repo.go14
2 files changed, 20 insertions, 0 deletions
diff --git a/models/access.go b/models/access.go
index 970f4a941f..749a2604d5 100644
--- a/models/access.go
+++ b/models/access.go
@@ -42,6 +42,12 @@ func UpdateAccess(access *Access) error {
return err
}
+// DeleteAccess deletes access record.
+func DeleteAccess(access *Access) error {
+ _, err := orm.Delete(access)
+ return err
+}
+
// UpdateAccess updates access information with session for rolling back.
func UpdateAccessWithSession(sess *xorm.Session, access *Access) error {
if _, err := sess.Id(access.Id).Update(access); err != nil {
diff --git a/models/repo.go b/models/repo.go
index 5e19378721..be889cba5f 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -712,6 +712,20 @@ func GetRepositoryCount(user *User) (int64, error) {
return orm.Count(&Repository{OwnerId: user.Id})
}
+// GetCollaborators returns a list of user name of repository's collaborators.
+func GetCollaborators(repoName string) ([]string, error) {
+ accesses := make([]*Access, 0, 10)
+ if err := orm.Find(&accesses, &Access{RepoName: strings.ToLower(repoName)}); err != nil {
+ return nil, err
+ }
+
+ names := make([]string, len(accesses))
+ for i := range accesses {
+ names[i] = accesses[i].UserName
+ }
+ return names, nil
+}
+
// Watch is connection request for receiving repository notifycation.
type Watch struct {
Id int64