fmt and update readme

This commit is contained in:
Jeffrey Paul 2019-12-14 07:49:35 -08:00
parent f2590fbe75
commit ceaed5f3e7
6 changed files with 52 additions and 24 deletions

View File

@ -6,7 +6,27 @@ archives the fediverse
[![CircleCI](https://circleci.com/gh/sneak/feta.svg?style=svg)](https://circleci.com/gh/sneak/feta)
# author
# ethics statement
It seems that some splinter groups are not well acquainted with the norms of
publishing data on the web.
Publishing your toots/messages on a server without marking them private or
requiring authentication and thus making them available to the web is an act
of affirmative consent to allowing others to download those toots/messages
(usually by viewing them in a browser on your profile page). If you don't
want your toots downloaded by remote/unauthenticated users on the web, do
not publish them to the web.
If you publish them to the whole web (and your home instance serves them to
all comers), do not be surprised or feel violated when people download (and
optionally save) them, as your home instance permits them to.
We do not have a right to be forgotten, as we do not have a right to delete
legitimately-obtained files from the hard drives of other people.
# Author
Jeffrey Paul <[sneak@sneak.berlin](mailto:sneak@sneak.berlin)>
[@sneak@sneak.berlin](https://s.sneak.berlin/@sneak)

View File

@ -4,7 +4,7 @@ import "os"
import "time"
import "github.com/jinzhu/gorm"
import _ "github.com/jinzhu/gorm/dialects/sqlite" // required for orm
import _ "github.com/jinzhu/gorm/dialects/sqlite" // required for orm
import "github.com/rs/zerolog"
import "github.com/rs/zerolog/log"
@ -33,7 +33,7 @@ type Process struct {
builduser string
locator *InstanceLocator
manager *InstanceManager
ingester *tootIngester
ingester *tootIngester
api *fetaAPIServer
db *gorm.DB
startup time.Time
@ -109,7 +109,7 @@ func (f *Process) runForever() int {
f.locator.addInstanceNotificationChannel(newInstanceHostnameNotifications)
f.manager.addInstanceNotificationChannel(newInstanceHostnameNotifications)
f.manager.addTootDestination(f.ingester.getDeliveryChannel())
f.manager.addTootDestination(f.ingester.getDeliveryChannel())
// ingester goroutine:
go f.ingester.ingest()

View File

@ -4,22 +4,30 @@ import "time"
import "github.com/rs/zerolog/log"
type tootIngester struct {
inbound chan *toot
inbound chan *toot
recentlySeen
}
type tootHash string
type seenTootMemo struct {
lastSeen time.Time
tootHash tootHash
}
func newTootIngester() *tootIngester {
ti := new(tootIngester)
ti.inbound = make(chan *toot, 1)
return ti
ti := new(tootIngester)
ti.inbound = make(chan *toot, 1)
return ti
}
func (ti *tootIngester) getDeliveryChannel() chan *toot {
return ti.inbound
return ti.inbound
}
func (ti *tootIngester) ingest() {
log.Info().Msg("tootIngester starting")
for {
time.Sleep(1 * time.Second) // FIXME do something
}
for {
time.Sleep(1 * time.Second) // FIXME do something
}
}

View File

@ -170,8 +170,8 @@ func (i *instance) nodeIdentified() bool {
func (i *instance) detectNodeTypeIfNecessary() error {
if !i.nodeIdentified() {
return i.fetchNodeInfo()
}
return nil
}
return nil
}
func (i *instance) registerError() {

View File

@ -37,7 +37,7 @@ type InstanceLocator struct {
pleromaIndexNextRefresh *time.Time
mastodonIndexNextRefresh *time.Time
reportInstanceVia chan InstanceHostname
mu sync.Mutex
mu sync.Mutex
}
func newInstanceLocator() *InstanceLocator {
@ -49,11 +49,11 @@ func newInstanceLocator() *InstanceLocator {
}
func (il *InstanceLocator) lock() {
il.mu.Lock()
il.mu.Lock()
}
func (il *InstanceLocator) unlock() {
il.mu.Unlock()
il.mu.Unlock()
}
func (il *InstanceLocator) addInstanceNotificationChannel(via chan InstanceHostname) {
@ -151,8 +151,8 @@ func (il *InstanceLocator) locateMastodon() {
return
}
log.Info().
Msg("fetched mastodon index")
log.Info().
Msg("fetched mastodon index")
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)

View File

@ -19,7 +19,7 @@ type InstanceManager struct {
mu sync.Mutex
instances map[InstanceHostname]*instance
newInstanceNotifications chan InstanceHostname
newToots chan *toot
newToots chan *toot
startup time.Time
hostAdderSemaphore chan bool
}
@ -32,7 +32,7 @@ func newInstanceManager() *InstanceManager {
}
func (im *InstanceManager) addTootDestination(td chan *toot) {
im.newToots = td
im.newToots = td
}
func (im *InstanceManager) logCaller(msg string) {
@ -99,7 +99,7 @@ func (im *InstanceManager) managerLoop() {
}
im.unlock()
// FIXME is this a bug outside of the mutex above?
// FIXME is this a bug outside of the mutex above?
for _, v := range il {
go func(i *instance) {
i.Tick()
@ -120,7 +120,7 @@ func (im *InstanceManager) hostnameExists(newhn InstanceHostname) bool {
func (im *InstanceManager) addInstanceByHostname(newhn InstanceHostname) {
if im.hostnameExists(newhn) {
// ignore adding new if we already know about it
// ignore adding new if we already know about it
return
}
@ -150,7 +150,7 @@ func (im *InstanceManager) receiveNewInstanceHostnames() {
newhn = <-im.newInstanceNotifications
// receive them fast out of the channel, let the adding function lock to add
// them one at a time, using a bunch of blocked goroutines as our
// modification queue
// modification queue
go im.addInstanceByHostname(newhn)
}
}