Started working on activity likes
This commit is contained in:
22
utils/ActivityLink.go
Normal file
22
utils/ActivityLink.go
Normal file
@ -0,0 +1,22 @@
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user