builds now
This commit is contained in:
parent
9d9e344546
commit
3542c107ad
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
fediverse-archive
|
Binary file not shown.
78
fetcher.go
78
fetcher.go
@ -1,23 +1,87 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/rs/zerolog/log"
|
||||
"net/http"
|
||||
"time"
|
||||
//"github.com/bitly/go-simplejson"
|
||||
)
|
||||
|
||||
// https://mastodon.social/api/v1/timelines/public?limit=40&local=true
|
||||
const mastodonIndexUrl = "https://instances.social/list.json?q%5Busers%5D=&q%5Bsearch%5D=&strict=false"
|
||||
|
||||
func findPleromaInstances() {
|
||||
//var url = "https://distsn.org/cgi-bin/distsn-pleroma-instances-api.cgi?shuffle"
|
||||
const pleromaIndexUrl = "https://distsn.org/cgi-bin/distsn-pleroma-instances-api.cgi"
|
||||
|
||||
type InstanceLocator struct {
|
||||
pleromaIndexLastRefresh *time.Time
|
||||
mastodonIndexLastRefresh *time.Time
|
||||
instances map[string]Instance
|
||||
}
|
||||
|
||||
func fetchPleromaToots(url string) {
|
||||
//https://%s/api/statuses/public_and_external_timeline.json?count=100
|
||||
type ServerImplementation int
|
||||
|
||||
const (
|
||||
Mastodon ServerImplementation = iota + 1
|
||||
Pleorama
|
||||
)
|
||||
|
||||
type Instance struct {
|
||||
hostName string
|
||||
impl ServerImplementation
|
||||
errorCount uint
|
||||
lastFetch *time.Time
|
||||
highestId int
|
||||
skip bool
|
||||
}
|
||||
|
||||
func NewInstance(hostname string) *Instance {
|
||||
i := new(Instance)
|
||||
i.hostName = hostname
|
||||
i.detectNodeType()
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *Instance) detectNodeType() {
|
||||
if i.impl == 0 {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Instance) fetchNodeInfo() {
|
||||
url := fmt.Sprintf("https://%s/.well-known/nodeinfo")
|
||||
var c = &http.Client{
|
||||
Timeout: time.Second * 10,
|
||||
}
|
||||
response, err := c.Get(url)
|
||||
if err != nil {
|
||||
log.Debug().Msg("unable to fetch nodeinfo, node is down?")
|
||||
i.skip = true
|
||||
}
|
||||
|
||||
log.Debug().Msg(fmt.Sprintf("%#v", response))
|
||||
}
|
||||
|
||||
func (i *Instance) fetchRecentToots() ([]byte, error) {
|
||||
if i.impl == Mastodon {
|
||||
return i.fetchRecentTootsJsonFromMastodon()
|
||||
} else if i.impl == Pleorama {
|
||||
return i.fetchRecentTootsJsonFromPleorama()
|
||||
} else {
|
||||
panic("nope")
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Instance) fetchRecentTootsJsonFromPleorama() ([]byte, error) {
|
||||
//url := fmt.Sprintf("https://%s/api/statuses/public_and_external_timeline.json?count=100", i.hostName)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (i *Instance) fetchRecentTootsJsonFromMastodon() ([]byte, error) {
|
||||
//url := fmt.Sprintf("https://%s/api/v1/timelines/public?limit=40&local=true", i.hostName)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func fetchLatestToots(lastId int) {
|
||||
|
||||
log.Debug().Msg("This message appears only when log level set to Debug")
|
||||
log.Info().Msg("This message appears when log level set to Debug or Info")
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user