aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel <>2021-06-19 19:04:43 -0700
committerFChannel <>2021-06-19 19:04:43 -0700
commitb4f7d00ad9d13f96323366ded2eb7702e37f6e52 (patch)
tree8a62817f7d1f70131533c2ab96f91270e0ad64db
parent6b265b0a8c2e45422f4a4601e041d44e5cef1c1b (diff)
admin can mark objects as senstive
-rw-r--r--database.go12
-rw-r--r--main.go57
-rw-r--r--static/bottom.html2
-rw-r--r--static/js/posts.js2
-rw-r--r--static/ncatalog.html20
-rw-r--r--static/posts.html2
6 files changed, 91 insertions, 4 deletions
diff --git a/database.go b/database.go
index 7fdbb5e..5e6e960 100644
--- a/database.go
+++ b/database.go
@@ -1476,3 +1476,15 @@ func GetActorPemFromDB(db *sql.DB, pemID string) PublicKeyPem {
return pem
}
+
+func MarkObjectSensitive(db *sql.DB, id string, sensitive bool) {
+ var query = `update activitystream set sensitive=$1 where id=$2`
+ _, err := db.Exec(query, sensitive, id)
+
+ CheckError(err, "error updating sensitive object in activitystream")
+
+ query = `update cacheactivitystream set sensitive=$1 where id=$2`
+ _, err = db.Exec(query, sensitive, id)
+
+ CheckError(err, "error updating sensitive object in cacheactivitystream")
+}
diff --git a/main.go b/main.go
index 6803053..8886266 100644
--- a/main.go
+++ b/main.go
@@ -801,6 +801,63 @@ func main() {
w.Write([]byte(""))
})
+ http.HandleFunc("/marksensitive", func(w http.ResponseWriter, r *http.Request){
+
+ id := r.URL.Query().Get("id")
+ board := r.URL.Query().Get("board")
+
+ _, auth := GetPasswordFromSession(r)
+
+ if id == "" || auth == "" {
+ w.WriteHeader(http.StatusBadRequest)
+ w.Write([]byte(""))
+ return
+ }
+
+ col := GetCollectionFromID(id)
+
+ if len(col.OrderedItems) < 1 {
+ if !HasAuth(db, auth, GetActorByNameFromDB(db, board).Id) {
+ w.WriteHeader(http.StatusBadRequest)
+ w.Write([]byte(""))
+ return
+ }
+
+ MarkObjectSensitive(db, id, true)
+
+ http.Redirect(w, r, "/" + board, http.StatusSeeOther)
+ return
+ }
+
+ actor := col.OrderedItems[0].Actor
+
+ var OP string
+ if (len(col.OrderedItems[0].InReplyTo) > 0 && col.OrderedItems[0].InReplyTo[0].Id != "") {
+ OP = col.OrderedItems[0].InReplyTo[0].Id
+ } else {
+ OP = id
+ }
+
+ if !HasAuth(db, auth, actor.Id) {
+ w.WriteHeader(http.StatusBadRequest)
+ w.Write([]byte(""))
+ return
+ }
+
+ MarkObjectSensitive(db, id, true)
+
+ if !IsIDLocal(db, OP) {
+ http.Redirect(w, r, "/" + board + "/" + remoteShort(OP), http.StatusSeeOther)
+ return
+ } else {
+ http.Redirect(w, r, OP, http.StatusSeeOther)
+ return
+ }
+
+ w.WriteHeader(http.StatusBadRequest)
+ w.Write([]byte(""))
+ })
+
http.HandleFunc("/remove", func(w http.ResponseWriter, r *http.Request){
id := r.URL.Query().Get("id")
manage := r.URL.Query().Get("manage")
diff --git a/static/bottom.html b/static/bottom.html
index 19c82c6..28750c8 100644
--- a/static/bottom.html
+++ b/static/bottom.html
@@ -1,5 +1,5 @@
{{ define "bottom" }}
-<div id="reply-box" class="popup-box" style="display: none; ">
+<div id="reply-box" class="popup-box" style="display: none;">
<div id="reply-header" style="display: inline-block; width: 370px; z-index: 0; cursor: move;"></div><div id="reply-close" style="display: inline-block; float: right;"><a href="javascript:closeReply()">[X]</a></div>
<form id="reply-post" action="/post" method="post" enctype="multipart/form-data">
<input id="reply-name" name="name" size="43" type="text" placeholder="Name" maxlength="100">
diff --git a/static/js/posts.js b/static/js/posts.js
index e46fed3..06aab77 100644
--- a/static/js/posts.js
+++ b/static/js/posts.js
@@ -224,7 +224,7 @@ function quote(actorName, opid, id)
}
- box.setAttribute("style", "display: block; position: absolute; width: 400px; height: 550px; z-index: 9; top: " + h + "px; left: " + w + "px; padding: 5px;");
+ box.setAttribute("style", "display: block; position: absolute; width: 400px; height: 600px; z-index: 9; top: " + h + "px; left: " + w + "px; padding: 5px;");
if (inReplyTo.value != opid)
diff --git a/static/ncatalog.html b/static/ncatalog.html
index 027a938..deb8e27 100644
--- a/static/ncatalog.html
+++ b/static/ncatalog.html
@@ -33,15 +33,31 @@
{{ if .Attachment }}
{{ if eq $board.ModCred $board.Domain $board.Actor.Id }}
<a href="/deleteattach?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Attachment]</a>
+ <a href="/marksensitive?id={{ .Id }}&board={{ $board.Actor.Name }}">[Mark Sensitive]</a>
{{ end }}
- <a id="{{ .Id }}-anchor" href="/{{ $board.Name }}/">
+
+ {{ if and .Sensitive $board.Actor.Restricted }}
+ <div id="hide-{{ .Id }}" style="display: none;">[Hide]</div>
+ <div id="sensitive-{{ .Id }}" style="display: none;"><div style="position: relative; text-align: center;"><img style="float: left; margin-right: 10px; margin-bottom: 10px; max-width: 180px; max-height: 180px;" src="/static/sensitive.png"><div style="width: 170px; position: absolute; margin-top: 75px; padding: 5px; background-color: black; color: white; cursor: default; ">NSFW Content</div></div></div>
+ {{ end }}
+ <a id="{{ .Id }}-anchor" href="/{{ $board.Name }}/">
<div id="media-{{ .Id }}" style="width:180px;"></div>
</a>
<script>
media = document.getElementById("media-{{ .Id }}")
+
+ if({{ .Sensitive }} && {{ $board.Actor.Restricted }}){
+ sensitive = document.getElementById("sensitive-{{ .Id }}")
+ hide = document.getElementById("hide-{{ .Id }}")
+ sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"}
+ hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"}
+ sensitive.style = "display: block"
+ media.style = "display: none;"
+ }
+
if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "image"){
var img = document.createElement("img");
- img.style = "max-width: 180px; max-height: 180px; cursor: move;"
+ img.style = "max-width: 180px; max-height: 180px;"
img.setAttribute("id", "img")
img.setAttribute("main", "1")
img.setAttribute("src", "{{ (index .Attachment 0).Href }}")
diff --git a/static/posts.html b/static/posts.html
index a6cac44..1b1d78b 100644
--- a/static/posts.html
+++ b/static/posts.html
@@ -96,8 +96,10 @@
<a href="/marksensitive?id={{ .Id }}&board={{ $board.Actor.Name }}">[Mark Sensitive]</a>
{{ end }}
<span style="display: block;">File <a id="{{ .Id }}-img" href="{{ (index .Attachment 0).Href}}">{{ (index .Attachment 0).Name }}</a> <span id="{{ .Id }}-size">({{ (index .Attachment 0).Size }})</span></span>
+ {{ if and .Sensitive $board.Actor.Restricted }}
<div id="hide-{{ .Id }}" style="display: none;">[Hide]</div>
<div id="sensitive-{{ .Id }}" style="display: none;"><div style="position: relative; text-align: center;"><img style="float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" src="/static/sensitive.png"><div style="width: 240px; position: absolute; margin-top: 110px; padding: 5px; background-color: black; color: white; cursor: default; ">NSFW Content</div></div></div>
+ {{ end }}
<div id="media-{{ .Id }}" sensitive="0"></div>
<script>
media = document.getElementById("media-{{ .Id }}")