summaryrefslogtreecommitdiffstats
path: root/models/export.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2016-01-05 13:37:15 +0100
committerMaxime Quandalle <maxime@quandalle.com>2016-01-05 13:37:15 +0100
commit701262a4394ea3fad1d64275930804db4f4ba182 (patch)
tree8cf1a9fd052008aa2d7ffa60102dc699018a92a8 /models/export.js
parent9ef8ebaf09e52d7133ebe08ab1354ef663ee948b (diff)
downloadwekan-701262a4394ea3fad1d64275930804db4f4ba182.tar.gz
wekan-701262a4394ea3fad1d64275930804db4f4ba182.tar.bz2
wekan-701262a4394ea3fad1d64275930804db4f4ba182.zip
Favor FlowRouter.url over Meteor.absoluteUrl
It hides the leading slash treatment as an hidden implementation detail.
Diffstat (limited to 'models/export.js')
-rw-r--r--models/export.js28
1 files changed, 16 insertions, 12 deletions
diff --git a/models/export.js b/models/export.js
index 3d8ee99e..b774cf15 100644
--- a/models/export.js
+++ b/models/export.js
@@ -2,8 +2,10 @@
if(Meteor.isServer) {
// todo XXX once we have a real API in place, move that route there
// todo XXX also share the route definition between the client and the server
- // so that we could use something like ApiRoutes.path('boards/export', boardId)
- // on the client instead of copy/pasting the route path manually between the client and the server.
+ // so that we could use something like
+ // `ApiRoutes.path('boards/export', boardId)``
+ // on the client instead of copy/pasting the route path manually between the
+ // client and the server.
/*
* This route is used to export the board FROM THE APPLICATION.
* If user is already logged-in, pass loginToken as param "authToken":
@@ -29,8 +31,8 @@ if(Meteor.isServer) {
if(exporter.canExport(user)) {
JsonRoutes.sendResult(res, 200, exporter.build());
} else {
- // we could send an explicit error message, but on the other hand the only way to
- // get there is by hacking the UI so let's keep it raw.
+ // we could send an explicit error message, but on the other hand the only
+ // way to get there is by hacking the UI so let's keep it raw.
JsonRoutes.sendResult(res, 403);
}
});
@@ -54,14 +56,16 @@ class Exporter {
result.comments = CardComments.find(byBoard, noBoardId).fetch();
result.activities = Activities.find(byBoard, noBoardId).fetch();
// for attachments we only export IDs and absolute url to original doc
- result.attachments = Attachments.find(byBoard).fetch().map((attachment) => { return {
- _id: attachment._id,
- cardId: attachment.cardId,
- url: Meteor.absoluteUrl(Utils.stripLeadingSlash(attachment.url())),
- };});
+ result.attachments = Attachments.find(byBoard).fetch().map((attachment) => {
+ return {
+ _id: attachment._id,
+ cardId: attachment.cardId,
+ url: FlowRouter.url(attachment.url()),
+ };
+ });
- // we also have to export some user data - as the other elements only include id
- // but we have to be careful:
+ // we also have to export some user data - as the other elements only
+ // include id but we have to be careful:
// 1- only exports users that are linked somehow to that board
// 2- do not export any sensitive information
const users = {};
@@ -88,7 +92,7 @@ class Exporter {
result.users = Users.find(byUserIds, userFields).fetch().map((user) => {
// user avatar is stored as a relative url, we export absolute
if(user.profile.avatarUrl) {
- user.profile.avatarUrl = Meteor.absoluteUrl(Utils.stripLeadingSlash(user.profile.avatarUrl));
+ user.profile.avatarUrl = FlowRouter.url(user.profile.avatarUrl);
}
return user;
});