mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
Improved model package. The details are as follows:
* Fix the Profiles class from package object to simple object * Fix the row case class to model package * Define the alias of JdbcBackend#Session
This commit is contained in:
@@ -21,9 +21,9 @@ trait AccountComponent { self: Profile =>
|
|||||||
val removed = column[Boolean]("REMOVED")
|
val removed = column[Boolean]("REMOVED")
|
||||||
def * = (userName, fullName, mailAddress, password, isAdmin, url.?, registeredDate, updatedDate, lastLoginDate.?, image.?, groupAccount, removed) <> (Account.tupled, Account.unapply)
|
def * = (userName, fullName, mailAddress, password, isAdmin, url.?, registeredDate, updatedDate, lastLoginDate.?, image.?, groupAccount, removed) <> (Account.tupled, Account.unapply)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class Account(
|
case class Account(
|
||||||
|
|
||||||
userName: String,
|
userName: String,
|
||||||
fullName: String,
|
fullName: String,
|
||||||
mailAddress: String,
|
mailAddress: String,
|
||||||
@@ -36,5 +36,4 @@ trait AccountComponent { self: Profile =>
|
|||||||
image: Option[String],
|
image: Option[String],
|
||||||
isGroupAccount: Boolean,
|
isGroupAccount: Boolean,
|
||||||
isRemoved: Boolean
|
isRemoved: Boolean
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ trait ActivityComponent extends TemplateComponent { self: Profile =>
|
|||||||
val activityDate = column[java.util.Date]("ACTIVITY_DATE")
|
val activityDate = column[java.util.Date]("ACTIVITY_DATE")
|
||||||
def * = (userName, repositoryName, activityUserName, activityType, message, additionalInfo.?, activityDate, activityId) <> (Activity.tupled, Activity.unapply)
|
def * = (userName, repositoryName, activityUserName, activityType, message, additionalInfo.?, activityDate, activityId) <> (Activity.tupled, Activity.unapply)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class Activity(
|
case class Activity(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
activityUserName: String,
|
activityUserName: String,
|
||||||
@@ -25,5 +26,4 @@ trait ActivityComponent extends TemplateComponent { self: Profile =>
|
|||||||
additionalInfo: Option[String],
|
additionalInfo: Option[String],
|
||||||
activityDate: java.util.Date,
|
activityDate: java.util.Date,
|
||||||
activityId: Int = 0
|
activityId: Int = 0
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ trait CollaboratorComponent extends TemplateComponent { self: Profile =>
|
|||||||
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
||||||
byRepository(owner, repository) && (collaboratorName is collaborator.bind)
|
byRepository(owner, repository) && (collaboratorName is collaborator.bind)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class Collaborator(
|
case class Collaborator(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
collaboratorName: String
|
collaboratorName: String
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ trait GroupMemberComponent { self: Profile =>
|
|||||||
val isManager = column[Boolean]("MANAGER")
|
val isManager = column[Boolean]("MANAGER")
|
||||||
def * = (groupName, userName, isManager) <> (GroupMember.tupled, GroupMember.unapply)
|
def * = (groupName, userName, isManager) <> (GroupMember.tupled, GroupMember.unapply)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class GroupMember(
|
case class GroupMember(
|
||||||
groupName: String,
|
groupName: String,
|
||||||
userName: String,
|
userName: String,
|
||||||
isManager: Boolean
|
isManager: Boolean
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ trait IssueComponent extends TemplateComponent { self: Profile =>
|
|||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId)
|
def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class Issue(
|
case class Issue(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
issueId: Int,
|
issueId: Int,
|
||||||
@@ -44,5 +45,5 @@ trait IssueComponent extends TemplateComponent { self: Profile =>
|
|||||||
closed: Boolean,
|
closed: Boolean,
|
||||||
registeredDate: java.util.Date,
|
registeredDate: java.util.Date,
|
||||||
updatedDate: java.util.Date,
|
updatedDate: java.util.Date,
|
||||||
isPullRequest: Boolean)
|
isPullRequest: Boolean
|
||||||
}
|
)
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ trait IssueCommentComponent extends TemplateComponent { self: Profile =>
|
|||||||
|
|
||||||
def byPrimaryKey(commentId: Int) = this.commentId is commentId.bind
|
def byPrimaryKey(commentId: Int) = this.commentId is commentId.bind
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class IssueComment(
|
case class IssueComment(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
issueId: Int,
|
issueId: Int,
|
||||||
@@ -30,5 +31,4 @@ trait IssueCommentComponent extends TemplateComponent { self: Profile =>
|
|||||||
content: String,
|
content: String,
|
||||||
registeredDate: java.util.Date,
|
registeredDate: java.util.Date,
|
||||||
updatedDate: java.util.Date
|
updatedDate: java.util.Date
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ trait IssueLabelComponent extends TemplateComponent { self: Profile =>
|
|||||||
def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) =
|
def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) =
|
||||||
byIssue(owner, repository, issueId) && (this.labelId is labelId.bind)
|
byIssue(owner, repository, issueId) && (this.labelId is labelId.bind)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class IssueLabel(
|
case class IssueLabel(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
issueId: Int,
|
issueId: Int,
|
||||||
labelId: Int)
|
labelId: Int
|
||||||
}
|
)
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ trait LabelComponent extends TemplateComponent { self: Profile =>
|
|||||||
def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId)
|
def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId)
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], labelId: Column[Int]) = byLabel(userName, repositoryName, labelId)
|
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], labelId: Column[Int]) = byLabel(userName, repositoryName, labelId)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class Label(
|
case class Label(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
labelId: Int = 0,
|
labelId: Int = 0,
|
||||||
@@ -33,5 +34,4 @@ trait LabelComponent extends TemplateComponent { self: Profile =>
|
|||||||
"FFFFFF"
|
"FFFFFF"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,14 @@ trait MilestoneComponent extends TemplateComponent { self: Profile =>
|
|||||||
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId)
|
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId)
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], milestoneId: Column[Int]) = byMilestone(userName, repositoryName, milestoneId)
|
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], milestoneId: Column[Int]) = byMilestone(userName, repositoryName, milestoneId)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class Milestone(
|
case class Milestone(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
milestoneId: Int = 0,
|
milestoneId: Int = 0,
|
||||||
title: String,
|
title: String,
|
||||||
description: Option[String],
|
description: Option[String],
|
||||||
dueDate: Option[java.util.Date],
|
dueDate: Option[java.util.Date],
|
||||||
closedDate: Option[java.util.Date])
|
closedDate: Option[java.util.Date]
|
||||||
}
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
trait Profile {
|
trait Profile {
|
||||||
val profile = slick.driver.H2Driver
|
val profile: slick.driver.JdbcProfile
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
|
||||||
// java.util.Date Mapped Column Types
|
// java.util.Date Mapped Column Types
|
||||||
@@ -15,3 +15,27 @@ trait Profile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object Profile extends {
|
||||||
|
val profile = slick.driver.H2Driver
|
||||||
|
|
||||||
|
} with AccountComponent
|
||||||
|
with ActivityComponent
|
||||||
|
with CollaboratorComponent
|
||||||
|
with GroupMemberComponent
|
||||||
|
with IssueComponent
|
||||||
|
with IssueCommentComponent
|
||||||
|
with IssueLabelComponent
|
||||||
|
with LabelComponent
|
||||||
|
with MilestoneComponent
|
||||||
|
with PullRequestComponent
|
||||||
|
with RepositoryComponent
|
||||||
|
with SshKeyComponent
|
||||||
|
with WebHookComponent with Profile {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns system date.
|
||||||
|
*/
|
||||||
|
def currentDate = new java.util.Date()
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ trait PullRequestComponent extends TemplateComponent { self: Profile =>
|
|||||||
def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) = byIssue(userName, repositoryName, issueId)
|
def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) = byIssue(userName, repositoryName, issueId)
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], issueId: Column[Int]) = byIssue(userName, repositoryName, issueId)
|
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], issueId: Column[Int]) = byIssue(userName, repositoryName, issueId)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class PullRequest(
|
case class PullRequest(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
issueId: Int,
|
issueId: Int,
|
||||||
@@ -28,5 +29,4 @@ trait PullRequestComponent extends TemplateComponent { self: Profile =>
|
|||||||
requestBranch: String,
|
requestBranch: String,
|
||||||
commitIdFrom: String,
|
commitIdFrom: String,
|
||||||
commitIdTo: String
|
commitIdTo: String
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
|||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository)
|
def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class Repository(
|
case class Repository(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
isPrivate: Boolean,
|
isPrivate: Boolean,
|
||||||
@@ -35,5 +36,4 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
|||||||
originRepositoryName: Option[String],
|
originRepositoryName: Option[String],
|
||||||
parentUserName: Option[String],
|
parentUserName: Option[String],
|
||||||
parentRepositoryName: Option[String]
|
parentRepositoryName: Option[String]
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ trait SshKeyComponent { self: Profile =>
|
|||||||
|
|
||||||
def byPrimaryKey(userName: String, sshKeyId: Int) = (this.userName is userName.bind) && (this.sshKeyId is sshKeyId.bind)
|
def byPrimaryKey(userName: String, sshKeyId: Int) = (this.userName is userName.bind) && (this.sshKeyId is sshKeyId.bind)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class SshKey(
|
case class SshKey(
|
||||||
userName: String,
|
userName: String,
|
||||||
sshKeyId: Int = 0,
|
sshKeyId: Int = 0,
|
||||||
title: String,
|
title: String,
|
||||||
publicKey: String
|
publicKey: String
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ trait WebHookComponent extends TemplateComponent { self: Profile =>
|
|||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, url: String) = byRepository(owner, repository) && (this.url is url.bind)
|
def byPrimaryKey(owner: String, repository: String, url: String) = byRepository(owner, repository) && (this.url is url.bind)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case class WebHook(
|
case class WebHook(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
url: String
|
url: String
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
package object model extends Profile
|
package object model {
|
||||||
with AccountComponent
|
type Session = slick.jdbc.JdbcBackend#Session
|
||||||
with ActivityComponent
|
|
||||||
with CollaboratorComponent
|
|
||||||
with GroupMemberComponent
|
|
||||||
with IssueComponent
|
|
||||||
with IssueCommentComponent
|
|
||||||
with IssueLabelComponent
|
|
||||||
with LabelComponent
|
|
||||||
with MilestoneComponent
|
|
||||||
with PullRequestComponent
|
|
||||||
with RepositoryComponent
|
|
||||||
with SshKeyComponent
|
|
||||||
with WebHookComponent {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns system date.
|
|
||||||
*/
|
|
||||||
def currentDate = new java.util.Date()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
import model.{Account, GroupMember}
|
||||||
// TODO [Slick 2.0]NOT import directly?
|
// TODO [Slick 2.0]NOT import directly?
|
||||||
import model.dateColumnType
|
import model.Profile.dateColumnType
|
||||||
import service.SystemSettingsService.SystemSettings
|
import service.SystemSettingsService.SystemSettings
|
||||||
import util.StringUtil._
|
import util.StringUtil._
|
||||||
import util.LDAPUtil
|
import util.LDAPUtil
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
import model.Activity
|
||||||
|
|
||||||
trait ActivityService {
|
trait ActivityService {
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package service
|
|||||||
import scala.slick.jdbc.{StaticQuery => Q}
|
import scala.slick.jdbc.{StaticQuery => Q}
|
||||||
import Q.interpolation
|
import Q.interpolation
|
||||||
|
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
import model.{Issue, IssueComment, IssueLabel, Label}
|
||||||
import util.Implicits._
|
import util.Implicits._
|
||||||
import util.StringUtil._
|
import util.StringUtil._
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
import model.Label
|
||||||
|
|
||||||
trait LabelsService {
|
trait LabelsService {
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
import model.Milestone
|
||||||
// TODO [Slick 2.0]NOT import directly?
|
// TODO [Slick 2.0]NOT import directly?
|
||||||
import model.dateColumnType
|
import model.Profile.dateColumnType
|
||||||
|
|
||||||
trait MilestonesService {
|
trait MilestonesService {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
import model.{PullRequest, Issue}
|
||||||
|
|
||||||
trait PullRequestService { self: IssuesService =>
|
trait PullRequestService { self: IssuesService =>
|
||||||
import PullRequestService._
|
import PullRequestService._
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.eclipse.jgit.revwalk.RevWalk
|
|||||||
import org.eclipse.jgit.treewalk.TreeWalk
|
import org.eclipse.jgit.treewalk.TreeWalk
|
||||||
import org.eclipse.jgit.lib.FileMode
|
import org.eclipse.jgit.lib.FileMode
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
|
||||||
trait RepositorySearchService { self: IssuesService =>
|
trait RepositorySearchService { self: IssuesService =>
|
||||||
@@ -107,7 +107,7 @@ object RepositorySearchService {
|
|||||||
|
|
||||||
case class SearchResult(
|
case class SearchResult(
|
||||||
files : List[(String, String)],
|
files : List[(String, String)],
|
||||||
issues: List[(Issue, Int, String)])
|
issues: List[(model.Issue, Int, String)])
|
||||||
|
|
||||||
case class IssueSearchResult(
|
case class IssueSearchResult(
|
||||||
issueId: Int,
|
issueId: Int,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
import model.{Repository, Account, Collaborator}
|
||||||
import util.JGitUtil
|
import util.JGitUtil
|
||||||
|
|
||||||
trait RepositoryService { self: AccountService =>
|
trait RepositoryService { self: AccountService =>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import model._
|
import model.{Account, Issue, Session}
|
||||||
import slick.jdbc.JdbcBackend
|
|
||||||
import util.Implicits.request2Session
|
import util.Implicits.request2Session
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +11,7 @@ import util.Implicits.request2Session
|
|||||||
*/
|
*/
|
||||||
trait RequestCache extends SystemSettingsService with AccountService with IssuesService {
|
trait RequestCache extends SystemSettingsService with AccountService with IssuesService {
|
||||||
|
|
||||||
private implicit def context2Session(implicit context: app.Context): JdbcBackend#Session =
|
private implicit def context2Session(implicit context: app.Context): Session =
|
||||||
request2Session(context.request)
|
request2Session(context.request)
|
||||||
|
|
||||||
def getIssue(userName: String, repositoryName: String, issueId: String)
|
def getIssue(userName: String, repositoryName: String, issueId: String)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
import model.SshKey
|
||||||
|
|
||||||
trait SshKeyService {
|
trait SshKeyService {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import model._
|
import model.Profile._
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
import model.{WebHook, Account}
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import service.RepositoryService.RepositoryInfo
|
import service.RepositoryService.RepositoryInfo
|
||||||
import util.JGitUtil
|
import util.JGitUtil
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import javax.servlet.http._
|
|||||||
import service.{SystemSettingsService, AccountService, RepositoryService}
|
import service.{SystemSettingsService, AccountService, RepositoryService}
|
||||||
import model._
|
import model._
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import slick.jdbc.JdbcBackend
|
|
||||||
import util.Implicits._
|
import util.Implicits._
|
||||||
import util.ControlUtil._
|
import util.ControlUtil._
|
||||||
import util.Keys
|
import util.Keys
|
||||||
@@ -67,7 +66,7 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def getWritableUser(username: String, password: String, repository: RepositoryService.RepositoryInfo)
|
private def getWritableUser(username: String, password: String, repository: RepositoryService.RepositoryInfo)
|
||||||
(implicit session: JdbcBackend#Session): Option[Account] =
|
(implicit session: Session): Option[Account] =
|
||||||
authenticate(loadSystemSettings(), username, password) match {
|
authenticate(loadSystemSettings(), username, password) match {
|
||||||
case x @ Some(account) if(hasWritePermission(repository.owner, repository.name, x)) => x
|
case x @ Some(account) if(hasWritePermission(repository.owner, repository.name, x)) => x
|
||||||
case _ => None
|
case _ => None
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import WebHookService._
|
|||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import util.JGitUtil.CommitInfo
|
import util.JGitUtil.CommitInfo
|
||||||
import service.IssuesService.IssueSearchCondition
|
import service.IssuesService.IssueSearchCondition
|
||||||
import slick.jdbc.JdbcBackend
|
import model.Session
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Git repository via HTTP.
|
* Provides Git repository via HTTP.
|
||||||
@@ -95,7 +95,7 @@ class GitBucketReceivePackFactory extends ReceivePackFactory[HttpServletRequest]
|
|||||||
|
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl: String)(implicit session: JdbcBackend#Session)
|
class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl: String)(implicit session: Session)
|
||||||
extends PostReceiveHook with PreReceiveHook
|
extends PostReceiveHook with PreReceiveHook
|
||||||
with RepositoryService with AccountService with IssuesService with ActivityService with PullRequestService with WebHookService {
|
with RepositoryService with AccountService with IssuesService with ActivityService with PullRequestService with WebHookService {
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
|
|||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import twirl.api.Html
|
import twirl.api.Html
|
||||||
import service.{AccountService, RepositoryService, SystemSettingsService}
|
import service.{AccountService, RepositoryService, SystemSettingsService}
|
||||||
import model.Account
|
import model.{Account, Session}
|
||||||
import util.{JGitUtil, Keys}
|
import util.{JGitUtil, Keys}
|
||||||
import plugin.PluginConnectionHolder
|
import plugin.PluginConnectionHolder
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ class PluginActionInvokeFilter extends Filter with SystemSettingsService with Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def processRepositoryAction(path: String, request: HttpServletRequest, response: HttpServletResponse)
|
private def processRepositoryAction(path: String, request: HttpServletRequest, response: HttpServletResponse)
|
||||||
(implicit session: model.profile.simple.Session): Boolean = {
|
(implicit session: Session): Boolean = {
|
||||||
val elements = path.split("/")
|
val elements = path.split("/")
|
||||||
if(elements.length > 3){
|
if(elements.length > 3){
|
||||||
val owner = elements(1)
|
val owner = elements(1)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import servlet.{Database, CommitLogHook}
|
|||||||
import service.{AccountService, RepositoryService, SystemSettingsService}
|
import service.{AccountService, RepositoryService, SystemSettingsService}
|
||||||
import org.eclipse.jgit.errors.RepositoryNotFoundException
|
import org.eclipse.jgit.errors.RepositoryNotFoundException
|
||||||
import javax.servlet.ServletContext
|
import javax.servlet.ServletContext
|
||||||
import model.profile.simple.Session
|
import model.Session
|
||||||
|
|
||||||
object GitCommand {
|
object GitCommand {
|
||||||
val CommandRegex = """\Agit-(upload|receive)-pack '/([a-zA-Z0-9\-_.]+)/([a-zA-Z0-9\-_.]+).git'\Z""".r
|
val CommandRegex = """\Agit-(upload|receive)-pack '/([a-zA-Z0-9\-_.]+)/([a-zA-Z0-9\-_.]+).git'\Z""".r
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import org.apache.commons.mail.{DefaultAuthenticator, HtmlEmail}
|
|||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
import app.Context
|
import app.Context
|
||||||
|
import model.Session
|
||||||
import service.{AccountService, RepositoryService, IssuesService, SystemSettingsService}
|
import service.{AccountService, RepositoryService, IssuesService, SystemSettingsService}
|
||||||
import servlet.Database
|
import servlet.Database
|
||||||
import SystemSettingsService.Smtp
|
import SystemSettingsService.Smtp
|
||||||
import _root_.util.ControlUtil.defining
|
import _root_.util.ControlUtil.defining
|
||||||
import model.profile.simple.Session
|
|
||||||
|
|
||||||
trait Notifier extends RepositoryService with AccountService with IssuesService {
|
trait Notifier extends RepositoryService with AccountService with IssuesService {
|
||||||
def toNotify(r: RepositoryService.RepositoryInfo, issueId: Int, content: String)
|
def toNotify(r: RepositoryService.RepositoryInfo, issueId: Int, content: String)
|
||||||
|
|||||||
Reference in New Issue
Block a user