summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-06-27 04:06:21 +0300
committerLauri Ojansivu <x@xet7.org>2019-06-27 04:06:21 +0300
commit5283ba9ebbedf11540ffef1d4d87891c5ce9efc7 (patch)
tree65355a19da1796d3ca34ceda95f96c731b22bae9 /models
parent7c89336ea9125648ed9b5ba50de16e4e4a2d0fc4 (diff)
downloadwekan-5283ba9ebbedf11540ffef1d4d87891c5ce9efc7.tar.gz
wekan-5283ba9ebbedf11540ffef1d4d87891c5ce9efc7.tar.bz2
wekan-5283ba9ebbedf11540ffef1d4d87891c5ce9efc7.zip
- 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
Diffstat (limited to 'models')
-rw-r--r--models/activities.js1
-rw-r--r--models/cardComments.js33
-rw-r--r--models/checklistItems.js22
-rw-r--r--models/checklists.js12
-rw-r--r--models/customFields.js27
5 files changed, 77 insertions, 18 deletions
diff --git a/models/activities.js b/models/activities.js
index a4a48284..908d4b14 100644
--- a/models/activities.js
+++ b/models/activities.js
@@ -180,6 +180,7 @@ if (Meteor.isServer) {
if (activity.customFieldId) {
const customField = activity.customField();
params.customField = customField.name;
+ params.customFieldValue = customField.text;
}
// Label activity did not work yet, unable to edit labels when tried this.
//if (activity.labelId) {
diff --git a/models/cardComments.js b/models/cardComments.js
index 2bcb5453..a823066c 100644
--- a/models/cardComments.js
+++ b/models/cardComments.js
@@ -81,14 +81,15 @@ CardComments.helpers({
CardComments.hookOptions.after.update = { fetchPrevious: false };
function commentCreation(userId, doc){
+ const card = Cards.findOne(doc.cardId);
Activities.insert({
userId,
activityType: 'addComment',
boardId: doc.boardId,
cardId: doc.cardId,
commentId: doc._id,
- listId: doc.listId,
- swimlaneId: doc.swimlaneId,
+ listId: card.listId,
+ swimlaneId: card.swimlaneId,
});
}
@@ -103,6 +104,34 @@ if (Meteor.isServer) {
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) => {
const activity = Activities.findOne({ commentId: doc._id });
if (activity) {
diff --git a/models/checklistItems.js b/models/checklistItems.js
index 013fee04..df56c475 100644
--- a/models/checklistItems.js
+++ b/models/checklistItems.js
@@ -94,9 +94,9 @@ function itemCreation(userId, doc) {
boardId,
checklistId: doc.checklistId,
checklistItemId: doc._id,
- checklistItemName:doc.title,
- listId: doc.listId,
- swimlaneId: doc.swimlaneId,
+ checklistItemName: doc.title,
+ listId: card.listId,
+ swimlaneId: card.swimlaneId,
});
}
@@ -123,8 +123,8 @@ function publishCheckActivity(userId, doc){
checklistId: doc.checklistId,
checklistItemId: doc._id,
checklistItemName:doc.title,
- listId: doc.listId,
- swimlaneId: doc.swimlaneId,
+ listId: card.listId,
+ swimlaneId: card.swimlaneId,
};
Activities.insert(act);
}
@@ -142,8 +142,8 @@ function publishChekListCompleted(userId, doc){
boardId,
checklistId: doc.checklistId,
checklistName: checkList.title,
- listId: doc.listId,
- swimlaneId: doc.swimlaneId,
+ listId: card.listId,
+ swimlaneId: card.swimlaneId,
};
Activities.insert(act);
}
@@ -175,8 +175,8 @@ function publishChekListUncompleted(userId, doc){
boardId,
checklistId: doc.checklistId,
checklistName: checkList.title,
- listId: doc.listId,
- swimlaneId: doc.swimlaneId,
+ listId: card.listId,
+ swimlaneId: card.swimlaneId,
};
Activities.insert(act);
}
@@ -215,8 +215,8 @@ if (Meteor.isServer) {
checklistId: doc.checklistId,
checklistItemId: doc._id,
checklistItemName:doc.title,
- listId: doc.listId,
- swimlaneId: doc.swimlaneId,
+ listId: card.listId,
+ swimlaneId: card.swimlaneId,
});
});
}
diff --git a/models/checklists.js b/models/checklists.js
index 33cb0f40..653fed4d 100644
--- a/models/checklists.js
+++ b/models/checklists.js
@@ -128,20 +128,22 @@ if (Meteor.isServer) {
});
Checklists.after.insert((userId, doc) => {
+ const card = Cards.findOne(doc.cardId);
Activities.insert({
userId,
activityType: 'addChecklist',
cardId: doc.cardId,
- boardId: Cards.findOne(doc.cardId).boardId,
+ boardId: card.boardId,
checklistId: doc._id,
checklistName:doc.title,
- listId: doc.listId,
- swimlaneId: doc.swimlaneId,
+ listId: card.listId,
+ swimlaneId: card.swimlaneId,
});
});
Checklists.before.remove((userId, doc) => {
const activities = Activities.find({ checklistId: doc._id });
+ const card = Cards.findOne(doc.cardId);
if (activities) {
activities.forEach((activity) => {
Activities.remove(activity._id);
@@ -154,8 +156,8 @@ if (Meteor.isServer) {
boardId: Cards.findOne(doc.cardId).boardId,
checklistId: doc._id,
checklistName:doc.title,
- listId: doc.listId,
- swimlaneId: doc.swimlaneId,
+ listId: card.listId,
+ swimlaneId: card.swimlaneId,
});
});
}
diff --git a/models/customFields.js b/models/customFields.js
index a67ddb7d..83033cb4 100644
--- a/models/customFields.js
+++ b/models/customFields.js
@@ -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) {
Meteor.startup(() => {
CustomFields._collection._ensureIndex({ boardIds: 1 });
@@ -133,9 +156,12 @@ if (Meteor.isServer) {
{$pull: {'customFields': {'_id': doc._id}}},
{multi: true}
);
+ customFieldEdit(userId, doc);
Activities.remove({
customFieldId: doc._id,
boardId: modifier.$pull.boardIds,
+ listId: card.listId,
+ swimlaneId: card.swimlaneId,
});
} else if (_.contains(fieldNames, 'boardIds') && modifier.$push) {
Activities.insert({
@@ -148,6 +174,7 @@ if (Meteor.isServer) {
});
CustomFields.before.remove((userId, doc) => {
+ customFieldDeletion(userId, doc);
Activities.remove({
customFieldId: doc._id,
});