From d46dc93dce176e8e2c054a1454c097123a08b4af Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Wed, 12 May 2021 23:06:40 -0700 Subject: admin tripcode --- client.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'client.go') diff --git a/client.go b/client.go index d31ba07..1ef6250 100644 --- a/client.go +++ b/client.go @@ -77,7 +77,7 @@ func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { t := template.Must(template.ParseFiles("./static/main.html", "./static/index.html")) actor := GetActorFromDB(db, Domain) - + var data PageData data.Title = "Welcome to " + actor.PreferredUsername data.Message = fmt.Sprintf("%s is a federated image board based on activitypub. The current version of the code running the server is still a work in progress, expect a bumpy ride for the time being. Get the server code here https://github.com/FChannel0", Domain) @@ -149,7 +149,7 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C t := template.Must(template.ParseFiles("./static/main.html", "./static/ncatalog.html", "./static/top.html")) actor := collection.Actor - + var returnData PageData returnData.Board.Name = actor.Name returnData.Board.PrefName = actor.PreferredUsername @@ -191,7 +191,6 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ inReplyTo := actor.Id + "/" + postId var returnData PageData - returnData.Board.Name = actor.Name returnData.Board.PrefName = actor.PreferredUsername returnData.Board.To = actor.Outbox -- cgit v1.2.3 From 13fddffc60b9cd6350e888ea4e92745a58e1f256 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sun, 30 May 2021 23:50:40 -0700 Subject: added finger methods for getting the actor --- client.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'client.go') diff --git a/client.go b/client.go index 1ef6250..6ca3ee0 100644 --- a/client.go +++ b/client.go @@ -215,15 +215,17 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ name := GetActorFollowNameFromPath(path) followActors := GetActorsFollowFromName(actor, name) followCollection := GetActorsFollowPostFromId(db, followActors, postId) - - returnData.Board.Post.Actor = followCollection.Actor - + DeleteRemovedPosts(db, &followCollection) DeleteTombstoneReplies(&followCollection) - if len(followCollection.OrderedItems) > 0 { + if len(followCollection.OrderedItems) > 0 { returnData.Board.InReplyTo = followCollection.OrderedItems[0].Id returnData.Posts = append(returnData.Posts, followCollection.OrderedItems[0]) + + var actor Actor + actor = FingerActor(returnData.Board.InReplyTo) + returnData.Board.Post.Actor = &actor } } else { collection := GetObjectByIDFromDB(db, inReplyTo) -- cgit v1.2.3 From 3efbc7fad19d5927e479258e94c62ae26e334f66 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sun, 6 Jun 2021 00:24:15 -0700 Subject: removed redundent functions --- client.go | 102 -------------------------------------------------------------- 1 file changed, 102 deletions(-) (limited to 'client.go') diff --git a/client.go b/client.go index 6ca3ee0..e9ecd80 100644 --- a/client.go +++ b/client.go @@ -124,10 +124,6 @@ func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Co returnData.Key = *Key - DeleteRemovedPosts(db, &collection) - DeleteTombstoneReplies(&collection) - DeleteTombstonePosts(&collection) - returnData.Boards = Boards returnData.Posts = collection.OrderedItems @@ -171,9 +167,6 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C returnData.Boards = Boards - DeleteRemovedPosts(db, &collection) - DeleteTombstonePosts(&collection) - returnData.Posts = collection.OrderedItems t.ExecuteTemplate(w, "layout", returnData) @@ -216,9 +209,6 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ followActors := GetActorsFollowFromName(actor, name) followCollection := GetActorsFollowPostFromId(db, followActors, postId) - DeleteRemovedPosts(db, &followCollection) - DeleteTombstoneReplies(&followCollection) - if len(followCollection.OrderedItems) > 0 { returnData.Board.InReplyTo = followCollection.OrderedItems[0].Id returnData.Posts = append(returnData.Posts, followCollection.OrderedItems[0]) @@ -233,9 +223,6 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ returnData.Board.Post.Actor = collection.Actor returnData.Board.InReplyTo = inReplyTo - DeleteRemovedPosts(db, &collection) - DeleteTombstoneReplies(&collection) - if len(collection.OrderedItems) > 0 { returnData.Posts = append(returnData.Posts, collection.OrderedItems[0]) } @@ -346,95 +333,6 @@ func GetCaptchaCode(captcha string) string { return code } -func DeleteTombstoneReplies(collection *Collection) { - - for i, e := range collection.OrderedItems { - var replies CollectionBase - for _, k := range e.Replies.OrderedItems { - if k.Type != "Tombstone" { - replies.OrderedItems = append(replies.OrderedItems, k) - } - } - - replies.TotalItems = collection.OrderedItems[i].Replies.TotalItems - replies.TotalImgs = collection.OrderedItems[i].Replies.TotalImgs - collection.OrderedItems[i].Replies = &replies - } -} - -func DeleteTombstonePosts(collection *Collection) { - var nColl Collection - - for _, e := range collection.OrderedItems { - if e.Type != "Tombstone" { - nColl.OrderedItems = append(nColl.OrderedItems, e) - } - } - collection.OrderedItems = nColl.OrderedItems -} - -func DeleteRemovedPosts(db *sql.DB, collection *Collection) { - - removed := GetLocalDeleteDB(db) - - for p, e := range collection.OrderedItems { - for _, j := range removed { - if e.Id == j.ID { - if j.Type == "attachment" { - collection.OrderedItems[p].Preview.Href = "/public/removed.png" - collection.OrderedItems[p].Preview.Name = "deleted" - collection.OrderedItems[p].Preview.MediaType = "image/png" - collection.OrderedItems[p].Attachment[0].Href = "/public/removed.png" - collection.OrderedItems[p].Attachment[0].Name = "deleted" - collection.OrderedItems[p].Attachment[0].MediaType = "image/png" - } else { - collection.OrderedItems[p].AttributedTo = "deleted" - collection.OrderedItems[p].Content = "" - collection.OrderedItems[p].Type = "Tombstone" - if collection.OrderedItems[p].Attachment != nil { - collection.OrderedItems[p].Preview.Href = "/public/removed.png" - collection.OrderedItems[p].Preview.Name = "deleted" - collection.OrderedItems[p].Preview.MediaType = "image/png" - collection.OrderedItems[p].Attachment[0].Href = "/public/removed.png" - collection.OrderedItems[p].Attachment[0].Name = "deleted" - collection.OrderedItems[p].Attachment[0].MediaType = "image/png" - } - } - } - } - - for i, r := range e.Replies.OrderedItems { - for _, k := range removed { - if r.Id == k.ID { - if k.Type == "attachment" { - e.Replies.OrderedItems[i].Preview.Href = "/public/removed.png" - e.Replies.OrderedItems[i].Preview.Name = "deleted" - e.Replies.OrderedItems[i].Preview.MediaType = "image/png" - e.Replies.OrderedItems[i].Attachment[0].Href = "/public/removed.png" - e.Replies.OrderedItems[i].Attachment[0].Name = "deleted" - e.Replies.OrderedItems[i].Attachment[0].MediaType = "image/png" - collection.OrderedItems[p].Replies.TotalImgs = collection.OrderedItems[p].Replies.TotalImgs - 1 - } else { - e.Replies.OrderedItems[i].AttributedTo = "deleted" - e.Replies.OrderedItems[i].Content = "" - e.Replies.OrderedItems[i].Type = "Tombstone" - if e.Replies.OrderedItems[i].Attachment != nil { - e.Replies.OrderedItems[i].Preview.Href = "/public/removed.png" - e.Replies.OrderedItems[i].Preview.Name = "deleted" - e.Replies.OrderedItems[i].Preview.MediaType = "image/png" - e.Replies.OrderedItems[i].Attachment[0].Name = "deleted" - e.Replies.OrderedItems[i].Attachment[0].Href = "/public/removed.png" - e.Replies.OrderedItems[i].Attachment[0].MediaType = "image/png" - collection.OrderedItems[p].Replies.TotalImgs = collection.OrderedItems[p].Replies.TotalImgs - 1 - } - collection.OrderedItems[p].Replies.TotalItems = collection.OrderedItems[p].Replies.TotalItems - 1 - } - } - } - } - } -} - func CreateLocalDeleteDB(db *sql.DB, id string, _type string) { query := `select id from removed where id=$1` -- cgit v1.2.3 From cc24155859b65653495747bd0b38be9bcef33298 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Thu, 17 Jun 2021 00:21:07 -0700 Subject: added html meta data as well as basic hover effect on links --- client.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'client.go') diff --git a/client.go b/client.go index e9ecd80..1c3ae93 100644 --- a/client.go +++ b/client.go @@ -47,6 +47,8 @@ type PageData struct { Boards []Board Posts []ObjectBase Key string + PostId string + Instance Actor } type AdminPage struct { @@ -158,8 +160,10 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C returnData.Board.Restricted = actor.Restricted returnData.Key = *Key - returnData.Board.Post.Actor = actor + returnData.Board.Post.Actor = actor + returnData.Instance = GetActorFromDB(db, Domain) + returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) @@ -196,6 +200,8 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) + returnData.Instance = GetActorFromDB(db, Domain) + returnData.Title = "/" + returnData.Board.Name + "/ - " + returnData.Board.PrefName returnData.Key = *Key @@ -212,7 +218,6 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ if len(followCollection.OrderedItems) > 0 { returnData.Board.InReplyTo = followCollection.OrderedItems[0].Id returnData.Posts = append(returnData.Posts, followCollection.OrderedItems[0]) - var actor Actor actor = FingerActor(returnData.Board.InReplyTo) returnData.Board.Post.Actor = &actor @@ -228,6 +233,10 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ } } + if len(returnData.Posts) > 0 { + returnData.PostId = shortURL(returnData.Board.To, returnData.Posts[0].Id) + } + t.ExecuteTemplate(w, "layout", returnData) } -- cgit v1.2.3 From ef7eb7330018c84a44fb24711982c25f51749d2e Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Thu, 24 Jun 2021 23:45:18 -0700 Subject: changed activitystream formating for objects to better align with pleromas actor field --- client.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'client.go') diff --git a/client.go b/client.go index 1c3ae93..91f5f1f 100644 --- a/client.go +++ b/client.go @@ -89,7 +89,8 @@ func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { data.Board.Domain = Domain data.Board.ModCred, _ = GetPasswordFromSession(r) data.Board.Actor = actor - data.Board.Post.Actor = &actor + data.Board.Post.Actor = actor.Id + data.Board.Restricted = actor.Restricted t.ExecuteTemplate(w, "layout", data) } @@ -117,7 +118,7 @@ func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Co returnData.Board.Restricted = actor.Restricted returnData.CurrentPage = page - returnData.Board.Post.Actor = actor + returnData.Board.Post.Actor = actor.Id returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) @@ -160,7 +161,7 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C returnData.Board.Restricted = actor.Restricted returnData.Key = *Key - returnData.Board.Post.Actor = actor + returnData.Board.Post.Actor = actor.Id returnData.Instance = GetActorFromDB(db, Domain) @@ -220,12 +221,12 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ returnData.Posts = append(returnData.Posts, followCollection.OrderedItems[0]) var actor Actor actor = FingerActor(returnData.Board.InReplyTo) - returnData.Board.Post.Actor = &actor + returnData.Board.Post.Actor = actor.Id } } else { collection := GetObjectByIDFromDB(db, inReplyTo) - returnData.Board.Post.Actor = collection.Actor + returnData.Board.Post.Actor = collection.Actor.Id returnData.Board.InReplyTo = inReplyTo if len(collection.OrderedItems) > 0 { -- cgit v1.2.3