Compare commits
No commits in common. "aa229317868007740a0a30f59cab6c9dc07f25db" and "09e5a8122701622ac107e75ba3ee611ea93fed38" have entirely different histories.
aa22931786
...
09e5a81227
|
|
@ -373,30 +373,11 @@ func (b *memoryBackend) Fetch3(channel, fetchURL string) (*http.Response, error)
|
||||||
return Fetch2(fetchURL)
|
return Fetch2(fetchURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *memoryBackend) channelAddItemWithMatcher(conn redis.Conn, channel string, item microsub.Item) error {
|
func (b *memoryBackend) channelAddItem(conn redis.Conn, channel string, item microsub.Item) error {
|
||||||
for channelKey, setting := range b.Settings {
|
zchannelKey := fmt.Sprintf("zchannel:%s:posts", channel)
|
||||||
if setting.IncludeRegex != "" {
|
|
||||||
included := false
|
|
||||||
includeRegex, err := regexp.Compile(setting.IncludeRegex)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("error in regexp: %q\n", includeRegex)
|
|
||||||
} else {
|
|
||||||
if item.Content != nil && includeRegex.MatchString(item.Content.Text) {
|
|
||||||
log.Printf("Included %#v\n", item)
|
|
||||||
included = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if includeRegex.MatchString(item.Name) {
|
var excludeRegex regexp.Regexp
|
||||||
log.Printf("Included %#v\n", item)
|
testExcludeRegex := false
|
||||||
included = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if included {
|
|
||||||
b.channelAddItem(conn, channelKey, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if setting, e := b.Settings[channel]; e {
|
if setting, e := b.Settings[channel]; e {
|
||||||
if setting.ExcludeRegex != "" {
|
if setting.ExcludeRegex != "" {
|
||||||
|
|
@ -404,6 +385,12 @@ func (b *memoryBackend) channelAddItemWithMatcher(conn redis.Conn, channel strin
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error in regexp: %q\n", excludeRegex)
|
log.Printf("error in regexp: %q\n", excludeRegex)
|
||||||
} else {
|
} else {
|
||||||
|
testExcludeRegex = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if testExcludeRegex {
|
||||||
if item.Content != nil && excludeRegex.MatchString(item.Content.Text) {
|
if item.Content != nil && excludeRegex.MatchString(item.Content.Text) {
|
||||||
log.Printf("Excluded %#v\n", item)
|
log.Printf("Excluded %#v\n", item)
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -414,14 +401,6 @@ func (b *memoryBackend) channelAddItemWithMatcher(conn redis.Conn, channel strin
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return b.channelAddItem(conn, channel, item)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *memoryBackend) channelAddItem(conn redis.Conn, channel string, item microsub.Item) error {
|
|
||||||
zchannelKey := fmt.Sprintf("zchannel:%s:posts", channel)
|
|
||||||
|
|
||||||
if item.Published == "" {
|
if item.Published == "" {
|
||||||
item.Published = time.Now().Format(time.RFC3339)
|
item.Published = time.Now().Format(time.RFC3339)
|
||||||
|
|
|
||||||
|
|
@ -569,18 +569,6 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
h.Backend.Settings[uid] = setting
|
h.Backend.Settings[uid] = setting
|
||||||
}
|
}
|
||||||
|
|
||||||
includeRegex := r.FormValue("include_regex")
|
|
||||||
|
|
||||||
if setting, e := h.Backend.Settings[uid]; e {
|
|
||||||
setting.IncludeRegex = includeRegex
|
|
||||||
h.Backend.Settings[uid] = setting
|
|
||||||
} else {
|
|
||||||
setting = channelSetting{
|
|
||||||
IncludeRegex: includeRegex,
|
|
||||||
}
|
|
||||||
h.Backend.Settings[uid] = setting
|
|
||||||
}
|
|
||||||
|
|
||||||
h.Backend.Debug()
|
h.Backend.Debug()
|
||||||
|
|
||||||
http.Redirect(w, r, "/settings", 302)
|
http.Redirect(w, r, "/settings", 302)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ type memoryBackend struct {
|
||||||
|
|
||||||
type channelSetting struct {
|
type channelSetting struct {
|
||||||
ExcludeRegex string
|
ExcludeRegex string
|
||||||
IncludeRegex string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Debug interface {
|
type Debug interface {
|
||||||
|
|
|
||||||
|
|
@ -57,16 +57,10 @@
|
||||||
<input type="hidden" name="uid" value="{{ .CurrentChannel.UID }}" />
|
<input type="hidden" name="uid" value="{{ .CurrentChannel.UID }}" />
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<label class="label">Blocking Regex</label>
|
<label class="label">Exclude regex</label>
|
||||||
<input type="text" class="input" name="exclude_regex" value="{{ .CurrentSetting.ExcludeRegex }}" placeholder="enter regex to block" />
|
<input type="text" class="input" name="exclude_regex" value="{{ .CurrentSetting.ExcludeRegex }}" placeholder="enter regex to block" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
|
||||||
<div class="control">
|
|
||||||
<label class="label">Tracking Regex</label>
|
|
||||||
<input type="text" class="input" name="include_regex" value="{{ .CurrentSetting.IncludeRegex }}" placeholder="enter regex to track items" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<button type="submit" class="button is-primary">Save</button>
|
<button type="submit" class="button is-primary">Save</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user