httpMemberMgr.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * 房间管理http接口
  3. */
  4. 'use strict';
  5. var F = require('../common/function');
  6. var C = require('../config/index');
  7. var _ = require('underscore');
  8. _.str = require('underscore.string');
  9. _.v = require('validator');
  10. var co = require('co');
  11. module.exports = function (app) {
  12. var mgr_map = app.common_mgr.mgr_map;
  13. var http_app = app.app;
  14. /**
  15. * 4.3.http:同步用户信息接口(Java→IM)
  16. */
  17. http_app.regPost('/imroom/:apiVer/updateMemberInfo', function* (ctx) {
  18. yield F.checkParamsNull(ctx, "user_info");
  19. let user_info = ctx.I.user_info;
  20. yield F.assertParamNull(user_info, "uid");
  21. let member = {};
  22. member.account = user_info.uid;
  23. member.nick = user_info.nick;
  24. member.avatar = user_info.avatar;
  25. member.gender = user_info.gender;
  26. member.headwear_url = user_info.headwearUrl;
  27. member.headwear_name = user_info.headwearName;
  28. member.car_url = user_info.carUrl;
  29. member.car_name = user_info.carName;
  30. member.exper_level = user_info.experLevel;
  31. member.charm_level = user_info.charmLevel;
  32. member.create_time = user_info.createTime;
  33. yield mgr_map.redis.setUserInfo(user_info.uid, member);
  34. F.setResJson(ctx, 0);
  35. });
  36. /**
  37. * 4.21.http:踢除特定成员(Client→Server)
  38. * room_id:房间id string
  39. * account:要踢除的uid string
  40. * uid: 发请求的用户
  41. * ticket:发请求的用户ticket
  42. */
  43. http_app.regPost('/imroom/:apiVer/kickMember', function* (ctx) {
  44. yield F.checkParamsNull(ctx, "room_id, account, uid, ticket"); // ext参数不能为空
  45. let room_id = ctx.I.room_id;
  46. let uid = ctx.I.uid;
  47. let account = ctx.I.account;
  48. let is_creator = yield mgr_map.validator.isRoomCreator(room_id, uid);
  49. let is_manager = yield mgr_map.validator.isRoomManager(room_id, uid);
  50. if (!is_creator && !is_manager) {
  51. F.throwErrCode(100405);
  52. }
  53. yield mgr_map.room.kickOffRoom(account,room_id);
  54. F.setResJson(ctx, 0);
  55. });
  56. /**
  57. * 4.23.http:查询房间管理员列表(Client→Server)军圣
  58. */
  59. http_app.regPost('/imroom/:apiVer/fetchRoomManagers', function* (ctx) {
  60. yield F.checkParamsNull(ctx, "room_id,uid,ticket");
  61. let room_id = ctx.I.room_id;
  62. let managers = yield mgr_map.member.fetchRoomManagers(room_id);
  63. F.setResJson(ctx, 0, managers);
  64. });
  65. /**
  66. * 4.24.http:查询房间黑名单列表(Client→Server)军圣
  67. */
  68. http_app.regPost('/imroom/:apiVer/fetchRoomBlackList', function* (ctx) {
  69. yield F.checkParamsNull(ctx, "room_id,uid,ticket");
  70. let room_id = ctx.I.room_id;
  71. let managers = yield mgr_map.member.fetchRoomBlackList(room_id);
  72. F.setResJson(ctx, 0, managers);
  73. });
  74. };