summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorRomulus Urakagi Tsai <urakagi@gmail.com>2019-11-20 10:40:09 +0000
committerRomulus Urakagi Tsai <urakagi@gmail.com>2019-11-20 10:40:09 +0000
commit4dcdec0084414e7dde9e630add01ecd2865bd941 (patch)
treeba145af20e31e57c48e25948d14f31469e8b2690 /models
parent05c53ca01d71a01a608c9ae345475abd67c9939b (diff)
downloadwekan-4dcdec0084414e7dde9e630add01ecd2865bd941.tar.gz
wekan-4dcdec0084414e7dde9e630add01ecd2865bd941.tar.bz2
wekan-4dcdec0084414e7dde9e630add01ecd2865bd941.zip
Attachment upload from card done, need to fix download link
Diffstat (limited to 'models')
-rw-r--r--models/attachments.js10
-rw-r--r--models/cards.js12
-rw-r--r--models/export.js2
-rw-r--r--models/trelloCreator.js1
-rw-r--r--models/wekanCreator.js2
5 files changed, 16 insertions, 11 deletions
diff --git a/models/attachments.js b/models/attachments.js
index fd03e6d2..4537e47c 100644
--- a/models/attachments.js
+++ b/models/attachments.js
@@ -4,7 +4,7 @@ Attachments = new FilesCollection({
storagePath: storagePath(),
debug: true, // FIXME: Remove debug mode
collectionName: 'attachments2',
- allowClientCode: false, // Disallow remove files from Client
+ allowClientCode: true, // FIXME: Permissions
});
if (Meteor.isServer) {
@@ -15,11 +15,11 @@ if (Meteor.isServer) {
// TODO: Permission related
// TODO: Add Activity update
// TODO: publish and subscribe
-// Meteor.publish('files.attachments.all', function () {
-// return Attachments.find().cursor;
-// });
+ Meteor.publish('attachments', function() {
+ return Attachments.find().cursor;
+ });
} else {
-// Meteor.subscribe('files.attachments.all');
+ Meteor.subscribe('attachments');
}
// ---------- Deprecated fallback ---------- //
diff --git a/models/cards.js b/models/cards.js
index 3944b09f..4c3e2c99 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -366,7 +366,7 @@ Cards.helpers({
// Copy attachments
oldCard.attachments().forEach(att => {
- att.cardId = _id;
+ att.meta.cardId = _id;
delete att._id;
return Attachments.insert(att);
});
@@ -456,14 +456,16 @@ Cards.helpers({
attachments() {
if (this.isLinkedCard()) {
return Attachments.find(
- { cardId: this.linkedId },
+ { 'meta.cardId': this.linkedId },
{ sort: { uploadedAt: -1 } },
);
} else {
- return Attachments.find(
- { cardId: this._id },
+ const ret = Attachments.find(
+ { 'meta.cardId': this._id },
{ sort: { uploadedAt: -1 } },
);
+ if (ret.first()) console.log('link', Attachments.link(ret.first()));
+ return ret;
}
},
@@ -471,7 +473,7 @@ Cards.helpers({
const cover = Attachments.findOne(this.coverId);
// if we return a cover before it is fully stored, we will get errors when we try to display it
// todo XXX we could return a default "upload pending" image in the meantime?
- return cover && cover.url() && cover;
+ return cover && cover.link();
},
checklists() {
diff --git a/models/export.js b/models/export.js
index cc979ce0..c93a8bda 100644
--- a/models/export.js
+++ b/models/export.js
@@ -162,7 +162,7 @@ export class Exporter {
readStream.pipe(tmpWriteable);
};
const getBase64DataSync = Meteor.wrapAsync(getBase64Data);
- result.attachments = Attachments.find(byBoard)
+ result.attachments = Attachments.find({ 'meta.boardId': byBoard.boardId })
.fetch()
.map(attachment => {
return {
diff --git a/models/trelloCreator.js b/models/trelloCreator.js
index cb1a6a67..b38e4652 100644
--- a/models/trelloCreator.js
+++ b/models/trelloCreator.js
@@ -345,6 +345,7 @@ export class TrelloCreator {
// so we make it server only, and let UI catch up once it is done, forget about latency comp.
const self = this;
if (Meteor.isServer) {
+ // FIXME: Change to new model
file.attachData(att.url, function(error) {
file.boardId = boardId;
file.cardId = cardId;
diff --git a/models/wekanCreator.js b/models/wekanCreator.js
index ec85d93f..175c156d 100644
--- a/models/wekanCreator.js
+++ b/models/wekanCreator.js
@@ -415,6 +415,7 @@ export class WekanCreator {
const self = this;
if (Meteor.isServer) {
if (att.url) {
+ // FIXME: Change to new file library
file.attachData(att.url, function(error) {
file.boardId = boardId;
file.cardId = cardId;
@@ -440,6 +441,7 @@ export class WekanCreator {
}
});
} else if (att.file) {
+ // FIXME: Change to new file library
file.attachData(
new Buffer(att.file, 'base64'),
{