Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2edbb29
version bump
mx2s Jan 31, 2020
99eb954
project images
mx2s Feb 2, 2020
9d15d1f
Merge pull request #57 from gitcomteam/feature/56-project-images
mx2s Feb 2, 2020
17683c3
user model - email confirmed method
mx2s Feb 2, 2020
b164713
registration bonus background job
mx2s Feb 3, 2020
6ac3417
test hotfix
mx2s Feb 3, 2020
c0dbe0e
test hotfix (2) / renamed circleci test config
mx2s Feb 3, 2020
e5b77fd
adding tasks to jobs pool
mx2s Feb 3, 2020
7c09468
clean up job pool between tests
mx2s Feb 3, 2020
871ba21
JobPool - fix waiting for jobs
mx2s Feb 3, 2020
f81e4f7
UserBadge transformer hotfix
mx2s Feb 4, 2020
945dd74
importing GitHub project without auth WIP
mx2s Feb 4, 2020
0c85bdb
transformers fixes
mx2s Feb 4, 2020
eb846d9
Merge pull request #62 from gitcomteam/feature/60-submit-project-anon…
mx2s Feb 4, 2020
f6342ac
submit new project anonymously
mx2s Feb 4, 2020
5431406
Merge pull request #65 from gitcomteam/feature/60-submit-project-anon…
mx2s Feb 4, 2020
00be62c
sync issues background job
mx2s Feb 4, 2020
205720f
get cards - endpoint pagination
mx2s Feb 4, 2020
dff387f
Merge branch 'release/minor' into dev
mx2s Feb 4, 2020
febce7d
card response hotfix
mx2s Feb 4, 2020
25a6fc2
get cards response hotfix
mx2s Feb 6, 2020
01a30d8
Merge pull request #69 from gitcomteam/release/minor
mx2s Feb 6, 2020
b9f32fe
Merge branch 'dev' of github.com:gitcomteam/gitcom-api into dev
mx2s Feb 6, 2020
3cf021e
project alias creation fix
mx2s Feb 6, 2020
b0d0aad
newest projects pagination / get project cards endpoints
mx2s Feb 6, 2020
f71b6f8
get cards endpoint
mx2s Feb 7, 2020
0d27e48
Merge branch 'release/minor' into dev
mx2s Feb 7, 2020
45c9a16
updated sync issues background job
mx2s Feb 9, 2020
b33f4cd
Merge branch 'release/minor' into dev
mx2s Feb 9, 2020
e47d182
misc fixes / discord webhooks for system events
mx2s Mar 1, 2020
fd7fd6a
fixed repo origin id parsing
mx2s Mar 4, 2020
61c6f78
fixed unit tests
mx2s Mar 4, 2020
c42bbf9
Merge pull request #78 from gitcomteam/release/minor
mx2s Mar 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .circleci/config.json.testing → .circleci/config.testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
"jwt": {
"secret_key": "GQDsD21j8s2zdm12F1f1k12",
"token_life_days": 7
}
},
"schedule": {
"token": "fk1092fk21"
}
},
"schedule": {
"token": "F2l901f"
},
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
"user": {
"registration": {
"token_bonus": 500
}
}
}
}
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

- run:
name: copy app config
command: mkdir -p Tests/bin/Debug/netcoreapp2.2/config && cp .circleci/config.json.testing Tests/bin/Debug/netcoreapp2.2/config/config.json
command: mkdir -p Tests/bin/Debug/netcoreapp2.2/config && cp .circleci/config.testing.json Tests/bin/Debug/netcoreapp2.2/config/config.json

- run:
name: yum install dotnet core sdk 2.2
Expand Down
1 change: 0 additions & 1 deletion App/AL/AppBoot.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using App.DL.Module.Cache;
using Micron.DL.Model;

