Compare commits
2 Commits
91e9add76a
...
877a87e21d
| Author | SHA1 | Date | |
|---|---|---|---|
| 877a87e21d | |||
| 0c88e90853 |
|
|
@ -157,8 +157,7 @@ func (timeline *redisSortedSetTimeline) AddItem(item microsub.Item) error {
|
||||||
|
|
||||||
data, err := json.Marshal(item)
|
data, err := json.Marshal(item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error while creating item for redis: %v\n", err)
|
return fmt.Errorf("couldn't marshall item for redis: %s", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
forRedis := redisItem{
|
forRedis := redisItem{
|
||||||
|
|
@ -171,7 +170,7 @@ func (timeline *redisSortedSetTimeline) AddItem(item microsub.Item) error {
|
||||||
itemKey := fmt.Sprintf("item:%s", item.ID)
|
itemKey := fmt.Sprintf("item:%s", item.ID)
|
||||||
_, err = redis.String(conn.Do("HMSET", redis.Args{}.Add(itemKey).AddFlat(&forRedis)...))
|
_, err = redis.String(conn.Do("HMSET", redis.Args{}.Add(itemKey).AddFlat(&forRedis)...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error while writing item for redis: %v", err)
|
return fmt.Errorf("writing failed for item to redis: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
readChannelKey := fmt.Sprintf("channel:%s:read", channel)
|
readChannelKey := fmt.Sprintf("channel:%s:read", channel)
|
||||||
|
|
@ -186,12 +185,12 @@ func (timeline *redisSortedSetTimeline) AddItem(item microsub.Item) error {
|
||||||
|
|
||||||
score, err := time.Parse(time.RFC3339, item.Published)
|
score, err := time.Parse(time.RFC3339, item.Published)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error can't parse %s as time", item.Published)
|
return fmt.Errorf("can't parse %s as time", item.Published)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = redis.Int64(conn.Do("ZADD", zchannelKey, score.Unix()*1.0, itemKey))
|
_, err = redis.Int64(conn.Do("ZADD", zchannelKey, score.Unix()*1.0, itemKey))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error while zadding item %s to channel %s for redis: %v", itemKey, zchannelKey, err)
|
return fmt.Errorf("zadding failed item %s to channel %s for redis: %v", itemKey, zchannelKey, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: send message to events...
|
// FIXME: send message to events...
|
||||||
|
|
|
||||||
|
|
@ -114,10 +114,12 @@ func simplifyToItem(itemType string, item map[string][]interface{}) microsub.Ite
|
||||||
case "checkin", "location":
|
case "checkin", "location":
|
||||||
author, _ := simplifyCard(v[0])
|
author, _ := simplifyCard(v[0])
|
||||||
feedItem.Checkin = &author
|
feedItem.Checkin = &author
|
||||||
case "name", "published", "updated", "url", "uid", "latitude", "longitude":
|
case "name", "published", "updated", "url", "uid", "latitude", "longitude", "summary":
|
||||||
if resultPtr := getScalarPtr(&feedItem, k); resultPtr != nil {
|
if resultPtr := getScalarPtr(&feedItem, k); resultPtr != nil {
|
||||||
if len(v) >= 1 {
|
if len(v) >= 1 {
|
||||||
*resultPtr = v[0].(string)
|
if value, ok := v[0].(string); ok {
|
||||||
|
*resultPtr = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "photo":
|
case "photo":
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ type Item struct {
|
||||||
RepostOf []string `json:"repost-of,omitempty" mf2:"repost-of"`
|
RepostOf []string `json:"repost-of,omitempty" mf2:"repost-of"`
|
||||||
InReplyTo []string `json:"in-reply-to,omitempty" mf2:"in-reply-to"`
|
InReplyTo []string `json:"in-reply-to,omitempty" mf2:"in-reply-to"`
|
||||||
Content *Content `json:"content,omitempty" mf2:"content"`
|
Content *Content `json:"content,omitempty" mf2:"content"`
|
||||||
|
Summary string `json:"summary,omitempty" mf2:"summary"`
|
||||||
Latitude string `json:"latitude,omitempty" mf2:"latitude"`
|
Latitude string `json:"latitude,omitempty" mf2:"latitude"`
|
||||||
Longitude string `json:"longitude,omitempty" mf2:"longitude"`
|
Longitude string `json:"longitude,omitempty" mf2:"longitude"`
|
||||||
Checkin *Card `json:"checkin,omitempty" mf2:"checkin"`
|
Checkin *Card `json:"checkin,omitempty" mf2:"checkin"`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user