diff options
author | Lauri Ojansivu <x@xet7.org> | 2017-07-19 21:20:40 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2017-07-19 21:20:40 +0300 |
commit | 57f9c1df69c61fc0d2921f89309df9262935356d (patch) | |
tree | 9c2a77164560a45edf196972b2a066f975329263 /models/wekanCreator.js | |
parent | 52619ef622a4257001516cb63acd66af02832ff4 (diff) | |
parent | f3f15f83b0a85ee3bf0c74b7a66d0dff43d678db (diff) | |
download | wekan-57f9c1df69c61fc0d2921f89309df9262935356d.tar.gz wekan-57f9c1df69c61fc0d2921f89309df9262935356d.tar.bz2 wekan-57f9c1df69c61fc0d2921f89309df9262935356d.zip |
Merge branch 'GhassenRjab-attachment-base64' into devel
Export and import attachments as base64 encoded files. Thanks to GhassenRjab !
Update translations.
Diffstat (limited to 'models/wekanCreator.js')
-rw-r--r-- | models/wekanCreator.js | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/models/wekanCreator.js b/models/wekanCreator.js index b91b875a..723c5c67 100644 --- a/models/wekanCreator.js +++ b/models/wekanCreator.js @@ -96,7 +96,6 @@ export class WekanCreator { archived: Boolean, dateLastActivity: DateString, labelIds: [String], - members: [String], title: String, sort: Number, })]); @@ -107,7 +106,6 @@ export class WekanCreator { // XXX refine control by validating 'color' against a list of allowed // values (is it worth the maintenance?) color: String, - name: String, })]); } @@ -303,21 +301,40 @@ export class WekanCreator { // - the template then tries to display the url to the attachment which causes other errors // so we make it server only, and let UI catch up once it is done, forget about latency comp. if(Meteor.isServer) { - file.attachData(att.url, function (error) { - file.boardId = boardId; - file.cardId = cardId; - if (error) { - throw(error); - } else { - const wekanAtt = Attachments.insert(file, () => { - // we do nothing - }); - // - if(wekanCoverId === att._id) { - Cards.direct.update(cardId, { $set: {coverId: wekanAtt._id}}); + if (att.url) { + file.attachData(att.url, function (error) { + file.boardId = boardId; + file.cardId = cardId; + if (error) { + throw(error); + } else { + const wekanAtt = Attachments.insert(file, () => { + // we do nothing + }); + // + if(wekanCoverId === att._id) { + Cards.direct.update(cardId, { $set: {coverId: wekanAtt._id}}); + } } - } - }); + }); + } else if (att.file) { + file.attachData(new Buffer(att.file, 'base64'), {type: att.type}, (error) => { + file.name(att.name); + file.boardId = boardId; + file.cardId = cardId; + if (error) { + throw(error); + } else { + const wekanAtt = Attachments.insert(file, () => { + // we do nothing + }); + // + if(wekanCoverId === att._id) { + Cards.direct.update(cardId, { $set: {coverId: wekanAtt._id}}); + } + } + }); + } } // todo XXX set cover - if need be }); @@ -406,7 +423,7 @@ export class WekanCreator { const wekanAttachment = wekanBoard.attachments.filter((attachment) => { return attachment._id === activity.attachmentId; })[0]; - if(wekanAttachment.url) { + if(wekanAttachment.url || wekanAttachment.file) { // we cannot actually create the Wekan attachment, because we don't yet // have the cards to attach it to, so we store it in the instance variable. const wekanCardId = activity.cardId; |