mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Add source field to imported attachments
We use this field to prevent adding attachments' related activities automatically only. Then this field will be removed.
This commit is contained in:
parent
4ad4c6ea22
commit
6ff0cf91e2
3 changed files with 26 additions and 8 deletions
|
|
@ -55,14 +55,23 @@ if (Meteor.isServer) {
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
Attachments.files.after.insert((userId, doc) => {
|
Attachments.files.after.insert((userId, doc) => {
|
||||||
Activities.insert({
|
// If the attachment doesn't have a source field
|
||||||
userId,
|
// or its source is different than import
|
||||||
type: 'card',
|
if (!doc.source || doc.source !== 'import') {
|
||||||
activityType: 'addAttachment',
|
// Add activity about adding the attachment
|
||||||
attachmentId: doc._id,
|
Activities.insert({
|
||||||
boardId: doc.boardId,
|
userId,
|
||||||
cardId: doc.cardId,
|
type: 'card',
|
||||||
});
|
activityType: 'addAttachment',
|
||||||
|
attachmentId: doc._id,
|
||||||
|
boardId: doc.boardId,
|
||||||
|
cardId: doc.cardId,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Don't add activity about adding the attachment as the activity
|
||||||
|
// be imported and delete source field
|
||||||
|
Attachments.update( {_id: doc._id} , {$unset: { source : "" } } );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Attachments.files.after.remove((userId, doc) => {
|
Attachments.files.after.remove((userId, doc) => {
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,9 @@ export class TrelloCreator {
|
||||||
file.boardId = boardId;
|
file.boardId = boardId;
|
||||||
file.cardId = cardId;
|
file.cardId = cardId;
|
||||||
file.userId = this._user(att.idMemberCreator);
|
file.userId = this._user(att.idMemberCreator);
|
||||||
|
// The field source will only be used to prevent adding
|
||||||
|
// attachments' related activities automatically
|
||||||
|
file.source = 'import';
|
||||||
if (error) {
|
if (error) {
|
||||||
throw(error);
|
throw(error);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -313,6 +313,9 @@ export class WekanCreator {
|
||||||
file.boardId = boardId;
|
file.boardId = boardId;
|
||||||
file.cardId = cardId;
|
file.cardId = cardId;
|
||||||
file.userId = this._user(att.userId);
|
file.userId = this._user(att.userId);
|
||||||
|
// The field source will only be used to prevent adding
|
||||||
|
// attachments' related activities automatically
|
||||||
|
file.source = 'import';
|
||||||
if (error) {
|
if (error) {
|
||||||
throw(error);
|
throw(error);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -332,6 +335,9 @@ export class WekanCreator {
|
||||||
file.boardId = boardId;
|
file.boardId = boardId;
|
||||||
file.cardId = cardId;
|
file.cardId = cardId;
|
||||||
file.userId = this._user(att.userId);
|
file.userId = this._user(att.userId);
|
||||||
|
// The field source will only be used to prevent adding
|
||||||
|
// attachments' related activities automatically
|
||||||
|
file.source = 'import';
|
||||||
if (error) {
|
if (error) {
|
||||||
throw(error);
|
throw(error);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue