Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion backend/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ CROWD_DB_PORT=5433

# Search engine settings
CROWD_SEARCH_ENGINE_HOST=http://localhost:7701
CROWD_SEARCH_ENGINE_API_KEY=masterKey
CROWD_SEARCH_ENGINE_API_KEY=masterKey

# Redis settings
CROWD_REDIS_PORT=6380
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,7 @@ describe('Github webhooks tests', () => {
it('It should parse a star event coming from the GitHub API', async () => {
const { tenantId, gh } = await init(TestEvents.star.event, TestEvents.star.created, true)
const star = await gh.star(GithubActivityType.STAR)
const starTimestamp = star.timestamp
delete star.timestamp

const expected = {
member: {
username: {
Expand All @@ -723,10 +722,11 @@ describe('Github webhooks tests', () => {
type: GithubActivityType.STAR,
platform: PlatformType.GITHUB,
tenant: tenantId,
timestamp: moment(TestEvents.star.created.starred_at).toDate(),
sourceId: IntegrationServiceBase.generateSourceIdHash(
'joanreyero',
GithubActivityType.STAR,
moment(starTimestamp).unix().toString(),
moment(TestEvents.star.created.starred_at).unix().toString(),
PlatformType.GITHUB,
),
sourceParentId: null,
Expand All @@ -736,7 +736,6 @@ describe('Github webhooks tests', () => {
}
expect(star).toStrictEqual(expected)
// Check timestamp
expect(moment(starTimestamp).unix()).toBeCloseTo(moment().unix(), 3)

const fromMain = await gh.getActivityWithMember()
expected.sourceId = IntegrationServiceBase.generateSourceIdHash(
Expand All @@ -746,7 +745,6 @@ describe('Github webhooks tests', () => {
PlatformType.GITHUB,
)

delete fromMain.timestamp
expect(fromMain).toStrictEqual(expected)

const fromDb = await gh.main()
Expand Down
7 changes: 4 additions & 3 deletions backend/src/serverless/integrations/webhooks/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,18 @@ export default class GitHubWebhook {
integration.token,
)
if (member) {
const timestampObject = moment().utc()
const starredAt =
type === GithubActivityType.STAR ? moment(this.payload.starred_at).utc() : moment().utc()
return {
member,
type,
timestamp: timestampObject.toDate(),
timestamp: starredAt.toDate(),
platform: PlatformType.GITHUB,
tenant: GitHubWebhook.getTenantId(integration),
sourceId: IntegrationServiceBase.generateSourceIdHash(
this.payload.sender.login,
type,
timestampObject.unix().toString(),
starredAt.unix().toString(),
PlatformType.GITHUB,
),
sourceParentId: null,
Expand Down
7 changes: 7 additions & 0 deletions docker/docker-compose.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ services:
networks:
- crowd-bridge-test

redis-test:
image: redis
ports:
- 6380:6379
networks:
- crowd-bridge-test

networks:
crowd-bridge-test:
external: true