@@ -2,7 +2,8 @@ package lib.actions
2
2
3
3
import com .madgag .github .Implicits ._
4
4
import com .madgag .github .{PullRequestId , RepoId }
5
- import com .madgag .playgithub .auth .GHRequest
5
+ import com .madgag .playgithub .auth .AuthenticatedSessions .AccessToken
6
+ import com .madgag .playgithub .auth .{Client , GHRequest }
6
7
import controllers .Application ._
7
8
import controllers .Auth
8
9
import lib ._
@@ -15,26 +16,30 @@ import play.api.mvc._
15
16
import scala .concurrent .ExecutionContext .Implicits .global
16
17
import scala .concurrent .Future
17
18
import scala .util .{Failure , Success , Try }
19
+ import scalax .file .ImplicitConversions ._
18
20
19
21
20
22
object Actions {
21
23
private val authScopes = Seq (" user:email" )
22
24
23
- val GitHubAuthenticatedAction = com.madgag.playgithub.auth.Actions .githubAction(authScopes)(Auth .authClient)
25
+ implicit val authClient : Client = Auth .authClient
26
+
27
+ implicit val provider = AccessToken .FromSession
28
+
29
+ val GitHubAuthenticatedAction = com.madgag.playgithub.auth.Actions .gitHubAction(authScopes, Bot .workingDir.toPath)
24
30
25
31
def githubRepoAction (repoId : RepoId ) = GitHubAuthenticatedAction andThen new ActionRefiner [GHRequest , GHRepoRequest ] {
26
32
override protected def refine [A ](request : GHRequest [A ]): Future [Either [Result , GHRepoRequest [A ]]] = Future {
27
33
Either .cond(Project .byRepoId.contains(repoId), {
28
- val gitHub = request.gitHub
29
34
val repo = Bot .conn().getRepository(repoId.fullName)
30
- new GHRepoRequest (gitHub , repo, request)}, Forbidden (" Not a supported repo" ))
35
+ new GHRepoRequest (request.gitHubCredentials , repo, request)}, Forbidden (" Not a supported repo" ))
31
36
}
32
37
}
33
38
34
39
def githubPRAction (prId : PullRequestId ) = githubRepoAction(prId.repo) andThen new ActionRefiner [GHRepoRequest , GHPRRequest ] {
35
40
override protected def refine [A ](request : GHRepoRequest [A ]): Future [Either [Result , GHPRRequest [A ]]] = Future {
36
41
Try (request.repo.getPullRequest(prId.num)) match {
37
- case Success (pr) => Right (new GHPRRequest [A ](request.gitHub , pr, request))
42
+ case Success (pr) => Right (new GHPRRequest [A ](request.gitHubCredentials , pr, request))
38
43
case Failure (e) => Left (NotFound (s " ${request.repo.getFullName} doesn't seem to have PR # ${prId.num}" ))
39
44
}
40
45
}
0 commit comments