23 lines
464 B
Go
Raw Normal View History

2018-11-16 20:33:40 +00:00
package utils
import (
"fmt"
"strings"
"github.com/animenotifier/arn"
)
// ActivityAPILink returns the API link for any activity.
func ActivityAPILink(activity arn.Activity) string {
id := activity.GetID()
typeName := activity.TypeName()
if activity.TypeName() == "ActivityCreate" {
created := activity.(*arn.ActivityCreate)
typeName = created.ObjectType
id = created.ObjectID
}
return fmt.Sprintf("/api/%s/%s", strings.ToLower(typeName), id)
}