Skip to content

Commit

Permalink
Merge branch 'v0.6.0' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Barnard committed Oct 28, 2016
2 parents 9606f69 + ae29e46 commit b14ed96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions lib/DataStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ DataStore.prototype.getMatrixRoomsForChannel = function(server, channel) {
);
};

DataStore.prototype.getMappingsForChannelByOrigin = function(server, channel, origin) {
DataStore.prototype.getMappingsForChannelByOrigin = function(server, channel, origin, allowUnset) {
log.debug(
"getMatrixRoomsForChannelByOrigin " + channel + ", origin: " + JSON.stringify(origin)
);
Expand All @@ -256,12 +256,17 @@ DataStore.prototype.getMappingsForChannelByOrigin = function(server, channel, or
throw new Error("origin must be string or array of strings");
}
let remoteId = IrcRoom.createId(server, channel);

return this._roomStore.getEntriesByLinkData({
origin: {$in : origin}
}).then((entries) => {
return this._roomStore.getEntriesByLinkData({}).then((entries) => {
return entries.filter((e) => {
return e.remote.getId() === remoteId
if (!e.remote || e.remote.getId() !== remoteId) {
return false;
}
if (allowUnset) {
if (!e.data || !e.data.origin) {
return true;
}
}
return e.data && origin.indexOf(e.data.origin) !== -1;
});
});
};
Expand Down
2 changes: 1 addition & 1 deletion lib/bridge/IrcHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ IrcHandler.prototype.onTopic = Promise.coroutine(function*(req, server, fromUser
// Only bridge topics for rooms created by the bridge, via !join or an alias
let origins = ["join", "alias"];
let entries = yield this.ircBridge.getStore().getMappingsForChannelByOrigin(
server, channel, origins
server, channel, origins, true
);
if (entries.length === 0) {
req.log.info(
Expand Down

0 comments on commit b14ed96

Please sign in to comment.