MCPcopy Create free account
hub / github.com/davecheney/pub / FindOrCreateByURI

Method FindOrCreateByURI

models/actor.go:253–275  ·  view source on GitHub ↗
(uri string)

Source from the content-addressed store, hash-verified

251}
252
253// MaybePinned returns a query that only includes pinned statuses if the request contains
254// the pinned parameter.
255func MaybePinned(r *http.Request) func(db *gorm.DB) *gorm.DB {
256 return func(db *gorm.DB) *gorm.DB {
257 if pinned := parseBool(r, "pinned"); pinned {
258 db = db.Joins("JOIN reactions ON reactions.status_id = statuses.id AND reactions.pinned = true AND reactions.actor_id = statuses.actor_id")
259 }
260 return db
261 }
262}
263
264// PreloadActor preloads all of an Actor's relations and associations.
265func PreloadActor(query *gorm.DB) *gorm.DB {
266 return query.Preload("Attributes")
267}
268
269// parseBool parses a boolean value from a request parameter.
270// If the parameter is not present, it returns false.
271// If the parameter is present but cannot be parsed, it returns false
272func parseBool(r *http.Request, key string) bool {
273 switch r.URL.Query().Get(key) {
274 case "true", "1":
275 return true
276 default:
277 return false
278 }

Callers 6

RunMethod · 0.45
getKeyMethod · 0.45
maybeCreateStatusMethod · 0.45
maybeCreateReblogMethod · 0.45
searchAccountsFunction · 0.45
searchStatusesFunction · 0.45

Calls 3

FindByURIMethod · 0.95
fetchObjectFunction · 0.85
CreateMethod · 0.45

Tested by

no test coverage detected