aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--cacheDatabase.go (renamed from CacheDatabase.go)72
-rw-r--r--database.go (renamed from Database.go)24
-rw-r--r--follow.go (renamed from Follow.go)0
-rw-r--r--main.go4
-rw-r--r--outboxPost.go (renamed from OutboxPost.go)3
l---------static/.#ncatalog.html1
7 files changed, 17 insertions, 88 deletions
diff --git a/.gitignore b/.gitignore
index 9789d20..adb71bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.*
*~
#*
public/
diff --git a/CacheDatabase.go b/cacheDatabase.go
index 2761237..380ade0 100644
--- a/CacheDatabase.go
+++ b/cacheDatabase.go
@@ -1,7 +1,6 @@
package main
import "fmt"
-import "time"
import "database/sql"
import _ "github.com/lib/pq"
@@ -31,17 +30,6 @@ func WriteObjectToCache(db *sql.DB, obj ObjectBase) ObjectBase {
return obj
}
-func WriteObjectUpdatesToCache(db *sql.DB, obj ObjectBase) {
- query := `update cacheactivitystream set updated=$1 where id=$2`
-
- _, e := db.Exec(query, time.Now().Format(time.RFC3339), obj.Id)
-
- if e != nil{
- fmt.Println("error inserting updating inreplyto")
- panic(e)
- }
-}
-
func WriteActivitytoCache(db *sql.DB, obj ObjectBase) {
obj.Name = EscapeString(obj.Name)
@@ -248,36 +236,6 @@ func WriteActorToCache(db *sql.DB, actorID string) {
}
}
-func DeleteObjectFromCache(db *sql.DB, id string) {
- query := `select attachment, preview from cacheactivitystream where id=$1 `
-
- rows, err := db.Query(query, id)
- CheckError(err, "could not select cache activitystream")
-
- var attachment string
- var preview string
-
- defer rows.Close()
- rows.Next()
- rows.Scan(&attachment, &preview)
-
- query = `delete from cacheactivitystream where id=$1`
- _, err = db.Exec(query, attachment)
- CheckError(err, "could not delete attachmet cache activitystream")
-
- query = `delete from cacheactivitystream where id=$1`
- _, err = db.Exec(query, preview)
- CheckError(err, "could not delete preview cache activitystream")
-
- query = `delete from cacheactivitystream where id=$1`
- _, err = db.Exec(query, id)
- CheckError(err, "could not delete object cache activitystream")
-
- query = `delete from replies where id=$1`
- _, err = db.Exec(query, id)
- CheckError(err, "could not delete cache replies activitystream")
-}
-
func DeleteActorCache(db *sql.DB, actorID string) {
query := `select id from cacheactivitystream where id in (select id from cacheactivitystream where actor=$1)`
@@ -291,34 +249,6 @@ func DeleteActorCache(db *sql.DB, actorID string) {
var id string
rows.Scan(&id)
- DeleteObjectFromCache(db, id)
+ DeleteObject(db, id)
}
}
-
-func TombstoneObjectFromCache(db *sql.DB, id string) {
-
- datetime := time.Now().Format(time.RFC3339)
-
- query := `update cacheactivitystream set type='Tombstone', name='', content='', attributedto='deleted', tripcode='', updated=$1, deleted=$2 where id=$3`
-
- _, err := db.Exec(query, datetime, datetime, id)
-
- CheckError(err, "error with tombstone cache object")
-
- query = `update cacheactivitystream set type='Tombstone', mediatype='image/png', href=$1, name='', content='', attributedto='deleted', updated=$2, deleted=$3 where id in (select attachment from cacheactivitystream where id=$4)`
-
- _, err = db.Exec(query, "/public/removed.png", datetime, datetime, id)
-
- CheckError(err, "error with tombstone attachment cache object")
-
- query = `update cacheactivitystream set type='Tombstone', mediatype='image/png', href=$1, name='', content='', attributedto='deleted', updated=$2, deleted=$3 where id in (select preview from cacheactivitystream where id=$4)`
-
- _, err = db.Exec(query, "/public/removed.png", datetime, datetime, id)
-
- CheckError(err, "error with tombstone preview cache object")
-
- query = `delete from replies where id=$1`
- _, err = db.Exec(query, id)
-
- CheckError(err, "could not delete cache replies activitystream")
-}
diff --git a/Database.go b/database.go
index fb12597..13cd08f 100644
--- a/Database.go
+++ b/database.go
@@ -197,7 +197,16 @@ func WriteObjectUpdatesToDB(db *sql.DB, obj ObjectBase) {
if e != nil{
fmt.Println("error inserting updating inreplyto")
panic(e)
- }
+ }
+
+ query = `update cacheactivitystream set updated=$1 where id=$2`
+
+ _, e = db.Exec(query, time.Now().Format(time.RFC3339), obj.Id)
+
+ if e != nil{
+ fmt.Println("error inserting updating cache inreplyto")
+ panic(e)
+ }
}
func WriteObjectReplyToLocalDB(db *sql.DB, id string, replyto string) {
@@ -261,11 +270,7 @@ func WriteObjectReplyToDB(db *sql.DB, obj ObjectBase) {
}
if update {
- if IsObjectLocal(db, e.Id) {
- WriteObjectUpdatesToDB(db, e)
- } else {
- WriteObjectUpdatesToCache(db, e)
- }
+ WriteObjectUpdatesToDB(db, e)
}
}
@@ -910,8 +915,8 @@ func DeletePreviewFromFile(db *sql.DB, id string) {
err := rows.Scan(&href)
href = strings.Replace(href, Domain + "/", "", 1)
CheckError(err, "error scanning delete attachment")
-
- if(href != "/static/notfound.png") {
+
+ if(href != "static/notfound.png") {
_, err = os.Stat(href)
if err == nil {
os.Remove(href)
@@ -936,10 +941,9 @@ func DeleteAttachmentFromFile(db *sql.DB, id string) {
err := rows.Scan(&href)
href = strings.Replace(href, Domain + "/", "", 1)
-
CheckError(err, "error scanning delete preview")
- if(href != "/static/notfound.png") {
+ if(href != "static/notfound.png") {
_, err = os.Stat(href)
if err == nil {
os.Remove(href)
diff --git a/Follow.go b/follow.go
index 667c6bd..667c6bd 100644
--- a/Follow.go
+++ b/follow.go
diff --git a/main.go b/main.go
index da39b5e..aa0764c 100644
--- a/main.go
+++ b/main.go
@@ -853,10 +853,6 @@ func main() {
SetObjectAndReplies(db, id, "Removed")
}
- if IsIDLocal(db, id){
- DeleteObjectRequest(db, id)
- }
-
if(manage == "t"){
http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther)
return
diff --git a/OutboxPost.go b/outboxPost.go
index c9ceb12..8bddf42 100644
--- a/OutboxPost.go
+++ b/outboxPost.go
@@ -566,11 +566,10 @@ func ParseInboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) {
if actor.Id != "" {
if activity.Object.Replies != nil {
for _, k := range activity.Object.Replies.OrderedItems {
- TombstoneObjectFromCache(db, k.Id)
DeleteObject(db, k.Id)
}
}
- TombstoneObjectFromCache(db, activity.Object.Id)
+ DeleteObject(db, activity.Object.Id)
break
}
}
diff --git a/static/.#ncatalog.html b/static/.#ncatalog.html
deleted file mode 120000
index 7e43052..0000000
--- a/static/.#ncatalog.html
+++ /dev/null
@@ -1 +0,0 @@
-namll@parabola.3055 \ No newline at end of file