Permalink
Browse files

maj en temps reel de l'issue courante par utilisateur

  • Loading branch information...
Sebastien Vitry
Sebastien Vitry committed Mar 29, 2012
1 parent 2ff6d4a commit bd4a410146f94c9e77e3c4bed102cc039b593645
Showing with 31 additions and 14 deletions.
  1. +28 −12 lib/irc.js
  2. +1 −0 lib/redmine.js
  3. +2 −2 server.js
View
@@ -9,15 +9,7 @@ var irc ={},
*/
irc.init = function() {
- io.sockets.on('connection', function(socket){
- irc.start();
- socket.on('irc::run', function(data){
-
- });
- socket.on('disconnect', function(data){
- irc.stop();
- });
- });
+ irc.start();
};
irc.start = function(callback) {
@@ -29,18 +21,42 @@ irc.start = function(callback) {
}));
client.addListener('pm', function (from, message){
console.log(from + ' => ME: ' + message);
+ storeCurrentIssue(from, message, callback);
});
callback = callback || function(){};
callback();
};
-var storeCurrentIssue = function(from, message, callback) {
- var SkUser = mongoose.model('SkUser', SkUsers);
- var db = mongoose.connect(config.mongo.host);
+var parseMess = function( message, callback ) {
+ var issue = message.split( 'issues/show/' )[ 1 ];
+ var arrayUser = message.split( ' ' );
+ var login = arrayUser[ 0 ];
+ if(login.match(',')){
+ login = login.split(',')[0];
+ issue = '';
+ }
+
+ if(typeof issue === 'undefined'){
+ issue = '';
+ }
callback = callback || function(){};
callback();
+console.log('####### user => ' + login);
+console.log('####### issue => ' + issue);
+ return {user : login, issue : issue};
+};
+
+var storeCurrentIssue = function(from, message, callback) {
+ var SkUser = mongoose.model('SkUser');
+
+ var majJSON = parseMess( message );
+
+ SkUser.update({login:majJSON.user}, {current:majJSON.issue}, {}, callback);
+
+ //callback = callback || function(){};
+ //callback();
};
irc.stop = function(callback) {
View
@@ -272,6 +272,7 @@ redmine.setUsersIssues = function( callback ) {
//callback( null, assignedIssues );
var skUser = new SkUser({
id: doc.id,
+ current: '',
login: doc.login,
name: doc.firstname + ' ' + doc.lastname,
redmine: {
View
@@ -79,8 +79,8 @@ redmine.init();
//mongo.initObjects( null, function(){} );
-//var irc = require('./lib/irc.js');
-//irc.init();
+var irc = require('./lib/irc.js');
+irc.init();
///////////////////////////////////////////
// Routes //

0 comments on commit bd4a410

Please sign in to comment.