Fix board-specific filtering in thread watcher.
This commit is contained in:
parent
6bc844bba1
commit
95487fd397
@ -17,12 +17,10 @@ Filter =
|
|||||||
# Don't mix up filter flags with the regular expression.
|
# Don't mix up filter flags with the regular expression.
|
||||||
filter = line.replace regexp[0], ''
|
filter = line.replace regexp[0], ''
|
||||||
|
|
||||||
# Do not add this filter to the list if it's not a global one
|
# Comma-separated list of the boards this filter applies to.
|
||||||
# and it's not specifically applicable to the current board.
|
|
||||||
# Defaults to global.
|
# Defaults to global.
|
||||||
boards = filter.match(/boards:([^;]+)/)?[1].toLowerCase() or 'global'
|
boards = filter.match(/boards:([^;]+)/)?[1].toLowerCase() or 'global'
|
||||||
if boards isnt 'global' and g.BOARD.ID not in boards.split ','
|
boards = if boards is 'global' then null else boards.split(',')
|
||||||
continue
|
|
||||||
|
|
||||||
if key in ['uniqueID', 'MD5']
|
if key in ['uniqueID', 'MD5']
|
||||||
# MD5 filter will use strings instead of regular expressions.
|
# MD5 filter will use strings instead of regular expressions.
|
||||||
@ -66,7 +64,7 @@ Filter =
|
|||||||
top = filter.match(/top:(yes|no)/)?[1] or 'yes'
|
top = filter.match(/top:(yes|no)/)?[1] or 'yes'
|
||||||
top = top is 'yes' # Turn it into a boolean
|
top = top is 'yes' # Turn it into a boolean
|
||||||
|
|
||||||
@filters[key].push @createFilter regexp, op, stub, hl, top
|
@filters[key].push @createFilter regexp, boards, op, stub, hl, top
|
||||||
|
|
||||||
# Only execute filter types that contain valid filters.
|
# Only execute filter types that contain valid filters.
|
||||||
unless @filters[key].length
|
unless @filters[key].length
|
||||||
@ -77,7 +75,7 @@ Filter =
|
|||||||
name: 'Filter'
|
name: 'Filter'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
createFilter: (regexp, op, stub, hl, top) ->
|
createFilter: (regexp, boards, op, stub, hl, top) ->
|
||||||
test =
|
test =
|
||||||
if typeof regexp is 'string'
|
if typeof regexp is 'string'
|
||||||
# MD5 checking
|
# MD5 checking
|
||||||
@ -91,7 +89,9 @@ Filter =
|
|||||||
class: hl
|
class: hl
|
||||||
top: top
|
top: top
|
||||||
|
|
||||||
(value, isReply) ->
|
(value, boardID, isReply) ->
|
||||||
|
if boards and boardID not in boards
|
||||||
|
return false
|
||||||
if isReply and op is 'only' or !isReply and op is 'no'
|
if isReply and op is 'only' or !isReply and op is 'no'
|
||||||
return false
|
return false
|
||||||
unless test value
|
unless test value
|
||||||
@ -103,7 +103,7 @@ Filter =
|
|||||||
for key of Filter.filters when (value = Filter[key] @)?
|
for key of Filter.filters when (value = Filter[key] @)?
|
||||||
# Continue if there's nothing to filter (no tripcode for example).
|
# Continue if there's nothing to filter (no tripcode for example).
|
||||||
|
|
||||||
for filter in Filter.filters[key] when result = filter value, @isReply
|
for filter in Filter.filters[key] when result = filter value, @board.ID, @isReply
|
||||||
# Hide
|
# Hide
|
||||||
if result.hide and not @isFetchedQuote
|
if result.hide and not @isFetchedQuote
|
||||||
if @isReply
|
if @isReply
|
||||||
@ -123,7 +123,7 @@ Filter =
|
|||||||
|
|
||||||
isHidden: (post) ->
|
isHidden: (post) ->
|
||||||
for key of Filter.filters when (value = Filter[key] post)?
|
for key of Filter.filters when (value = Filter[key] post)?
|
||||||
for filter in Filter.filters[key] when result = filter value, post.isReply
|
for filter in Filter.filters[key] when result = filter value, post.boardID, post.isReply
|
||||||
return true if result.hide
|
return true if result.hide
|
||||||
false
|
false
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user