adds feed
This commit is contained in:
@@ -176,6 +176,11 @@ func TrailFromActivity(activity pub.Activity, app core.App, actor *core.Record)
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// this trail exists already
|
||||
// nothing more to do
|
||||
|
||||
return record, nil
|
||||
}
|
||||
|
||||
var distance, duration, elevation_gain, elevation_loss float64
|
||||
@@ -442,6 +447,11 @@ func ListFromActivity(activity pub.Activity, app core.App, actor *core.Record) (
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// this list exists already
|
||||
// nothing more to do
|
||||
|
||||
return record, nil
|
||||
}
|
||||
|
||||
record.Set("name", l.Name.First().Value)
|
||||
|
||||
27
db/util/feed.go
Normal file
27
db/util/feed.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package util
|
||||
|
||||
import "github.com/pocketbase/pocketbase/core"
|
||||
|
||||
type FeedType string
|
||||
|
||||
const (
|
||||
ListFeed FeedType = "list"
|
||||
TrailFeed FeedType = "trail"
|
||||
SummitLogFeed FeedType = "summit_log"
|
||||
)
|
||||
|
||||
func InsertIntoFeed(app core.App, actorId string, authorId string, itemId string, feedType FeedType) (*core.Record, error) {
|
||||
collection, err := app.FindCollectionByNameOrId("feed")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
record := core.NewRecord(collection)
|
||||
|
||||
record.Set("actor", actorId)
|
||||
record.Set("author", authorId)
|
||||
record.Set("item", itemId)
|
||||
record.Set("type", string(feedType))
|
||||
|
||||
return record, app.Save(record)
|
||||
}
|
||||
Reference in New Issue
Block a user