浏览代码

Try to get some label outgoing webhooks working.

Thanks to xet7 !

Related #4898
Lauri Ojansivu 1 年之前
父节点
当前提交
b40654cdfe
共有 3 个文件被更改,包括 23 次插入11 次删除
  1. 19 11
      models/activities.js
  2. 1 0
      models/cards.js
  3. 3 0
      server/notifications/outgoing.js

+ 19 - 11
models/activities.js

@@ -58,10 +58,10 @@ Activities.helpers({
   customField() {
     return ReactiveCache.getCustomField(this.customFieldId);
   },
-  // Label activity did not work yet, unable to edit labels when tried this.
-  //label() {
-  //  return ReactiveCache.getCard(this.labelId);
-  //},
+  label() {
+    // Label activity did not work yet, unable to edit labels when tried this.
+    return ReactiveCache.getCard(this.labelId);
+  },
 });
 
 Activities.before.update((userId, doc, fieldNames, modifier) => {
@@ -101,8 +101,8 @@ if (Meteor.isServer) {
       { partialFilterExpression: { customFieldId: { $exists: true } } },
     );
     // Label activity did not work yet, unable to edit labels when tried this.
-    //Activities._collection._dropIndex({ labelId: 1 }, { "indexKey": -1 });
-    //Activities._collection._dropIndex({ labelId: 1 }, { partialFilterExpression: { labelId: { $exists: true } } });
+    //Activities._collection.dropIndex({ labelId: 1 }, { "indexKey": -1 });
+    //Activities._collection.dropIndex({ labelId: 1 }, { partialFilterExpression: { labelId: { $exists: true } } });
   });
 
   Activities.after.insert((userId, doc) => {
@@ -280,11 +280,19 @@ if (Meteor.isServer) {
       }
     }
     // Label activity did not work yet, unable to edit labels when tried this.
-    //if (activity.labelId) {
-    //  const label = activity.label();
-    //  params.label = label.name;
-    //  params.labelId = activity.labelId;
-    //}
+    if (activity.labelId) {
+      const label = activity.label();
+      if (label) {
+        if (label.name) {
+          params.label = label.name;
+        } else if (label.color) {
+          params.label = label.color;
+        }
+        if (label._id) {
+          params.labelId = label._id;
+        }
+      }
+    }
     if (
       (!activity.timeKey || activity.timeKey === 'dueAt') &&
       activity.timeValue

+ 1 - 0
models/cards.js

@@ -2820,6 +2820,7 @@ function cardLabels(userId, doc, fieldNames, modifier) {
   // Say hello to the new label
   if (modifier.$addToSet && modifier.$addToSet.labelIds) {
     labelId = modifier.$addToSet.labelIds;
+    //const label = labels(labelId).name;
     if (!_.contains(doc.labelIds, labelId)) {
       const act = {
         userId,

+ 3 - 0
server/notifications/outgoing.js

@@ -66,6 +66,8 @@ if (Meteor.isServer) {
     'swimlaneId',
     'customField',
     'customFieldValue',
+    'labelId',
+    'label',
     'attachmentId',
   ];
   const responseFunc = data => {
@@ -126,6 +128,7 @@ if (Meteor.isServer) {
           'checklist',
           'swimlane',
           'oldSwimlane',
+          'labelId',
           'label',
           'attachment',
           'attachmentId',