Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add [media] support on ActivityItem, populate via instagram

  • Loading branch information...
commit a5da4457c72a78f2476c480a43345e5b9c1d763d 1 parent 35b0fac
@brianshaler brianshaler authored
Showing with 13 additions and 4 deletions.
  1. +8 −0 controllers/InstagramController.js
  2. +5 −4 models/ActivityItem.js
View
8 controllers/InstagramController.js
@@ -306,6 +306,14 @@ exports.controller = function(req, res, next) {
activity_item.guid = activity_item.platform + "-" + post.id;
activity_item.user = identity.id;
activity_item.message = message;
+ var image = {};
+ var keys = ["standard_resolution", "thumbnail", "low_resolution"];
+ image.type = "photo";
+ image.sizes = [];
+ keys.forEach (function (size) {
+ image.sizes.push({url: post.images[size].url, width: post.images[size].width, height: post.images[size].height});
+ });
+ activity_item.media = [image];
activity_item.posted_at = new Date(parseInt(post.created_time)*1000);
activity_item.analyzed_at = new Date(0);
activity_item.topics = [];
View
9 models/ActivityItem.js
@@ -25,10 +25,11 @@ function merge(array, newItem) {
var ActivityItemSchema = new Schema({
guid: {type: String, index: { unique: true }, required: true},
user: {type: ObjectId, index: true, ref: "Identity"},
- message: {type: String},
- posted_at: {type: Date},
- platform: {type: String},
- read: {type: Boolean},
+ message: {type: String, default: ""},
+ media: [{}],
+ posted_at: {type: Date, default: Date.now},
+ platform: {type: String, default: "unknown"},
+ read: {type: Boolean, default: false},
liked: {type: Boolean, default: false},
disliked: {type: Boolean, default: false},
ratings: {},
Please sign in to comment.
Something went wrong with that request. Please try again.