mirror of https://gitlab.com/ngerakines/tavern.git
Fixed bug where tags were not being recorded correctly.
This commit is contained in:
parent
04fd776cee
commit
dc2afcdecd
|
@ -19,6 +19,7 @@ type ObjectStorage interface {
|
|||
ListObjectEventPayloadsInFeed(ctx context.Context, userID uuid.UUID, limit int, offset int) ([]Payload, error)
|
||||
CountObjectPayloadsInLocalFeed(ctx context.Context) (int, error)
|
||||
ListObjectPayloadsInLocalFeed(ctx context.Context) ([]Payload, error)
|
||||
CountObjectPayloadsInTagFeed(ctx context.Context, tag string) (int, error)
|
||||
ListObjectPayloadsInTagFeed(ctx context.Context, tag string) ([]Payload, error)
|
||||
CountObjectPayloadsInUserOutbox(ctx context.Context, userID uuid.UUID) (int, error)
|
||||
ListObjectPayloadsInUserOutbox(ctx context.Context, userID uuid.UUID, limit int, offset int) ([]Payload, error)
|
||||
|
@ -84,6 +85,11 @@ func (s pgStorage) ListObjectPayloadsInLocalFeed(ctx context.Context) ([]Payload
|
|||
return s.objectPayloads(ctx, query)
|
||||
}
|
||||
|
||||
func (s pgStorage) CountObjectPayloadsInTagFeed(ctx context.Context, tag string) (int, error) {
|
||||
query := `SELECT COUNT(o.payload) FROM user_object_events uoe INNER JOIN object_events oe on oe.id = uoe.activity_id INNER JOIN objects o on oe.object_id = o.id INNER JOIN object_tags ot on ot.object_id = o.id WHERE uoe.public = true AND ot.tag = $1`
|
||||
return s.RowCount(ctx, query, tag)
|
||||
}
|
||||
|
||||
func (s pgStorage) ListObjectPayloadsInTagFeed(ctx context.Context, tag string) ([]Payload, error) {
|
||||
query := `SELECT o.payload FROM user_object_events uoe INNER JOIN object_events oe on oe.id = uoe.activity_id INNER JOIN objects o on oe.object_id = o.id INNER JOIN object_tags ot on ot.object_id = o.id WHERE uoe.public = true AND ot.tag = $1`
|
||||
return s.objectPayloads(ctx, query, tag)
|
||||
|
|
|
@ -224,7 +224,8 @@ func (h handler) createNote(c *gin.Context) {
|
|||
language: content,
|
||||
}
|
||||
}
|
||||
note["context"] = conversation
|
||||
// The spec is really vague about how note context can be used.
|
||||
// note["context"] = conversation
|
||||
note["conversation"] = conversation
|
||||
noteURL := fmt.Sprintf("https://%s/object/%s", h.domain, createNoteID)
|
||||
note["id"] = noteURL
|
||||
|
@ -301,7 +302,7 @@ func (h handler) createNote(c *gin.Context) {
|
|||
"href": fmt.Sprintf("https://%s/tags/%s", h.domain, clean),
|
||||
"name": hashtag,
|
||||
})
|
||||
if len(firstTags) < 5 {
|
||||
if len(firstTags) < 10 {
|
||||
firstTags = append(firstTags, clean)
|
||||
}
|
||||
}
|
||||
|
@ -385,6 +386,13 @@ func (h handler) createNote(c *gin.Context) {
|
|||
return err
|
||||
}
|
||||
|
||||
for _, tag := range firstTags {
|
||||
_, err = storage.RecordObjectTag(ctx, activityObjectRowID, tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -23,7 +23,7 @@ func (h handler) getTaggedObjects(c *gin.Context) {
|
|||
page := intParam(c, "page", 0)
|
||||
limit := 50
|
||||
|
||||
total, err := h.storage.RowCount(ctx, `SELECT COUNT(*) FROM user_activities WHERE public = TRUE AND tags @> ARRAY[$1]::varchar[]`, tag)
|
||||
total, err := h.storage.CountObjectPayloadsInTagFeed(ctx, tag)
|
||||
if err != nil {
|
||||
h.internalServerErrorJSON(c, err)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue