Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 291d9d2

Browse files
committed
UI updates and better handling of close events.
1 parent 609c02a commit 291d9d2

8 files changed

+678
-1084
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Now, receiver service can receive the webhooks from git host's project. Now you
6767
- create a pull request, you can see the logs in `receiver` and `processor`, the `pull_request.created` event is generated.
6868
- close a pull request without merge, you can see the logs in `receiver` and `processor`, the `pull_request.closed` event is generated and the `merged` property is `false`.
6969
- merge a pull request, you can see the logs in `receiver` and `processor`, the `pull_request.closed` event is generated and the `merged` property is `true`.
70+
- close an issue in the repo, you can see the logs in `receiver` and `processor`, the `issue.closed` event is generated
7071

7172
## Gitlab Verification
7273

@@ -79,3 +80,4 @@ Now, receiver service can receive the webhooks from git host's project. Now you
7980
- create a pull request, you can see the logs in `receiver` and `processor`, the `pull_request.created` event is generated.
8081
- close a pull request without merge, you can see the logs in `receiver` and `processor`, the `pull_request.closed` event is generated and the `merged` property is `false`.
8182
- merge a pull request, you can see the logs in `receiver` and `processor`, the `pull_request.closed` event is generated and the `merged` property is `true`.
83+
- close an issue in the repo, you can see the logs in `receiver` and `processor`, the `issue.closed` event is generated

models/IssueClosedEvent.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2018 TopCoder, Inc. All rights reserved.
3+
*/
4+
/**
5+
* This module contains the schema of the issue closed schema.
6+
*
7+
* @author veshu
8+
* @version 1.0
9+
*/
10+
'use strict';
11+
const Joi = require('joi');
12+
const {issueSchema, repositorySchema} = require('./common');
13+
14+
const IssueClosedEvent = {
15+
name: 'issue.closed',
16+
17+
schema: Joi.object().keys({
18+
issue: issueSchema.required(),
19+
repository: repositorySchema.required(),
20+
assignee: Joi.object().keys({
21+
id: Joi.number().allow(null)
22+
}).required()
23+
})
24+
};
25+
26+
27+
module.exports = IssueClosedEvent;
28+

models/Project.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ const schema = new mongoose.Schema({
1414
title: {type: String, required: true},
1515
tcDirectId: {type: Number, required: true},
1616
repoUrl: {type: String, required: true},
17-
rocketChatWebhook: {type: String, required: true},
18-
rocketChatChannelName: {type: String, required: true},
17+
rocketChatWebhook: {type: String, required: false},
18+
rocketChatChannelName: {type: String, required: false},
1919
archived: {type: String, required: true},
2020
username: {type: String, required: true},
2121
secretWebhookKey: {type: String, required: true}
2222
});
2323

24-
// project id, provider, repositoryId must be unique
25-
schema.index({tcDirectId: 1}, {unique: true});
24+
schema.index({tcDirectId: 1});
2625

2726

2827
module.exports = schema;

models/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mongoose.Promise = global.Promise;
1717
const connection = mongoose.createConnection(config.MONGODB_URL);
1818
const IssueCreatedEvent = require('./IssueCreatedEvent');
1919
const IssueUpdatedEvent = require('./IssueUpdatedEvent');
20+
const IssueClosedEvent = require('./IssueClosedEvent');
2021
const CommentCreatedEvent = require('./CommentCreatedEvent');
2122
const CommentUpdatedEvent = require('./CommentUpdatedEvent');
2223
const UserAssignedEvent = require('./UserAssignedEvent');
@@ -36,5 +37,6 @@ module.exports = {
3637
PullRequestCreatedEvent,
3738
PullRequestClosedEvent,
3839
LabelUpdatedEvent,
39-
Project: connection.model('Project', Project)
40+
Project: connection.model('Project', Project),
41+
IssueClosedEvent
4042
};

0 commit comments

Comments
 (0)