Compare commits
No commits in common. "d4de6faa897088e43e95daf98047e068639d1d43" and "f8b9003c36d8d674328740e27286f63da715e77c" have entirely different histories.
d4de6faa89
...
f8b9003c36
|
|
@ -54,10 +54,8 @@ type indexPage struct {
|
||||||
type settingsPage struct {
|
type settingsPage struct {
|
||||||
Session session
|
Session session
|
||||||
|
|
||||||
CurrentChannel microsub.Channel
|
CurrentChannel microsub.Channel
|
||||||
CurrentSetting channelSetting
|
CurrentSetting channelSetting
|
||||||
ExcludedTypes map[string]bool
|
|
||||||
ExcludedTypeNames map[string]string
|
|
||||||
|
|
||||||
Channels []microsub.Channel
|
Channels []microsub.Channel
|
||||||
Feeds []microsub.Feed
|
Feeds []microsub.Feed
|
||||||
|
|
@ -350,7 +348,7 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
} else {
|
} else {
|
||||||
page.CurrentSetting = channelSetting{}
|
page.CurrentSetting = channelSetting{}
|
||||||
}
|
}
|
||||||
// FIXME: similar code is found in timeline.go
|
// TODO: similar code is found in timeline.go
|
||||||
if page.CurrentSetting.ChannelType == "" {
|
if page.CurrentSetting.ChannelType == "" {
|
||||||
if v.UID == "notifications" {
|
if v.UID == "notifications" {
|
||||||
page.CurrentSetting.ChannelType = "stream"
|
page.CurrentSetting.ChannelType = "stream"
|
||||||
|
|
@ -358,21 +356,6 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
page.CurrentSetting.ChannelType = "sorted-set"
|
page.CurrentSetting.ChannelType = "sorted-set"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
page.ExcludedTypeNames = map[string]string{
|
|
||||||
"repost": "Reposts",
|
|
||||||
"like": "Likes",
|
|
||||||
"bookmark": "Bookmarks",
|
|
||||||
"reply": "Replies",
|
|
||||||
"checkin": "Checkins",
|
|
||||||
}
|
|
||||||
page.ExcludedTypes = make(map[string]bool)
|
|
||||||
types := []string{"repost", "like", "bookmark", "reply", "checkin"}
|
|
||||||
for _, v := range types {
|
|
||||||
page.ExcludedTypes[v] = false
|
|
||||||
}
|
|
||||||
for _, v := range page.CurrentSetting.ExcludeType {
|
|
||||||
page.ExcludedTypes[v] = true
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -646,25 +629,23 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
defer h.Backend.save()
|
defer h.Backend.save()
|
||||||
uid := r.FormValue("uid")
|
uid := r.FormValue("uid")
|
||||||
|
|
||||||
if h.Backend.Settings == nil {
|
|
||||||
h.Backend.Settings = make(map[string]channelSetting)
|
|
||||||
}
|
|
||||||
|
|
||||||
excludeRegex := r.FormValue("exclude_regex")
|
excludeRegex := r.FormValue("exclude_regex")
|
||||||
includeRegex := r.FormValue("include_regex")
|
includeRegex := r.FormValue("include_regex")
|
||||||
channelType := r.FormValue("type")
|
channelType := r.FormValue("type")
|
||||||
|
|
||||||
setting, e := h.Backend.Settings[uid]
|
if setting, e := h.Backend.Settings[uid]; e {
|
||||||
if !e {
|
setting.ExcludeRegex = excludeRegex
|
||||||
setting = channelSetting{}
|
setting.IncludeRegex = includeRegex
|
||||||
|
setting.ChannelType = channelType
|
||||||
|
h.Backend.Settings[uid] = setting
|
||||||
|
} else {
|
||||||
|
setting = channelSetting{
|
||||||
|
ExcludeRegex: excludeRegex,
|
||||||
|
IncludeRegex: includeRegex,
|
||||||
|
ChannelType: channelType,
|
||||||
|
}
|
||||||
|
h.Backend.Settings[uid] = setting
|
||||||
}
|
}
|
||||||
setting.ExcludeRegex = excludeRegex
|
|
||||||
setting.IncludeRegex = includeRegex
|
|
||||||
setting.ChannelType = channelType
|
|
||||||
if values, e := r.Form["exclude_type"]; e {
|
|
||||||
setting.ExcludeType = values
|
|
||||||
}
|
|
||||||
h.Backend.Settings[uid] = setting
|
|
||||||
|
|
||||||
h.Backend.Debug()
|
h.Backend.Debug()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ type memoryBackend struct {
|
||||||
type channelSetting struct {
|
type channelSetting struct {
|
||||||
ExcludeRegex string
|
ExcludeRegex string
|
||||||
IncludeRegex string
|
IncludeRegex string
|
||||||
ExcludeType []string
|
|
||||||
ChannelType string
|
ChannelType string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -565,37 +564,6 @@ func (b *memoryBackend) channelAddItemWithMatcher(channel string, item microsub.
|
||||||
b.lock.RUnlock()
|
b.lock.RUnlock()
|
||||||
|
|
||||||
for channelKey, setting := range settings {
|
for channelKey, setting := range settings {
|
||||||
if len(setting.ExcludeType) > 0 {
|
|
||||||
for _, v := range setting.ExcludeType {
|
|
||||||
switch v {
|
|
||||||
case "repost":
|
|
||||||
if len(item.RepostOf) > 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "like":
|
|
||||||
if len(item.LikeOf) > 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "bookmark":
|
|
||||||
if len(item.BookmarkOf) > 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "reply":
|
|
||||||
if len(item.InReplyTo) > 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "checkin":
|
|
||||||
if item.Checkin != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if setting.IncludeRegex != "" {
|
if setting.IncludeRegex != "" {
|
||||||
re, err := regexp.Compile(setting.IncludeRegex)
|
re, err := regexp.Compile(setting.IncludeRegex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -79,18 +79,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
|
||||||
<label for="exclude_type" class="label">Exclude Types</label>
|
|
||||||
<div class="control">
|
|
||||||
<div class="select is-multiple">
|
|
||||||
<select name="exclude_type" id="exclude_type" multiple>
|
|
||||||
{{ range $key, $excluded := .ExcludedTypes }}
|
|
||||||
<option value="{{ $key }}" {{ if $excluded }}selected="selected"{{ end }}>{{ index $.ExcludedTypeNames $key }}</option>
|
|
||||||
{{ end }}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button type="submit" class="button is-primary">Save</button>
|
<button type="submit" class="button is-primary">Save</button>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user