Permalink
Browse files

update activity done

  • Loading branch information...
1 parent f5c7064 commit 1faed57ef84c789bb09af56f328ebe94ee417c69 @rxkh rxkh committed Jun 6, 2012
Showing with 9 additions and 6 deletions.
  1. +2 −2 client/index.html
  2. +7 −4 server/activity.js
View
4 client/index.html
@@ -68,8 +68,8 @@
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
- //var socket = io.connect('http://localhost:8000');
- var socket = io.connect('http://ec2-23-20-135-217.compute-1.amazonaws.com:8000');
+ var socket = io.connect('http://localhost:8000');
+ //var socket = io.connect('http://ec2-23-20-135-217.compute-1.amazonaws.com:8000');
var friendList;
var globalgrouplist;
var chatobject;
View
11 server/activity.js
@@ -58,7 +58,7 @@ function addActivity(activity, callback) {
var data = new Array();
obj.documents[0].results.forEach(function (result) {
var obj = result.obj;
- if (obj._id in clients) {
+ if (obj._id in clients && obj._id != uid) {
clients[obj._id].emit('recommend activity', activity);
console.log('recommend activity to ' + obj._id);
}
@@ -101,11 +101,14 @@ function updateActivityDetails(activity, callback) {
if (!uid) return;
redis.hget('activities:' + activity._id, 'creator_id', function(err, cid) {
if (uid != cid) return;
+ var aid = activity._id;
// set in mongo
- db.activities.update({'_id': db.ObjectId(activity._id)}, {$set: activity});
+ delete activity._id;
+ db.activities.update({'_id': db.ObjectId(aid)}, {$set: activity});
// set in redis
- for (key in activity)
- redis.hset('activities:' + activity._id, key, activity[key]);
+ for (key in activity)
+ redis.hset('activities:' + aid, key, activity[key]);
+ console.log('activity ' + aid + 'updated');
callback({err: 0, msg: ''});
});
});

0 comments on commit 1faed57

Please sign in to comment.