Skip to content

Commit

Permalink
HRIS-360 Implement Slack notification if user is not yet Logged In
Browse files Browse the repository at this point in the history
  • Loading branch information
sun-asterisk authored and sun-asterisk committed Jun 14, 2024
1 parent 1f09f8b commit fbb8828
Show file tree
Hide file tree
Showing 39 changed files with 1,745 additions and 9 deletions.
9 changes: 8 additions & 1 deletion .env.api_v2.example
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
JWT_SECRET_KEY=
JWT_SECRET_KEY=
SLACK_O_AUTH_TOKEN=
JWT_SIGNING_EXPIRATION=
JWT_SIGNING_ALGORITHM=
CACHE_TTL=
HRIS_GRAPHQL_API_ENDPOINT=
QUEUE_HOST=
QUEUE_PORT=
6 changes: 6 additions & 0 deletions api/Schema/Queries/UserQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public UserQuery(TimeInService timeInService, UserService userService)
{
return _userService.GetLoggedInUser();
}

public async Task<UserDTO?> GetUserByEmail([Service] UserService _userService, string email)
{
return await _userService.GetUserByEmail(email);
}

public async Task<List<User>> GetAllUsers([Service] UserService _userService)
{
return await _userService.Index();
Expand Down
17 changes: 17 additions & 0 deletions api/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ public string GenerateAvatarLink(int avatarId)
}
}

public async Task<UserDTO?> GetUserByEmail(string email)
{
using (HrisContext context = _contextFactory.CreateDbContext())
{
User? user = await context.Users
.Include(i => i.EmployeeSchedule)
.ThenInclude(i => i.WorkingDayTimes)
.Include(i => i.TimeEntries.OrderByDescending(o => o.CreatedAt))
.ThenInclude(i => i.TimeIn)
.Include(i => i.TimeEntries.OrderByDescending(o => o.CreatedAt))
.ThenInclude(i => i.TimeOut)
.Where(i => i.Email == email).FirstAsync();

return user != null ? new UserDTO(user, "") : null;
}
}

public async Task<List<User>> ESLUsers(int? exceptUserId)
{
using (HrisContext context = _contextFactory.CreateDbContext())
Expand Down
7 changes: 7 additions & 0 deletions api_v2/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
JWT_SECRET_KEY=
SLACK_O_AUTH_TOKEN=
JWT_SIGNING_EXPIRATION=
JWT_SIGNING_ALGORITHM=
CACHE_TTL=
HRIS_GRAPHQL_API_ENDPOINT=
QUEUE_HOST=
QUEUE_PORT=
13 changes: 13 additions & 0 deletions api_v2/config/bull.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { BullModuleOptions, BullOptionsFactory } from "@nestjs/bull";

export class BullConfigService implements BullOptionsFactory {

createBullOptions(): BullModuleOptions {
return {
redis: {
host: process.env.QUEUE_HOST || 'localhost',
port: process.env.QUEUE_PORT ? parseInt(process.env.QUEUE_PORT) : 6379
}
}
}
}
3 changes: 3 additions & 0 deletions api_v2/config/cache.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default () => ({
cacheTTL: process.env.CACHE_TTL || '3600',
})
3 changes: 3 additions & 0 deletions api_v2/config/hris-api.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default () => ({
hrisApiGraphQLEndpoint: process.env.HRIS_API_GRAPHQL_ENDPOINT || 'http://localhost:5257/graphql',
})
4 changes: 3 additions & 1 deletion api_v2/config/jwt.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export default () => ({
jwtSecret: process.env.JWT_SECRET_KEY
jwtSecret: process.env.JWT_SECRET_KEY,
jwtSigningExpiration: process.env.JWT_SIGNING_EXPIRATION || '7d',
jwtSigningAlgorithm: process.env.JWT_SIGNING_ALGORITHM || 'HS256',
})
4 changes: 4 additions & 0 deletions api_v2/config/queue.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default () => ({
queueHost: process.env.QUEUE_HOST || 'localhost',
queuePort: process.env.QUEUE_PORT || 6379
})
3 changes: 3 additions & 0 deletions api_v2/config/slack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default () => ({
slackOAuthToken: process.env.SLACK_O_AUTH_TOKEN
})
Binary file added api_v2/dump.rdb
Binary file not shown.
Loading

0 comments on commit fbb8828

Please sign in to comment.