namespace App.AL {
public static class AppBoot {
Expand Down
5 changes: 1 addition & 4 deletions App/AL/Controller/Alias/Project/ProjectAliasController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ public ProjectAliasController() {
var alias = ProjectAliasRepository.FindByAlias(
GetRequestStr("owner"), GetRequestStr("alias")
);
if (alias == null) return HttpResponse.Error(HttpStatusCode.NotFound, "Project not found");

if (alias == null) {
return HttpResponse.Error(HttpStatusCode.NotFound, "Project not found");
}

return HttpResponse.Item("project", new ProjectTransformer().Transform(alias.Project()));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public GithubAuthController() {
"We're unable to get your access token, please try again");
}

var githubClient = new GitHubClient(new ProductHeaderValue("SupportHub"));
var githubClient = new GitHubClient(new ProductHeaderValue("GitCom"));

githubClient.Credentials = new Credentials(accessToken);

Expand Down
5 changes: 2 additions & 3 deletions App/AL/Controller/Auth/JwtAuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public JwtAuthController() {
return HttpResponse.Error(
new HttpError(HttpStatusCode.Unauthorized, "Your email / password combination is incorrect")
);

var queuedItem = RegistrationQueueItemRepository.Find(user);
if (queuedItem != null && !queuedItem.email_confirmed)

if (!user.EmailConfirmed())
return HttpResponse.Error(HttpStatusCode.Forbidden, "You need to confirm your email");

return HttpResponse.Data(new JObject() {
Expand Down
56 changes: 54 additions & 2 deletions App/AL/Controller/Card/CardController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using App.DL.Repository.BoardColumn;
using App.DL.Repository.Card;
using App.DL.Repository.Project;
using App.PL.Transformer.Card;
using Micron.AL.Validation.Basic;
using Micron.AL.Validation.Db;
using Micron.DL.Middleware;
using Micron.DL.Module.Controller;
using Micron.DL.Module.Http;
using Micron.DL.Module.Validator;
using Newtonsoft.Json.Linq;

namespace App.AL.Controller.Card {
public sealed class CardController : BaseController {
Expand All @@ -24,6 +26,45 @@ public CardController() {
CardRepository.FindByGuid((string) Request.Query["card_guid"])
));
});

Get("/api/v1/cards/get", _ => {
var page = GetRequestInt("page");
page = page > 0 ? page : 1;

var pageSize = 25;
return HttpResponse.Data(new JObject() {
["cards"] = new CardTransformer().Many(
DL.Model.Card.Card.Paginate(page, pageSize)
),
["meta"] = new JObject() {
["pages_count"] = (DL.Model.Card.Card.Count() / pageSize)+1,
["current_page"] = page
}
});
});

Get("/api/v1/project/cards/get", _ => {
var errors = ValidationProcessor.Process(Request, new IValidatorRule[] {
new ShouldHaveParameter("project_guid"),
new ExistsInTable("project_guid", "projects", "guid")
});
if (errors.Count > 0) return HttpResponse.Errors(errors);

var page = GetRequestInt("page");
page = page > 0 ? page : 1;

var pageSize = 25;

var project = ProjectRepository.FindByGuid(GetRequestStr("project_guid"));

return HttpResponse.Data(new JObject() {
["cards"] = new CardTransformer().Many(project.Cards(page, pageSize)),
["meta"] = new JObject() {
["pages_count"] = (project.CardsCount() / pageSize)+1,
["current_page"] = page
}
});
});

Get("/api/v1/board_column/cards/get", _ => {
var errors = ValidationProcessor.Process(Request, new IValidatorRule[] {
Expand All @@ -33,8 +74,19 @@ public CardController() {
if (errors.Count > 0) return HttpResponse.Errors(errors);

var column = BoardColumnRepository.FindByGuid(GetRequestStr("column_guid"));

return HttpResponse.Item("cards", new CardTransformer().Many(column.Cards()));

var page = GetRequestInt("page");
page = page > 0 ? page : 1;

var pageSize = 25;

return HttpResponse.Data(new JObject() {
["cards"] = new CardTransformer().Many(column.Cards(page, pageSize)),
["meta"] = new JObject() {
["pages_count"] = (column.CardsCount() / pageSize)+1,
["current_page"] = page
}
});
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion App/AL/Controller/External/MyIntegrationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public MyIntegrationsController() {
JObject githubUser = null;

if (githubToken != null) {
var githubClient = new GitHubClient(new ProductHeaderValue("SupportHub"));
var githubClient = new GitHubClient(new ProductHeaderValue("GitCom"));

githubClient.Credentials = new Credentials(githubToken.access_token);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using App.AL.Validation.Entity;
using App.DL.Enum;
using App.DL.Repository.Funding;
using App.DL.Repository.User;
using App.PL.Transformer.Funding;
using Micron.AL.Validation.Basic;
using Micron.AL.Validation.String;
Expand Down
26 changes: 26 additions & 0 deletions App/AL/Controller/Project/Image/ProjectImageController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using App.DL.Repository.Project;
using App.PL.Transformer.Image;
using Micron.AL.Validation.Db;
using Micron.DL.Middleware;
using Micron.DL.Module.Controller;
using Micron.DL.Module.Http;
using Micron.DL.Module.Validator;

namespace App.AL.Controller.Project.Image {
public class ProjectImageController : BaseController {
protected override IMiddleware[] Middleware() => new IMiddleware[] { };

public ProjectImageController() {
Get("/api/v1/project/images/get", _ => {
var errors = ValidationProcessor.Process(Request, new IValidatorRule[] {
new ExistsInTable("project_guid", "projects", "guid"),
});
if (errors.Count > 0) return HttpResponse.Errors(errors);

var project = ProjectRepository.FindByGuid(GetRequestStr("project_guid"));

return HttpResponse.Item("images", new ImageTransformer().Many(project.Images()));
});
}
}
}
19 changes: 15 additions & 4 deletions App/AL/Controller/Project/ProjectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
using Micron.DL.Module.Controller;
using Micron.DL.Module.Http;
using Micron.DL.Module.Validator;
using Newtonsoft.Json.Linq;

namespace App.AL.Controller.Project {
public sealed class ProjectController : BaseController {
protected override IMiddleware[] Middleware() => new IMiddleware[] {};
protected override IMiddleware[] Middleware() => new IMiddleware[] { };

public ProjectController() {
Get("/api/v1/project/get", _ => {
Expand All @@ -29,9 +30,19 @@ public ProjectController() {
});

Get("/api/v1/projects/newest/get", _ => {
return HttpResponse.Item("projects", new ProjectTransformer().Many(
ProjectRepository.GetNewest()
));
var page = GetRequestInt("page");
page = page > 0 ? page : 1;

var pageSize = 25;
return HttpResponse.Data(new JObject() {
["projects"] = new ProjectTransformer().Many(
ProjectRepository.GetNewest(page, pageSize)
),
["meta"] = new JObject() {
["pages_count"] = (DL.Model.Project.Project.Count() / pageSize)+1,
["current_page"] = page
}
});
});
}
}
Expand Down
84 changes: 84 additions & 0 deletions App/AL/Controller/Repo/Import/PublicImportController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Linq;
using App.AL.Utils.External.GitHub;
using App.DL.Enum;
using App.DL.External.GitHub;
using App.DL.Repository.Repo;
using App.PL.Transformer.Project;
using App.PL.Transformer.Repo;
using Micron.AL.Validation.Basic;
using Micron.DL.Middleware;
using Micron.DL.Module.Controller;
using Micron.DL.Module.Http;
using Micron.DL.Module.Validator;
using Nancy;
using Newtonsoft.Json.Linq;
using Octokit;

namespace App.AL.Controller.Repo.Import {
public class PublicImportController : BaseController {
protected override IMiddleware[] Middleware() => new IMiddleware[] {};

// TODO: add support for GitLab
public PublicImportController() {
Post("/api/v1/repository/submit/post", _ => {
var errors = ValidationProcessor.Process(Request, new IValidatorRule[] {
new ShouldHaveParameters(new[] {"url"}),
});
if (errors.Count > 0) return HttpResponse.Errors(errors);

var url = GetRequestStr("url");

Uri parsedUrl;
try {
parsedUrl = new Uri(url);
}
catch (Exception e) {
return HttpResponse.Error(HttpStatusCode.UnprocessableEntity, "Invalid url");
}

string host = parsedUrl.Host;

if (
!(new[] {"github.com"}.Contains(host)) || parsedUrl.Segments.Length < 3
) {
return HttpResponse.Error(HttpStatusCode.UnprocessableEntity, "Invalid hostname");
}

RepoServiceType serviceType = host == "github.com" ? RepoServiceType.GitHub : RepoServiceType.GitLab;

(DL.Model.Project.Project project, DL.Model.Repo.Repo repo) result = (null, null);

if (serviceType == RepoServiceType.GitHub) {
var githubClient = GitHubApi.Client();
Repository repo;
try {
repo = githubClient.Repository.Get(
parsedUrl.Segments[1].Replace("/", ""),
parsedUrl.Segments[2].Replace("/", "")
).Result;
}
catch (Exception e) {
return HttpResponse.Error(HttpStatusCode.NotFound, "GitHub repository does not exist");
}

var existingRepo = RepoRepository.Find(repo.Id.ToString(), serviceType);

if (existingRepo != null) {
return HttpResponse.Error(HttpStatusCode.UnprocessableEntity, "Project is already imported",
new JObject() {
["project"] = new ProjectTransformer().Transform(existingRepo.Project()),
});
}

result = GitHubRepositoriesUtils.ImportProject(null, repo.Id.ToString());
}

return HttpResponse.Data(new JObject() {
["project"] = new ProjectTransformer().Transform(result.project),
["repository"] = new RepoTransformer().Transform(result.repo)
});
});
}
}
}
Loading