Compare commits

...

3 Commits

2 changed files with 20 additions and 4 deletions

View File

@ -228,10 +228,9 @@ func (b *memoryBackend) feedItems(fetchURL, contentType string, body io.Reader)
//r["_id"] = "" // generate random value
}
if _, e := r["published"]; e {
item := mapToItem(r)
items = append(items, item)
}
// mapToItem adds published
item := mapToItem(r)
items = append(items, item)
}
} else if strings.HasPrefix(contentType, "application/json") { // json feed?
var feed JSONFeed
@ -329,6 +328,14 @@ func (b *memoryBackend) feedItems(fetchURL, contentType string, body io.Reader)
items[i] = v
}
}
for _, item := range items {
log.Printf("ID=%s Name=%s\n", item.ID, item.Name)
log.Printf("Author=%#v\n", item.Author)
log.Printf("Text=%s\n", item.Content.Text)
log.Printf("HTML=%s\n", item.Content.HTML)
}
return items, nil
}
@ -365,6 +372,10 @@ func (b *memoryBackend) channelAddItem(channel string, item microsub.Item) {
channelKey := fmt.Sprintf("channel:%s:posts", channel)
zchannelKey := fmt.Sprintf("zchannel:%s:posts", channel)
if item.Published == "" {
item.Published = time.Now().Format(time.RFC3339)
}
data, err := json.Marshal(item)
if err != nil {
log.Printf("error while creating item for redis: %v\n", err)
@ -378,6 +389,9 @@ func (b *memoryBackend) channelAddItem(channel string, item microsub.Item) {
Data: data,
}
log.Printf("Adding item to channel %s\n", channel)
log.Printf("%#v\n", forRedis)
itemKey := fmt.Sprintf("item:%s", item.ID)
_, err = redis.String(conn.Do("HMSET", redis.Args{}.Add(itemKey).AddFlat(&forRedis)...))
if err != nil {

View File

@ -346,6 +346,8 @@ func mapToItem(result map[string]interface{}) microsub.Item {
if published, e := result["published"]; e {
item.Published = published.(string)
} else {
item.Published = time.Now().Format(time.RFC3339)
}
if updated, e := result["updated"]; e {