summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <yuval@y3xz.com>2015-07-08 00:44:33 +0300
committerYuval Adam <yuval@y3xz.com>2015-07-08 00:44:33 +0300
commit7b5c0eb8844e75fd0dae2b816dd5a313dd657f92 (patch)
treef39817441fa92d660cff816e287c1688cc501367
parent0af98ba6002da726dfb511c7a7dccb1a858950aa (diff)
Add printing CRUD
-rw-r--r--lib/router.js8
-rw-r--r--server/methods.js11
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/router.js b/lib/router.js
index 55816d0..daddf5e 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -8,6 +8,14 @@ Router.route('/photos', {name: 'photos'});
Router.route('/about', {name: 'about'});
+Router.route('/prints', function () {
+ var self = this;
+ var res = Prints.find({ ts: { $gt: new Date().getTime() - 60000 } }).fetch()
+ self.response.setHeader('Content-Type', 'application/json');
+ self.response.write(JSON.stringify(res));
+ self.response.end();
+}, { where: 'server' });
+
Router.route('/imgproxy', function () {
var self = this;
var url = 'http://scontent.cdninstagram.com' + this.request._parsedUrl.search.match(/url\=[^\&]+/)[0].split('=')[1];
diff --git a/server/methods.js b/server/methods.js
index 8f6cc52..5713479 100644
--- a/server/methods.js
+++ b/server/methods.js
@@ -1,3 +1,5 @@
+Prints = new Mongo.Collection('prints');
+
Meteor.methods({
getInstagramMedia: function (year, month) {
this.unblock();
@@ -12,10 +14,15 @@ Meteor.methods({
getInstagramProfilePhoto: function () {
return Meteor.user().services.instagram.profile_picture;
},
- printFinalImage: function(code) {
+ printFinalImage: function (code) {
if (Meteor.userId()) {
var username = Meteor.user().services.instagram.username;
- console.log('Printing', username + '|' + code);
+ var data = username + '|' + code;
+ Prints.insert({
+ data: data,
+ ip: this.connection.clientAddress,
+ ts: new Date().getTime()
+ })
}
}
});