mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 16:00:13 +01:00
- Fix Outgoing Webhook messages for Checlists, Checklist Items, Card comments, Add/Remove CustomField to board.
Not yet fixed is Outgoing Webhook message about setting CustomField value. Thanks to xet7 ! Related #1969
This commit is contained in:
parent
7c89336ea9
commit
5283ba9ebb
6 changed files with 82 additions and 19 deletions
|
|
@ -17,10 +17,14 @@
|
||||||
"act-completeChecklist": "completed checklist __checklist__ at card __card__ at list __list__ at swimlane __swimlane__ at board __board__",
|
"act-completeChecklist": "completed checklist __checklist__ at card __card__ at list __list__ at swimlane __swimlane__ at board __board__",
|
||||||
"act-uncompleteChecklist": "uncompleted checklist __checklist__ at card __card__ at list __list__ at swimlane __swimlane__ at board __board__",
|
"act-uncompleteChecklist": "uncompleted checklist __checklist__ at card __card__ at list __list__ at swimlane __swimlane__ at board __board__",
|
||||||
"act-addComment": "commented on card __card__: __comment__ at list __list__ at swimlane __swimlane__ at board __board__",
|
"act-addComment": "commented on card __card__: __comment__ at list __list__ at swimlane __swimlane__ at board __board__",
|
||||||
|
"act-editComment": "edited comment on card __card__: __comment__ at list __list__ at swimlane __swimlane__ at board __board__",
|
||||||
|
"act-deleteComment": "deleted comment on card __card__: __comment__ at list __list__ at swimlane __swimlane__ at board __board__",
|
||||||
"act-createBoard": "created board __board__",
|
"act-createBoard": "created board __board__",
|
||||||
"act-createSwimlane": "created swimlane __swimlane__ to board __board__",
|
"act-createSwimlane": "created swimlane __swimlane__ to board __board__",
|
||||||
"act-createCard": "created card __card__ to list __list__ at swimlane __swimlane__ at board __board__",
|
"act-createCard": "created card __card__ to list __list__ at swimlane __swimlane__ at board __board__",
|
||||||
"act-createCustomField": "created custom field __customField__ to card __card__ at list __list__ at swimlane __swimlane__ at board __board__",
|
"act-createCustomField": "created custom field __customField__ at board __board__",
|
||||||
|
"act-deleteCustomField": "deleted custom field __customField__ at board __board__",
|
||||||
|
"act-setCustomField": "set custom field __customField__: __customFieldValue__ at card __card__ at list __list__ at swimlane __swimlane__ at board __board__",
|
||||||
"act-createList": "added list __list__ to board __board__",
|
"act-createList": "added list __list__ to board __board__",
|
||||||
"act-addBoardMember": "added member __member__ to board __board__",
|
"act-addBoardMember": "added member __member__ to board __board__",
|
||||||
"act-archivedBoard": "Board __board__ moved to Archive",
|
"act-archivedBoard": "Board __board__ moved to Archive",
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,7 @@ if (Meteor.isServer) {
|
||||||
if (activity.customFieldId) {
|
if (activity.customFieldId) {
|
||||||
const customField = activity.customField();
|
const customField = activity.customField();
|
||||||
params.customField = customField.name;
|
params.customField = customField.name;
|
||||||
|
params.customFieldValue = customField.text;
|
||||||
}
|
}
|
||||||
// Label activity did not work yet, unable to edit labels when tried this.
|
// Label activity did not work yet, unable to edit labels when tried this.
|
||||||
//if (activity.labelId) {
|
//if (activity.labelId) {
|
||||||
|
|
|
||||||
|
|
@ -81,14 +81,15 @@ CardComments.helpers({
|
||||||
CardComments.hookOptions.after.update = { fetchPrevious: false };
|
CardComments.hookOptions.after.update = { fetchPrevious: false };
|
||||||
|
|
||||||
function commentCreation(userId, doc){
|
function commentCreation(userId, doc){
|
||||||
|
const card = Cards.findOne(doc.cardId);
|
||||||
Activities.insert({
|
Activities.insert({
|
||||||
userId,
|
userId,
|
||||||
activityType: 'addComment',
|
activityType: 'addComment',
|
||||||
boardId: doc.boardId,
|
boardId: doc.boardId,
|
||||||
cardId: doc.cardId,
|
cardId: doc.cardId,
|
||||||
commentId: doc._id,
|
commentId: doc._id,
|
||||||
listId: doc.listId,
|
listId: card.listId,
|
||||||
swimlaneId: doc.swimlaneId,
|
swimlaneId: card.swimlaneId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,6 +104,34 @@ if (Meteor.isServer) {
|
||||||
commentCreation(userId, doc);
|
commentCreation(userId, doc);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CardComments.after.update((userId, doc) => {
|
||||||
|
const activity = Activities.findOne({ commentId: doc._id });
|
||||||
|
const card = Cards.findOne(doc.cardId);
|
||||||
|
Activities.insert({
|
||||||
|
userId,
|
||||||
|
activityType: 'editComment',
|
||||||
|
boardId: doc.boardId,
|
||||||
|
cardId: doc.cardId,
|
||||||
|
commentId: doc._id,
|
||||||
|
listId: card.listId,
|
||||||
|
swimlaneId: card.swimlaneId,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
CardComments.before.remove((userId, doc) => {
|
||||||
|
const activity = Activities.findOne({ commentId: doc._id });
|
||||||
|
const card = Cards.findOne(doc.cardId);
|
||||||
|
Activities.insert({
|
||||||
|
userId,
|
||||||
|
activityType: 'deleteComment',
|
||||||
|
boardId: doc.boardId,
|
||||||
|
cardId: doc.cardId,
|
||||||
|
commentId: doc._id,
|
||||||
|
listId: card.listId,
|
||||||
|
swimlaneId: card.swimlaneId,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
CardComments.after.remove((userId, doc) => {
|
CardComments.after.remove((userId, doc) => {
|
||||||
const activity = Activities.findOne({ commentId: doc._id });
|
const activity = Activities.findOne({ commentId: doc._id });
|
||||||
if (activity) {
|
if (activity) {
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,8 @@ function itemCreation(userId, doc) {
|
||||||
checklistId: doc.checklistId,
|
checklistId: doc.checklistId,
|
||||||
checklistItemId: doc._id,
|
checklistItemId: doc._id,
|
||||||
checklistItemName: doc.title,
|
checklistItemName: doc.title,
|
||||||
listId: doc.listId,
|
listId: card.listId,
|
||||||
swimlaneId: doc.swimlaneId,
|
swimlaneId: card.swimlaneId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,8 +123,8 @@ function publishCheckActivity(userId, doc){
|
||||||
checklistId: doc.checklistId,
|
checklistId: doc.checklistId,
|
||||||
checklistItemId: doc._id,
|
checklistItemId: doc._id,
|
||||||
checklistItemName:doc.title,
|
checklistItemName:doc.title,
|
||||||
listId: doc.listId,
|
listId: card.listId,
|
||||||
swimlaneId: doc.swimlaneId,
|
swimlaneId: card.swimlaneId,
|
||||||
};
|
};
|
||||||
Activities.insert(act);
|
Activities.insert(act);
|
||||||
}
|
}
|
||||||
|
|
@ -142,8 +142,8 @@ function publishChekListCompleted(userId, doc){
|
||||||
boardId,
|
boardId,
|
||||||
checklistId: doc.checklistId,
|
checklistId: doc.checklistId,
|
||||||
checklistName: checkList.title,
|
checklistName: checkList.title,
|
||||||
listId: doc.listId,
|
listId: card.listId,
|
||||||
swimlaneId: doc.swimlaneId,
|
swimlaneId: card.swimlaneId,
|
||||||
};
|
};
|
||||||
Activities.insert(act);
|
Activities.insert(act);
|
||||||
}
|
}
|
||||||
|
|
@ -175,8 +175,8 @@ function publishChekListUncompleted(userId, doc){
|
||||||
boardId,
|
boardId,
|
||||||
checklistId: doc.checklistId,
|
checklistId: doc.checklistId,
|
||||||
checklistName: checkList.title,
|
checklistName: checkList.title,
|
||||||
listId: doc.listId,
|
listId: card.listId,
|
||||||
swimlaneId: doc.swimlaneId,
|
swimlaneId: card.swimlaneId,
|
||||||
};
|
};
|
||||||
Activities.insert(act);
|
Activities.insert(act);
|
||||||
}
|
}
|
||||||
|
|
@ -215,8 +215,8 @@ if (Meteor.isServer) {
|
||||||
checklistId: doc.checklistId,
|
checklistId: doc.checklistId,
|
||||||
checklistItemId: doc._id,
|
checklistItemId: doc._id,
|
||||||
checklistItemName:doc.title,
|
checklistItemName:doc.title,
|
||||||
listId: doc.listId,
|
listId: card.listId,
|
||||||
swimlaneId: doc.swimlaneId,
|
swimlaneId: card.swimlaneId,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,20 +128,22 @@ if (Meteor.isServer) {
|
||||||
});
|
});
|
||||||
|
|
||||||
Checklists.after.insert((userId, doc) => {
|
Checklists.after.insert((userId, doc) => {
|
||||||
|
const card = Cards.findOne(doc.cardId);
|
||||||
Activities.insert({
|
Activities.insert({
|
||||||
userId,
|
userId,
|
||||||
activityType: 'addChecklist',
|
activityType: 'addChecklist',
|
||||||
cardId: doc.cardId,
|
cardId: doc.cardId,
|
||||||
boardId: Cards.findOne(doc.cardId).boardId,
|
boardId: card.boardId,
|
||||||
checklistId: doc._id,
|
checklistId: doc._id,
|
||||||
checklistName:doc.title,
|
checklistName:doc.title,
|
||||||
listId: doc.listId,
|
listId: card.listId,
|
||||||
swimlaneId: doc.swimlaneId,
|
swimlaneId: card.swimlaneId,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Checklists.before.remove((userId, doc) => {
|
Checklists.before.remove((userId, doc) => {
|
||||||
const activities = Activities.find({ checklistId: doc._id });
|
const activities = Activities.find({ checklistId: doc._id });
|
||||||
|
const card = Cards.findOne(doc.cardId);
|
||||||
if (activities) {
|
if (activities) {
|
||||||
activities.forEach((activity) => {
|
activities.forEach((activity) => {
|
||||||
Activities.remove(activity._id);
|
Activities.remove(activity._id);
|
||||||
|
|
@ -154,8 +156,8 @@ if (Meteor.isServer) {
|
||||||
boardId: Cards.findOne(doc.cardId).boardId,
|
boardId: Cards.findOne(doc.cardId).boardId,
|
||||||
checklistId: doc._id,
|
checklistId: doc._id,
|
||||||
checklistName:doc.title,
|
checklistName:doc.title,
|
||||||
listId: doc.listId,
|
listId: card.listId,
|
||||||
swimlaneId: doc.swimlaneId,
|
swimlaneId: card.swimlaneId,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,29 @@ function customFieldCreation(userId, doc){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function customFieldDeletion(userId, doc){
|
||||||
|
Activities.insert({
|
||||||
|
userId,
|
||||||
|
activityType: 'deleteCustomField',
|
||||||
|
boardId: doc.boardIds[0], // We are creating a customField, it has only one boardId
|
||||||
|
customFieldId: doc._id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// This has some bug, it does not show edited customField value at Outgoing Webhook,
|
||||||
|
// instead it shows undefined, and no listId and swimlaneId.
|
||||||
|
function customFieldEdit(userId, doc){
|
||||||
|
const card = Cards.findOne(doc.cardId);
|
||||||
|
Activities.insert({
|
||||||
|
userId,
|
||||||
|
activityType: 'editCustomField',
|
||||||
|
boardId: doc.boardIds[0], // We are creating a customField, it has only one boardId
|
||||||
|
customFieldId: doc._id,
|
||||||
|
listId: card.listId,
|
||||||
|
swimlaneId: card.swimlaneId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
Meteor.startup(() => {
|
Meteor.startup(() => {
|
||||||
CustomFields._collection._ensureIndex({ boardIds: 1 });
|
CustomFields._collection._ensureIndex({ boardIds: 1 });
|
||||||
|
|
@ -133,9 +156,12 @@ if (Meteor.isServer) {
|
||||||
{$pull: {'customFields': {'_id': doc._id}}},
|
{$pull: {'customFields': {'_id': doc._id}}},
|
||||||
{multi: true}
|
{multi: true}
|
||||||
);
|
);
|
||||||
|
customFieldEdit(userId, doc);
|
||||||
Activities.remove({
|
Activities.remove({
|
||||||
customFieldId: doc._id,
|
customFieldId: doc._id,
|
||||||
boardId: modifier.$pull.boardIds,
|
boardId: modifier.$pull.boardIds,
|
||||||
|
listId: card.listId,
|
||||||
|
swimlaneId: card.swimlaneId,
|
||||||
});
|
});
|
||||||
} else if (_.contains(fieldNames, 'boardIds') && modifier.$push) {
|
} else if (_.contains(fieldNames, 'boardIds') && modifier.$push) {
|
||||||
Activities.insert({
|
Activities.insert({
|
||||||
|
|
@ -148,6 +174,7 @@ if (Meteor.isServer) {
|
||||||
});
|
});
|
||||||
|
|
||||||
CustomFields.before.remove((userId, doc) => {
|
CustomFields.before.remove((userId, doc) => {
|
||||||
|
customFieldDeletion(userId, doc);
|
||||||
Activities.remove({
|
Activities.remove({
|
||||||
customFieldId: doc._id,
|
customFieldId: doc._id,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue