Load all urls when starting
This commit is contained in:
parent
925e914d01
commit
75c9dfd4f6
|
|
@ -59,6 +59,7 @@ func (b *memoryBackend) Fetch3(channel, fetchURL string) error {
|
||||||
u, _ := url.Parse(fetchURL)
|
u, _ := url.Parse(fetchURL)
|
||||||
|
|
||||||
contentType := resp.Header.Get("Content-Type")
|
contentType := resp.Header.Get("Content-Type")
|
||||||
|
log.Println("Found " + contentType)
|
||||||
if strings.HasPrefix(contentType, "text/html") {
|
if strings.HasPrefix(contentType, "text/html") {
|
||||||
data := microformats.Parse(resp.Body, u)
|
data := microformats.Parse(resp.Body, u)
|
||||||
results := simplifyMicroformatData(data)
|
results := simplifyMicroformatData(data)
|
||||||
|
|
@ -175,6 +176,8 @@ func (b *memoryBackend) Fetch3(channel, fetchURL string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *memoryBackend) channelAddItem(channel string, item microsub.Item) {
|
func (b *memoryBackend) channelAddItem(channel string, item microsub.Item) {
|
||||||
|
log.Printf("Adding item to channel %s\n", channel)
|
||||||
|
log.Println(item)
|
||||||
// send to redis
|
// send to redis
|
||||||
channelKey := fmt.Sprintf("channel:%s:posts", channel)
|
channelKey := fmt.Sprintf("channel:%s:posts", channel)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,14 @@ func (b *memoryBackend) load() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("cant open backend.json")
|
panic("cant open backend.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for uid, channel := range b.Channels {
|
||||||
|
log.Printf("loading channel %s - %s\n", uid, channel.Name)
|
||||||
|
for _, feed := range b.Feeds[uid] {
|
||||||
|
log.Printf("- loading feed %s\n", feed.URL)
|
||||||
|
b.Fetch3(uid, feed.URL)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *memoryBackend) save() {
|
func (b *memoryBackend) save() {
|
||||||
|
|
@ -209,7 +217,11 @@ func mapToItem(result map[string]interface{}) microsub.Item {
|
||||||
|
|
||||||
if value, e := result["in-reply-to"]; e {
|
if value, e := result["in-reply-to"]; e {
|
||||||
for _, v := range value.([]interface{}) {
|
for _, v := range value.([]interface{}) {
|
||||||
item.InReplyTo = append(item.InReplyTo, v.(string))
|
if replyTo, ok := v.(string); ok {
|
||||||
|
item.InReplyTo = append(item.InReplyTo, replyTo)
|
||||||
|
} else if cite, ok := v.(map[string]interface{}); ok {
|
||||||
|
item.InReplyTo = append(item.InReplyTo, cite["url"].(string))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user