Fix challenges retrieval from server
[vchess.git] / server / models / User.js
index 9e1aded..6058427 100644 (file)
@@ -63,14 +63,14 @@ const UserModel =
                });
        },
 
-  getByName: function(names, cb) {
-               db.serialize(function() {
-                       const query =
-                               "SELECT id " +
+  getByIds: function(ids, cb) {
+    db.serialize(function() {
+      const query =
+        "SELECT id, name " +
         "FROM Users " +
-                               "WHERE name IN ('" + names.join("','") + "')";
-                       db.all(query, cb);
-               });
+        "WHERE id IN (" + ids + ")";
+      db.all(query, cb);
+    });
   },
 
        /////////
@@ -124,6 +124,15 @@ const UserModel =
                        db.run(query, cb);
                });
        },
+
+  /////////////////
+  // NOTIFICATIONS
+
+  tryNotify: function(oppId, gid, vname, message)
+  {
+    // TODO: send email to oppId (request...) with title
+    // "vchess.club - vname" and content "message"
+  }
 }
 
 module.exports = UserModel;