zilence (collapse) posts matching regex
This commit is contained in:
parent
2a2019743f
commit
eab34a6104
|
@ -2,6 +2,8 @@ changelog
|
||||||
|
|
||||||
-- next
|
-- next
|
||||||
|
|
||||||
|
+ Collapse posts based on custom regex match.
|
||||||
|
|
||||||
+ Tonks are now honk backs.
|
+ Tonks are now honk backs.
|
||||||
|
|
||||||
+ Show both avatars for bonks. Other minor refinements to UI.
|
+ Show both avatars for bonks. Other minor refinements to UI.
|
||||||
|
|
|
@ -59,6 +59,8 @@ works poorly in a federated environment. It's more like please disregard.
|
||||||
The zonkzone supports muting unwanted contacts. One may mute an actor
|
The zonkzone supports muting unwanted contacts. One may mute an actor
|
||||||
(zonker), a domain (zomain), thread (zonvoy), or word (zord).
|
(zonker), a domain (zomain), thread (zonvoy), or word (zord).
|
||||||
|
|
||||||
|
Posts can be collapsed, but not hidden, by specifying a zilence regex.
|
||||||
|
|
||||||
-- privacy
|
-- privacy
|
||||||
|
|
||||||
Posted honks are public. The federated environment lacks robust privacy
|
Posted honks are public. The federated environment lacks robust privacy
|
||||||
|
|
39
fun.go
39
fun.go
|
@ -33,6 +33,7 @@ import (
|
||||||
|
|
||||||
func reverbolate(userid int64, honks []*Honk) {
|
func reverbolate(userid int64, honks []*Honk) {
|
||||||
filt := htfilter.New()
|
filt := htfilter.New()
|
||||||
|
zilences := getzilences(userid)
|
||||||
for _, h := range honks {
|
for _, h := range honks {
|
||||||
h.What += "ed"
|
h.What += "ed"
|
||||||
if h.What == "tonked" {
|
if h.What == "tonked" {
|
||||||
|
@ -62,13 +63,11 @@ func reverbolate(userid int64, honks []*Honk) {
|
||||||
zap := make(map[*Donk]bool)
|
zap := make(map[*Donk]bool)
|
||||||
h.Noise = unpucker(h.Noise)
|
h.Noise = unpucker(h.Noise)
|
||||||
h.Open = "open"
|
h.Open = "open"
|
||||||
if userid != -1 {
|
if badword := unsee(zilences, h.Precis, h.Noise); badword != "" {
|
||||||
if badword := unsee(userid, h.Precis, h.Noise); badword != "" {
|
if h.Precis == "" {
|
||||||
if h.Precis == "" {
|
h.Precis = badword
|
||||||
h.Precis = badword
|
|
||||||
}
|
|
||||||
h.Open = ""
|
|
||||||
}
|
}
|
||||||
|
h.Open = ""
|
||||||
}
|
}
|
||||||
h.HTML, _ = filt.String(h.Noise)
|
h.HTML, _ = filt.String(h.Noise)
|
||||||
emuxifier := func(e string) string {
|
emuxifier := func(e string) string {
|
||||||
|
@ -94,9 +93,15 @@ func reverbolate(userid int64, honks []*Honk) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func unsee(userid int64, precis string, noise string) string {
|
func unsee(zilences []*regexp.Regexp, precis string, noise string) string {
|
||||||
if precis != "" {
|
for _, z := range zilences {
|
||||||
return "more..."
|
if z.MatchString(precis) || z.MatchString(noise) {
|
||||||
|
if precis == "" {
|
||||||
|
w := z.String()
|
||||||
|
return w[6 : len(w)-3]
|
||||||
|
}
|
||||||
|
return precis
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -495,6 +500,7 @@ func makeitworksomehowwithoutregardforkeycontinuity(keyname string, r *http.Requ
|
||||||
|
|
||||||
var thumbbiters map[int64]map[string]bool
|
var thumbbiters map[int64]map[string]bool
|
||||||
var zordses map[int64][]*regexp.Regexp
|
var zordses map[int64][]*regexp.Regexp
|
||||||
|
var zilences map[int64][]*regexp.Regexp
|
||||||
var thumblock sync.Mutex
|
var thumblock sync.Mutex
|
||||||
|
|
||||||
func bitethethumbs() {
|
func bitethethumbs() {
|
||||||
|
@ -509,6 +515,7 @@ func bitethethumbs() {
|
||||||
defer thumblock.Unlock()
|
defer thumblock.Unlock()
|
||||||
thumbbiters = make(map[int64]map[string]bool)
|
thumbbiters = make(map[int64]map[string]bool)
|
||||||
zordses = make(map[int64][]*regexp.Regexp)
|
zordses = make(map[int64][]*regexp.Regexp)
|
||||||
|
zilences = make(map[int64][]*regexp.Regexp)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var userid int64
|
var userid int64
|
||||||
var name, wherefore string
|
var name, wherefore string
|
||||||
|
@ -517,13 +524,17 @@ func bitethethumbs() {
|
||||||
log.Printf("error scanning zonker: %s", err)
|
log.Printf("error scanning zonker: %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if wherefore == "zord" {
|
if wherefore == "zord" || wherefore == "zilence" {
|
||||||
zord := "\\b(?i:" + name + ")\\b"
|
zord := "\\b(?i:" + name + ")\\b"
|
||||||
re, err := regexp.Compile(zord)
|
re, err := regexp.Compile(zord)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error compiling zord: %s", err)
|
log.Printf("error compiling zord: %s", err)
|
||||||
} else {
|
} else {
|
||||||
zordses[userid] = append(zordses[userid], re)
|
if wherefore == "zord" {
|
||||||
|
zordses[userid] = append(zordses[userid], re)
|
||||||
|
} else {
|
||||||
|
zilences[userid] = append(zilences[userid], re)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -542,6 +553,12 @@ func getzords(userid int64) []*regexp.Regexp {
|
||||||
return zordses[userid]
|
return zordses[userid]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getzilences(userid int64) []*regexp.Regexp {
|
||||||
|
thumblock.Lock()
|
||||||
|
defer thumblock.Unlock()
|
||||||
|
return zilences[userid]
|
||||||
|
}
|
||||||
|
|
||||||
func thoudostbitethythumb(userid int64, who []string, objid string) bool {
|
func thoudostbitethythumb(userid int64, who []string, objid string) bool {
|
||||||
thumblock.Lock()
|
thumblock.Lock()
|
||||||
biters := thumbbiters[userid]
|
biters := thumbbiters[userid]
|
||||||
|
|
5
honk.go
5
honk.go
|
@ -1270,13 +1270,14 @@ func zonkzonk(w http.ResponseWriter, r *http.Request) {
|
||||||
case "zomain":
|
case "zomain":
|
||||||
case "zonvoy":
|
case "zonvoy":
|
||||||
case "zord":
|
case "zord":
|
||||||
|
case "zilence":
|
||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
db := opendatabase()
|
db := opendatabase()
|
||||||
db.Exec("insert into zonkers (userid, name, wherefore) values (?, ?, ?)",
|
db.Exec("insert into zonkers (userid, name, wherefore) values (?, ?, ?)",
|
||||||
userinfo.UserID, name, wherefore)
|
userinfo.UserID, name, wherefore)
|
||||||
if wherefore == "zonker" || wherefore == "zomain" || wherefore == "zord" {
|
if wherefore == "zonker" || wherefore == "zomain" || wherefore == "zord" || wherefore == "zilence" {
|
||||||
bitethethumbs()
|
bitethethumbs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1573,7 +1574,7 @@ func prepareStatements(db *sql.DB) {
|
||||||
stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers")
|
stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers")
|
||||||
stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg from doovers where dooverid = ?")
|
stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg from doovers where dooverid = ?")
|
||||||
stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?")
|
stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?")
|
||||||
stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers where (wherefore = 'zonker' or wherefore = 'zomain' or wherefore = 'zord')")
|
stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers where (wherefore = 'zonker' or wherefore = 'zomain' or wherefore = 'zord' or wherefore = 'zilence')")
|
||||||
stmtFindZonk = preparetodie(db, "select zonkerid from zonkers where userid = ? and name = ? and wherefore = 'zonk'")
|
stmtFindZonk = preparetodie(db, "select zonkerid from zonkers where userid = ? and name = ? and wherefore = 'zonk'")
|
||||||
stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ? and wherefore <> 'zonk'")
|
stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ? and wherefore <> 'zonk'")
|
||||||
stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)")
|
stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)")
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
<p>
|
<p>
|
||||||
<input type="radio" id="iszord" name="wherefore" value="zord">
|
<input type="radio" id="iszord" name="wherefore" value="zord">
|
||||||
<label for="iszord">Zord</label>
|
<label for="iszord">Zord</label>
|
||||||
|
<p>
|
||||||
|
<input type="radio" id="iszilence" name="wherefore" value="zilence">
|
||||||
|
<label for="iszilence">Zilence</label>
|
||||||
<p><br><input tabindex=1 type="submit" name="zonk" value="zonk!">
|
<p><br><input tabindex=1 type="submit" name="zonk" value="zonk!">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue