aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel <>2021-08-01 18:35:00 -0700
committerFChannel <>2021-08-01 18:35:00 -0700
commit4450e8da252137b68f067dbc9cfaa5745a8804c5 (patch)
tree0759a113986b9adddbe4b1cab6e98a50cf5e13ef
parentca7a516f878bba8ab62ffda596ba603b26250917 (diff)
fix inactive instance check and archive bug
-rw-r--r--client.go5
-rw-r--r--database.go3
-rw-r--r--main.go57
-rw-r--r--static/archive.html12
-rw-r--r--static/faq.html2
-rw-r--r--static/npost.html1
6 files changed, 63 insertions, 17 deletions
diff --git a/client.go b/client.go
index 5ccdade..3b7676e 100644
--- a/client.go
+++ b/client.go
@@ -1019,7 +1019,7 @@ func ShortExcerpt(post ObjectBase) string {
var returnString string
if post.Name != "" {
- returnString = post.Name + ": " + post.Content;
+ returnString = post.Name + "| " + post.Content;
} else {
returnString = post.Content;
}
@@ -1032,12 +1032,13 @@ func ShortExcerpt(post ObjectBase) string {
returnString = match[0] + "..."
}
- re = regexp.MustCompile(`(^.+:)`)
+ re = regexp.MustCompile(`(^.+\|)`)
match = re.FindStringSubmatch(returnString)
if len(match) > 0 {
returnString = strings.Replace(returnString, match[0], "<b>" + match[0] + "</b>", 1)
+ returnString = strings.Replace(returnString, "|", ":", 1)
}
return returnString
diff --git a/database.go b/database.go
index d0b6fcc..f142ea2 100644
--- a/database.go
+++ b/database.go
@@ -1834,7 +1834,7 @@ func IsInactiveTimestamp(db *sql.DB, timeStamp string) bool {
}
func ArchivePosts(db *sql.DB, actor Actor) {
- if actor.Id != "" {
+ if actor.Id != "" && actor.Id != Domain {
col := GetAllActorArchiveDB(db, actor.Id, 165)
for _, e := range col.OrderedItems {
for _, k := range e.Replies.OrderedItems {
@@ -1901,7 +1901,6 @@ func GetActorCollectionDBType(db *sql.DB, actorId string, nType string) Collecti
post.Replies = &replies
post.Replies.TotalItems, post.Replies.TotalImgs = GetObjectRepliesCount(db, post)
-
post.Attachment = GetObjectAttachment(db, attachID)
post.Preview = GetObjectPreview(db, previewID)
diff --git a/main.go b/main.go
index c370722..07d2adf 100644
--- a/main.go
+++ b/main.go
@@ -71,6 +71,8 @@ func main() {
StartupArchive(db)
+ go CheckInactive(db)
+
Boards = GetBoardCollection(db)
// root actor is used to follow remote feeds that are not local
@@ -1864,7 +1866,6 @@ func GetActor(id string) Actor {
resp, err := RouteProxy(req)
if err != nil {
- fmt.Println("error with getting actor resp " + id)
return respActor
}
@@ -1874,7 +1875,9 @@ func GetActor(id string) Actor {
err = json.Unmarshal(body, &respActor)
- CheckError(err, "error getting actor from body")
+ if err != nil {
+ return respActor
+ }
ActorCache[actor + "@" + instance] = respActor
}
@@ -2213,10 +2216,7 @@ func MakeActivityRequest(db *sql.DB, activity Activity) {
_, err = RouteProxy(req)
if err != nil {
- fmt.Println("error with sending activity resp to actor " + instance + " instance marked as inactive and will be removed from following and followers in 24 hrs")
- AddInstanceToInactiveDB(db, instance)
- } else {
- DeleteInstanceFromInactiveDB(db, instance)
+ fmt.Println("error with sending activity resp to actor " + instance)
}
}
}
@@ -2942,3 +2942,48 @@ func StartupArchive(db *sql.DB) {
ArchivePosts(db, GetActorFromDB(db, e.Id))
}
}
+
+func CheckInactive(db *sql.DB) {
+ for true {
+ CheckInactiveInstances(db)
+ time.Sleep(48 * time.Hour)
+ }
+}
+
+func CheckInactiveInstances(db *sql.DB) map[string]string {
+ instances := make(map[string]string)
+ query := `select following from following`
+ rows, err := db.Query(query)
+
+ CheckError(err, "cold not select instances from following")
+
+ defer rows.Close()
+ for rows.Next() {
+ var instance string
+ rows.Scan(&instance)
+ instances[instance] = instance
+ }
+
+ query = `select follower from follower`
+ rows, err = db.Query(query)
+
+ CheckError(err, "cold not select instances from follower")
+
+ defer rows.Close()
+ for rows.Next() {
+ var instance string
+ rows.Scan(&instance)
+ instances[instance] = instance
+ }
+
+ for _, e := range instances {
+ actor := GetActor(e)
+ if actor.Id == "" {
+ AddInstanceToInactiveDB(db, e)
+ } else {
+ DeleteInstanceFromInactiveDB(db, e)
+ }
+ }
+
+ return instances
+}
diff --git a/static/archive.html b/static/archive.html
index aa37c94..b08693a 100644
--- a/static/archive.html
+++ b/static/archive.html
@@ -37,14 +37,14 @@
</ul>
<hr>
-<table align="center" style="width: 900px;">
+<table align="center" style="table-layout:fixed; width:90%;">
<tr>
{{ if eq $board.ModCred $board.Domain $board.Actor.Id }}
- <td></td>
+ <th style="width: 45px;"></th>
{{ end }}
- <th style="width: 100px">No.</th>
+ <th style="width: 110px">No.</th>
<th>Excerpt</th>
- <th style="width: 100px;"></th>
+ <th style="width: 60px;"></th>
</tr>
{{ range $i, $e := .Posts }}
{{ if mod $i 2 }}
@@ -53,7 +53,7 @@
<td><a href="/poparchive?id={{ $e.Id }}&board={{ $board.Name }}">[Pop]</a></td>
{{ end }}
<td>{{ short $board.Actor.Outbox $e.Id }}</td>
- <td>{{ shortExcerpt $e }}</td>
+ <td style="overflow: hidden; word-wrap: break-word; text-overflow: ellipsis;">{{ shortExcerpt $e }}</td>
<td style="text-align: center;"><a href="/{{ $board.Actor.Name }}/{{ short $board.Actor.Outbox $e.Id }}">[View]</a></td>
</tr>
{{ else }}
@@ -62,7 +62,7 @@
<td><a href="/poparchive?id={{ $e.Id }}">[Pop]</a></td>
{{ end }}
<td>{{ short $board.Actor.Outbox $e.Id }}</td>
- <td>{{ shortExcerpt $e }}</td>
+ <td style="overflow: hidden; word-wrap: break-word; text-overflow: ellipsis;">{{ shortExcerpt $e }}</td>
<td style="text-align: center;"><a href="/{{ $board.Actor.Name }}/{{ short $board.Actor.Outbox $e.Id }}">[View]</a></td>
</tr>
{{ end }}
diff --git a/static/faq.html b/static/faq.html
index f4fb237..b9c6085 100644
--- a/static/faq.html
+++ b/static/faq.html
@@ -56,7 +56,7 @@
<p>Soon&trade;.</p>
<h4 id="version">What version is this FChannel instance?</h4>
- <p>v0.0.14-release</p>
+ <p>v0.0.14-dev</p>
</div>
<div style="width: 500px; margin:0 auto; margin-top: 50px; text-align: center;">
<a href="/">[Home]</a><a href="/static/rules.html">[Rules]</a><a href="/static/faq.html">[FAQ]</a>
diff --git a/static/npost.html b/static/npost.html
index b0f89e6..2f0778f 100644
--- a/static/npost.html
+++ b/static/npost.html
@@ -50,6 +50,7 @@
{{ end }}
{{ define "script" }}
+<script src="/static/js/posts.js"></script>
<script src="/static/js/footerscript.js"></script>
<script src="/static/js/timer.js"></script>
{{ end }}