mirror of https://github.com/zulip/zulip.git
For mit.edu, include unclasses and .d classes in narrowed views
(imported from commit e21aab715c949d4348c447e6e135281b47e06b98)
This commit is contained in:
parent
dc54a24766
commit
45116a0b61
|
@ -103,7 +103,7 @@ Filter.prototype = {
|
|||
// build JavaScript code in a string and then eval() it.
|
||||
|
||||
return function (message) {
|
||||
var operand, i;
|
||||
var operand, i, index;
|
||||
for (i = 0; i < operators.length; i++) {
|
||||
operand = operators[i][1];
|
||||
switch (operators[i][0]) {
|
||||
|
@ -133,9 +133,19 @@ Filter.prototype = {
|
|||
break;
|
||||
|
||||
case 'stream':
|
||||
if ((message.type !== 'stream') ||
|
||||
(message.stream.toLowerCase() !== operand))
|
||||
if (message.type !== 'stream')
|
||||
return false;
|
||||
|
||||
if (page_params.domain === "mit.edu") {
|
||||
// MIT users expect narrowing to "social" to also show messages to /^(un)*social(.d)*$/
|
||||
// (unsocial, ununsocial, social.d, etc)
|
||||
var related_regexp = new RegExp(/^(un)*/.source + util.escape_regexp(message.stream) + /(.d)*$/.source, 'i');
|
||||
if (! related_regexp.test(operand)) {
|
||||
return false;
|
||||
}
|
||||
} else if (message.stream.toLowerCase() !== operand) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'subject':
|
||||
|
|
|
@ -696,6 +696,15 @@ class NarrowBuilder(object):
|
|||
stream = get_stream(operand, self.user_profile.realm)
|
||||
if stream is None:
|
||||
raise BadNarrowOperator('unknown stream ' + operand)
|
||||
|
||||
if self.user_profile.realm.domain == "mit.edu":
|
||||
# MIT users expect narrowing to "social" to also show messages to /^(un)*social(.d)*$/
|
||||
# (unsocial, ununsocial, social.d, etc)
|
||||
matching_streams = Stream.objects.filter(realm=self.user_profile.realm,
|
||||
name__iregex=r'"^(un)*%s(.d)*$' % (re.escape(stream.name),))
|
||||
return self.pQ(recipient__in=[get_recipient(Recipient.STREAM, type_id=stream.id)
|
||||
for stream in matching_streams])
|
||||
|
||||
recipient = get_recipient(Recipient.STREAM, type_id=stream.id)
|
||||
return self.pQ(recipient=recipient)
|
||||
|
||||
|
|
Loading…
Reference in New Issue