Fixed IRC federation's issues with the no-cache branch (#11906)

pull/12175/head^2
Pierre H. Lehnen 7 years ago committed by Aaron Ogle
parent a265af96f8
commit cabcecab88
  1. 10
      packages/rocketchat-irc/server/irc-bridge/localHandlers/onCreateRoom.js
  2. 2
      packages/rocketchat-irc/server/irc-bridge/localHandlers/onCreateUser.js
  3. 2
      packages/rocketchat-irc/server/irc-bridge/localHandlers/onLogin.js
  4. 3
      packages/rocketchat-irc/server/irc-bridge/peerHandlers/sentMessage.js
  5. 4
      packages/rocketchat-lib/server/models/Rooms.js
  6. 10
      packages/rocketchat-lib/server/models/Users.js

@ -1,15 +1,11 @@
export default function handleOnCreateRoom(user, room) { export default function handleOnCreateRoom(user, room) {
if (!room.usernames) { const users = RocketChat.models.Users.findByRoomId(room._id);
return this.log(`Room ${ room.name } does not have a valid list of usernames`);
}
for (const username of room.usernames) {
const user = RocketChat.models.Users.findOne({ username });
users.forEach((user) => {
if (user.profile.irc.fromIRC) { if (user.profile.irc.fromIRC) {
this.sendCommand('joinChannel', { room, user }); this.sendCommand('joinChannel', { room, user });
} else { } else {
this.sendCommand('joinedChannel', { room, user }); this.sendCommand('joinedChannel', { room, user });
} }
} });
} }

@ -26,7 +26,7 @@ export default function handleOnCreateUser(newUser) {
this.sendCommand('registerUser', user); this.sendCommand('registerUser', user);
const rooms = RocketChat.models.Rooms.findWithUsername(user.username).fetch(); const rooms = RocketChat.models.Rooms.findBySubscriptionUserId(user._id).fetch();
rooms.forEach((room) => this.sendCommand('joinedChannel', { room, user })); rooms.forEach((room) => this.sendCommand('joinedChannel', { room, user }));
} }

@ -26,7 +26,7 @@ export default function handleOnLogin(login) {
this.sendCommand('registerUser', user); this.sendCommand('registerUser', user);
const rooms = RocketChat.models.Rooms.findWithUsername(user.username).fetch(); const rooms = RocketChat.models.Rooms.findBySubscriptionUserId(user._id).fetch();
rooms.forEach((room) => this.sendCommand('joinedChannel', { room, user })); rooms.forEach((room) => this.sendCommand('joinedChannel', { room, user }));
} }

@ -8,9 +8,6 @@ const getDirectRoom = (source, target) => {
const rid = [source._id, target._id].sort().join(''); const rid = [source._id, target._id].sort().join('');
RocketChat.models.Rooms.upsert({ _id: rid }, { RocketChat.models.Rooms.upsert({ _id: rid }, {
$set: {
usernames: [source.username, target.username],
},
$setOnInsert: { $setOnInsert: {
t: 'd', t: 'd',
msgs: 0, msgs: 0,

@ -61,10 +61,6 @@ class ModelRooms extends RocketChat.models._Base {
// FIND // FIND
findWithUsername(username, options) {
return this.find({ usernames: username }, options);
}
findById(roomId, options) { findById(roomId, options) {
return this.find({ _id: roomId }, options); return this.find({ _id: roomId }, options);
} }

@ -80,6 +80,16 @@ class ModelUsers extends RocketChat.models._Base {
return this.find(query, options); return this.find(query, options);
} }
findByRoomId(rid, options) {
const data = RocketChat.models.Subscriptions.findByRoomId(rid).fetch().map((item) => item.u._id);
const query = {
_id: {
$in: data,
},
};
return this.find(query, options);
}
findByUsername(username, options) { findByUsername(username, options) {
const query = { username }; const query = { username };

Loading…
Cancel
Save