kopia lustrzana https://github.com/reiver/greatape
feat(app): ✨ following retrieval command
rodzic
66c386942d
commit
b1d9011c8c
|
@ -17,6 +17,7 @@
|
|||
10. [FollowActor](#follow-actor)
|
||||
11. [AuthorizeInteraction](#authorize-interaction)
|
||||
12. [GetFollowers](#get-followers)
|
||||
13. [GetFollowing](#get-following)
|
||||
|
||||
---
|
||||
|
||||
|
@ -180,3 +181,18 @@ Result:
|
|||
string first
|
||||
```
|
||||
[Back to List](#apis)
|
||||
|
||||
## Get Following
|
||||
```
|
||||
Request:
|
||||
string username
|
||||
|
||||
Result:
|
||||
string @context
|
||||
string id
|
||||
string type
|
||||
int32 totalItems
|
||||
repeated string orderedItems
|
||||
string first
|
||||
```
|
||||
[Back to List](#apis)
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package spi
|
||||
|
||||
import (
|
||||
. "rail.town/infrastructure/components/constants"
|
||||
. "rail.town/infrastructure/components/contracts"
|
||||
)
|
||||
|
||||
func GetFollowing(x IDispatcher, username string) (IGetFollowingResult, error) {
|
||||
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
||||
return identity.Username() == username
|
||||
})
|
||||
|
||||
x.Assert(identities.HasExactlyOneItem()).Or(ERROR_USER_NOT_FOUND)
|
||||
identity := identities.First()
|
||||
|
||||
actor := x.Format("%s/u/%s", x.PublicUrl(), identity.Username())
|
||||
|
||||
var orderedItems []string = []string{}
|
||||
return x.NewGetFollowingResult(
|
||||
ACTIVITY_STREAMS, // context
|
||||
x.Format("%s/following", actor), // id
|
||||
ACTIVITY_PUB_ORDERED_COLLECTION, // type
|
||||
int32(len(orderedItems)), // totalItems
|
||||
orderedItems, // orderedItems
|
||||
"", // first
|
||||
), nil
|
||||
}
|
Ładowanie…
Reference in New Issue