+{{ $board.Restricted }} + {{ template "posts" . }}
-- cgit v1.2.3 From df34b557bb7894b82bd08dc9430d5fb76b35c3ff Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Mon, 31 May 2021 03:32:52 -0700 Subject: missed the count --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index b37c41d..29b93fd 100644 --- a/main.go +++ b/main.go @@ -2208,8 +2208,8 @@ func GetActorInstance(path string) (string, string) { if(atFormat) { match := re.FindStringSubmatch(path) - if(len(match) > 1) { - return match[1], match[2] + if(len(match) > 2) { + return match[2], match[3] } } -- cgit v1.2.3 From b7ce42c8a9a6f458cc1537f6aeefe0b5f7ab150c Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Mon, 31 May 2021 03:56:00 -0700 Subject: you should not be able to see verify page without modkey --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 29b93fd..1942135 100644 --- a/main.go +++ b/main.go @@ -703,8 +703,8 @@ func main() { http.Redirect(w, r, "/", http.StatusSeeOther) } } else { - t := template.Must(template.ParseFiles("./static/verify.html")) - t.Execute(w, "") + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte("404 no path")) } }) -- cgit v1.2.3 From 60b6bdf1c021fcffff397c7b1439a1407ed90f0a Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Tue, 1 Jun 2021 00:45:05 -0700 Subject: changed actor to type Group and other clean up --- README.md | 3 ++- main.go | 11 ++--------- static/js/posts.js | 2 +- static/npost.html | 2 -- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8da0dd6..44d3c3a 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,8 @@ Any contributions or suggestions are appreciated. Best way to give immediate fee `emailpass:password` -#### local testing +### local testing + When testing on a local env when setting the `instance` value in the config file you have to append the port number to the local address eg. `instance:localhost:3000` with `instanceport` also being set to the same port. If you want to test federation between servers locally you have to use your local ip as the `instance` eg. `instance:192.168.0.2:3000` and `instance:192:168:0:3:3000` adding the port to localhost will not route correctly. diff --git a/main.go b/main.go index 1942135..1be79e1 100644 --- a/main.go +++ b/main.go @@ -740,12 +740,8 @@ func main() { } if !IsIDLocal(db, id) { - if(!isOP) { CloseLocalReportDB(db, id, board) CreateLocalDeleteDB(db, id, "post") - } else { - - } if(manage == "t") { http.Redirect(w, r, "/" + *Key + "/" + board, http.StatusSeeOther) } else if(OP != ""){ @@ -757,9 +753,6 @@ func main() { return } - - - if !isOP { DeleteReportActivity(db, id) DeleteObjectRequest(db, id) @@ -1145,7 +1138,7 @@ func CreateNewActor(board string, prefName string, summary string, authReq []str actor.Name = board } - actor.Type = "Service" + actor.Type = "Group" actor.Id = fmt.Sprintf("%s", path) actor.Following = fmt.Sprintf("%s/following", actor.Id) actor.Followers = fmt.Sprintf("%s/followers", actor.Id) @@ -2213,7 +2206,7 @@ func GetActorInstance(path string) (string, string) { } } - re = regexp.MustCompile(`(http:\\|https:\\)?(www)?([\w\d-_.:]+)\/([\w\d-_.]+)`) + re = regexp.MustCompile(`(https?:\\)?(www)?([\w\d-_.:]+)\/([\w\d-_.]+)`) httpFormat := re.MatchString(path) if(httpFormat) { diff --git a/static/js/posts.js b/static/js/posts.js index 8dd05eb..b2bfd7a 100644 --- a/static/js/posts.js +++ b/static/js/posts.js @@ -212,7 +212,7 @@ function report(actorName, id) var inReplyTo = document.getElementById("report-inReplyTo-box"); var w = window.innerWidth / 2 - 200; - var h = document.getElementById(id + "-content").offsetTop - 448; + var h = document.getElementById(id + "-content").offsetTop - 348; box.setAttribute("style", "display: block; position: absolute; width: 400px; height: 480px; z-index: 9; top: " + h + "px; left: " + w + "px; padding: 5px;"); diff --git a/static/npost.html b/static/npost.html index e3c4cec..b91b795 100644 --- a/static/npost.html +++ b/static/npost.html @@ -14,8 +14,6 @@
-{{ $board.Restricted }} - {{ template "posts" . }}
-- cgit v1.2.3 From 9d937e6f895ca7213ae759efca9b292a1d014ab3 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Thu, 3 Jun 2021 01:19:37 -0700 Subject: cleaning up removing posts --- Database.go | 112 +++++++++++++++++++++++++++++++++++++++++++++++++-- main.go | 77 ++++++++++++++--------------------- static/js/posts.js | 15 ++++--- static/ncatalog.html | 11 +++-- static/posts.html | 2 +- 5 files changed, 155 insertions(+), 62 deletions(-) diff --git a/Database.go b/Database.go index 3e890dd..9f8516d 100644 --- a/Database.go +++ b/Database.go @@ -818,7 +818,7 @@ func GetObjectAttachment(db *sql.DB, id string) []ObjectBase { var attachments []ObjectBase - query := `select x.id, x.type, x.name, x.href, x.mediatype, x.size, x.published from (select id, type, name, href, mediatype, size, published from activitystream where id=$1 union select id, type, name, href, mediatype, size, published from cacheactivitystream where id=$1) as x` + query := `select x.id, x.type, x.name, x.href, x.mediatype, x.size, x.published from (select id, type, name, href, mediatype, size, published from activitystream where id=$1 union select id, type, name, href, mediatype, size, published from cacheactivitystream where id=$1) as x where type='Attachment'` rows, err := db.Query(query, id) @@ -844,7 +844,7 @@ func GetObjectPreview(db *sql.DB, id string) *NestedObjectBase { var preview NestedObjectBase - query := `select x.id, x.type, x.name, x.href, x.mediatype, x.size, x.published from (select id, type, name, href, mediatype, size, published from activitystream where id=$1 union select id, type, name, href, mediatype, size, published from cacheactivitystream where id=$1) as x` + query := `select x.id, x.type, x.name, x.href, x.mediatype, x.size, x.published from (select id, type, name, href, mediatype, size, published from activitystream where id=$1 union select id, type, name, href, mediatype, size, published from cacheactivitystream where id=$1) as x where type='Preview'` rows, err := db.Query(query, id) @@ -1044,8 +1044,114 @@ func DeleteObjectRepliesFromDB(db *sql.DB, id string) { } -func DeleteObject(db *sql.DB, id string) { +func SetAttachmentFromDB(db *sql.DB, id string, _type string) { + datetime := time.Now().Format(time.RFC3339) + + var query = `update activitystream set type=$1, deleted=$2 where id in (select attachment from activitystream where id=$3)` + + _, err := db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set attachment") + + query = `update cacheactivitystream set type=$1, deleted=$2 where id in (select attachment from cacheactivitystream where id=$3)` + + _, err = db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set cache attachment") +} + +func SetAttachmentRepliesFromDB(db *sql.DB, id string, _type string) { + datetime := time.Now().Format(time.RFC3339) + + var query = `update activitystream set type=$1, deleted=$2 where id in (select attachment from activitystream where id in (select id from replies where inreplyto=$3))` + + _, err := db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set attachment") + + query = `update cacheactivitystream set type=$1, deleted=$2 where id in (select attachment from cacheactivitystream where id in (select id from replies where inreplyto=$3))` + + _, err = db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set cache attachment") +} + +func SetPreviewFromDB(db *sql.DB, id string, _type string) { + datetime := time.Now().Format(time.RFC3339) + + var query = `update activitystream set type=$1, deleted=$2 where id in (select preview from activitystream where id=$3)` + + _, err := db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set preview") + + query = `update cacheactivitystream set type=$1, deleted=$2 where id in (select preview from cacheactivitystream where id=$3)` + + _, err = db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set cache preview") +} + +func SetPreviewRepliesFromDB(db *sql.DB, id string, _type string) { + datetime := time.Now().Format(time.RFC3339) + + var query = `update activitystream set type=$1, deleted=$2 where id in (select preview from activitystream where id in (select id from replies where inreplyto=$3))` + + _, err := db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set preview") + + query = `update cacheactivitystream set type=$1, deleted=$2 where id in (select preview from cacheactivitystream where id in (select id from replies where inreplyto=$3))` + + _, err = db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set cache preview") +} + +func SetObjectFromDB(db *sql.DB, id string, _type string) { + datetime := time.Now().Format(time.RFC3339) + var query = `update activitystream set type=$1, deleted=$2 where id=$3` + + _, err := db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set object") + + query = `update cacheactivitystream set type=$1, deleted=$2 where id=$3` + + _, err = db.Exec(query, _type, datetime, id) + + CheckError(err, "error with set cache object") +} + +func SetObjectRepliesFromDB(db *sql.DB, id string, _type string) { + datetime := time.Now().Format(time.RFC3339) + + var query = `update activitystream set type=$1, deleted=$2 where id in (select id from replies where inreplyto=$3)` + _, err := db.Exec(query, _type, datetime, id) + CheckError(err, "error with set object replies") + + query = `update cacheactivitystream set type=$1, deleted=$2 where id in (select id from replies where inreplyto=$3)` + _, err = db.Exec(query, _type, datetime, id) + CheckError(err, "error with set cache object replies") +} + +func SetObject(db *sql.DB, id string, _type string) { + SetAttachmentFromDB(db, id, _type); + SetPreviewFromDB(db, id, _type); + SetObjectFromDB(db, id, _type); +} + +func SetObjectAndReplies(db *sql.DB, id string, _type string) { + SetAttachmentFromDB(db, id, _type); + SetPreviewFromDB(db, id, _type); + SetObjectRepliesFromDB(db, id, _type); + SetAttachmentRepliesFromDB(db, id, _type); + SetPreviewRepliesFromDB(db, id, _type); + SetObjectFromDB(db, id, _type); +} + +func DeleteObject(db *sql.DB, id string) { if(!IsIDLocal(db, id)) { return } diff --git a/main.go b/main.go index 1be79e1..5e4c69e 100644 --- a/main.go +++ b/main.go @@ -739,40 +739,29 @@ func main() { OP = col.OrderedItems[0].InReplyTo[0].Id } - if !IsIDLocal(db, id) { - CloseLocalReportDB(db, id, board) - CreateLocalDeleteDB(db, id, "post") - if(manage == "t") { - http.Redirect(w, r, "/" + *Key + "/" + board, http.StatusSeeOther) - } else if(OP != ""){ - http.Redirect(w, r, "/" + board + "/" + remoteShort(OP), http.StatusSeeOther) - } else { - http.Redirect(w, r, "/" + board, http.StatusSeeOther) - } - - return + if !isOP { + SetObject(db, id, "Removed") + } else { + SetObjectAndReplies(db, id, "Removed") } - if !isOP { - DeleteReportActivity(db, id) - DeleteObjectRequest(db, id) - DeleteObject(db, obj.Id) - if(manage == "t"){ - http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) - }else{ + if IsIDLocal(db, id){ + DeleteObjectRequest(db, id) + } + + if(manage == "t"){ + http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) + return + } else if !isOP { + if (!IsIDLocal(db, id)){ + http.Redirect(w, r, "/" + board + "/" + remoteShort(OP), http.StatusSeeOther) + return + } else { http.Redirect(w, r, OP, http.StatusSeeOther) + return } - return - } else { - DeleteReportActivity(db, id) - DeleteObjectAndRepliesRequest(db, id) - DeleteObjectAndReplies(db, obj.Id) - if(manage == "t"){ - http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) - }else{ - http.Redirect(w, r, "/" + board, http.StatusSeeOther) - } + http.Redirect(w, r, "/" + board, http.StatusSeeOther) return } @@ -809,26 +798,22 @@ func main() { return } - - - if !IsIDLocal(db, id) { - CreateLocalDeleteDB(db, id, "attachment") - if(manage == "t") { - http.Redirect(w, r, "/" + *Key + "/" + board, http.StatusSeeOther) - } else { - http.Redirect(w, r, "/" + board + "/" + remoteShort(OP), http.StatusSeeOther) - } - return - } - - DeleteAttachmentFromFile(db, id) - DeletePreviewFromFile(db, id) - - if(manage == "t") { + SetAttachmentFromDB(db, id, "Removed") + SetPreviewFromDB(db, id, "Removed") + + if (manage == "t") { http.Redirect(w, r, "/" + *Key + "/" + board, http.StatusSeeOther) - } else { + return + } else 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("/report", func(w http.ResponseWriter, r *http.Request){ diff --git a/static/js/posts.js b/static/js/posts.js index b2bfd7a..077b654 100644 --- a/static/js/posts.js +++ b/static/js/posts.js @@ -26,6 +26,8 @@ function shortURL(actorName, url) { re = /.+\//g; temp = re.exec(url) + + var output if(stripTransferProtocol(temp[0]) == stripTransferProtocol(actorName) + "/") { @@ -39,11 +41,8 @@ function shortURL(actorName, url) re = /\w+$/g; - u = re.exec(short); - - return u; + output = re.exec(short); }else{ - var short = url.replace("https://", ""); short = short.replace("http://", ""); short = short.replace("www.", ""); @@ -64,10 +63,10 @@ function shortURL(actorName, url) v = re.exec(str) - v = "f" + v[0] + "-" + u - - return v; + output = "f" + v[0] + "-" + u } + + return output } function shortImg(url) @@ -113,7 +112,7 @@ function getBoardId(url) function convertContent(actorName, content, opid) { - var re = /(>>)(https:\/\/|http:\/\/)?(www\.)?.+\/\w+/gm; + var re = /(>>)(https?:\/\/)?(www\.)?.+\/\w+/gm; var match = content.match(re); var newContent = content; if(match) diff --git a/static/ncatalog.html b/static/ncatalog.html index 81d31f3..a399d13 100644 --- a/static/ncatalog.html +++ b/static/ncatalog.html @@ -24,6 +24,7 @@ {{ end }} + {{ end }} +