social source realm
1
20
func AddReaction
crossing Action1func AddReaction(cur realm, userPostsAddr address, threadid, postid PostID, reaction Reaction) boolAdd the reaction by the caller to the post of userPostsAddr, where threadid is the ID returned by the original call to PostMessage. If postid == threadid then add the reaction to a top-level post for the threadid, otherwise add the reaction to the postid "sub reply". (This function's arguments are similar to PostReply.) The caller must already be registered with /r/gnoland/users/v1 Register. Return a boolean indicating whether the userAddr was added. See Post.addReaction.
func GetHomePostsCount
ActionGet the number of posts which GetJsonHomePosts will return. The result is something like "(12 int)". This returns the current count of the home posts (without need to pay gas). To include the latest followed posts, call RefreshHomePosts.
func GetJsonFollowers
ActionGet the UserPosts for the user with the given address, and return the list of followers. If the user address is not found, return "". Limit the response to entries from startIndex up to (not including) endIndex. The response is a JSON string.
func GetJsonFollowing
ActionGet the UserPosts for the user with the given address, and return the list of other users that this user is following. If the user address is not found, return "". Limit the response to entries from startIndex up to (not including) endIndex. The response is a JSON string.
func GetJsonHomePosts
ActionGet home posts for a user, which are the user's top-level posts plus all posts of all users being followed. Limit the response to posts from startIndex up to (not including) endIndex within the home posts. If you just want the total count, use GetHomePostsCount. The response is a JSON string. This returns the current state of the home posts (without need to pay gas). To include the latest posts, call RefreshHomePosts.
func GetJsonTopPostsByID
ActionFor each address/PostID in addrAndIDs, get the thread post. The Post ID must be for a a top-level thread (not a reply; to get reply posts, use GetThreadPosts). If the Post ID is not found, set the result for that Post ID to {}. The response is a JSON string.
func GetJsonUserByAddress
ActionCall users.ResolveAddress and return the result as JSON, or "" if not found. (This is a temporary utility until gno.land supports returning structured data directly.)
func GetJsonUserByName
ActionCall users.ResolveName and return the result as JSON, or "" if not found. (This is a temporary utility until gno.land supports returning structured data directly.)
func GetJsonUserPostsInfo
ActionGet the UserPosts info for the user with the given address, including url, n_threads, n_followers and n_following. If the user address is not found, return "". The name of this function has "Info" because it just returns the number of items, not the items themselves. To get the items, see GetJsonFollowers, etc. The response is a JSON string.
func GetThreadPosts
Action1func GetThreadPosts(userPostsAddr address, threadID int, replyID int, startIndex int, endIndex int) stringGet posts in a thread for a user. A thread is the sequence of posts without replies. While each post has an an arbitrary id, it also has an index within the thread starting from 0. Limit the response to posts from startIndex up to (not including) endIndex within the thread. If you just want the total count, set startIndex and endIndex to 0 and see the response "n_threads". If threadID is 0 then return the user's top-level posts. (Like render args "user".) If threadID is X and replyID is 0, then return the posts (without replies) in that thread. (Like render args "user/2".) If threadID is X and replyID is Y, then return the posts in the thread starting with replyID. (Like render args "user/2/5".) The response includes reposts by this user (only if threadID is 0), but not messages of other users that are being followed. (See GetJsonHomePosts.) The response is a JSON string.
func ListJsonUsersByPrefix
ActionGet a list of user names starting from the given prefix. Limit the number of results to maxResults. The response is a JSON string.
func ListUsersByPrefix
ActionGet a list of user names starting from the given prefix. Limit the number of results to maxResults.
func RefreshHomePosts
crossing ActionUpdate the home posts by scanning all posts from all followed users and adding the followed posts since the last call to RefreshHomePosts (or since started following the user). Return the new count of home posts. The result is something like "(12 int)".
func RemoveReaction
crossing Action1func RemoveReaction(cur realm, userPostsAddr address, threadid, postid PostID, reaction Reaction) boolRemove the reaction by the caller to the post of userPostsAddr, where threadid is the ID returned by the original call to PostMessage. If postid == threadid then remove the reaction from a top-level post for the threadid, otherwise remove the reaction from the postid "sub reply". (This function's arguments are similar to PostReply.) The caller must already be registered with /r/gnoland/users/v1 Register. Return a boolean indicating whether the userAddr was removed. See Post.removeReaction.
func Render
func Unfollow
crossing ActionUpdate the caller to unfollow the user with followedAddr. See UserPosts.unfollow.
func Follow
crossing ActionUpdate the caller to follow the user with followedAddr. See UserPosts.follow.
func PostMessage
crossing ActionPost a message to the caller's main user posts. The caller must already be registered with /r/gnoland/users/v1 Register. Return the "thread ID" of the new post. (This is similar to boards.CreateThread, but no message title)
func PostReply
crossing Action1func PostReply(cur realm, userPostsAddr address, threadid, postid PostID, body string) PostIDPost a reply to the user posts of userPostsAddr where threadid is the ID returned by the original call to PostMessage. If postid == threadid then create another top-level post for the threadid, otherwise post a reply to the postid "sub reply". The caller must already be registered with /r/gnoland/users/v1 Register. Return the new post ID. (This is similar to boards.CreateReply.)
func RepostThread
crossing ActionRepost the message from the user posts of userPostsAddr where threadid is the ID returned by the original call to PostMessage. This must be a top-level thread (not a reply). Return the new post ID. (This is similar to boards.CreateRepost.)
6
type FollowingInfo
structtype Post
struct 1type Post struct {
2 userPosts *UserPosts
3 id PostID
4 creator address
5 body string
6 replies bptree.BPTree // PostID -> *Post
7 repliesAll bptree.BPTree // PostID -> *Post (all replies, for top-level posts)
8 reposts bptree.BPTree // UserPosts user address -> PostID
9 threadID PostID // original PostID
10 parentID PostID // parent PostID (if reply or repost)
11 repostUser address // UserPosts user address of original post (if repost)
12 reactions *bptree.BPTree // Reaction -> *bptree.BPTree of address -> "" (Use the bptree.BPTree keys as the "set" of addresses)
13 createdAt time.Time
14}A Post is a "thread" or a "reply" depending on context. A thread is a Post of a UserPosts that holds other replies. This is similar to boards.Post except that this doesn't have a title.
Methods on Post
func GetGnodFormURL
method on Postfunc GetPostID
method on Postfunc GetReactionCount
method on PostReturn the count of reactions for the reaction.
func GetReply
method on Postfunc GetReplyFormURL
method on Postfunc GetRepostFormURL
method on Postfunc GetSummary
method on Postfunc GetURL
method on Postfunc IsThread
method on Postfunc MarshalJSON
method on PostMarshalJSON implements the json.Marshaler interface.
func RenderInner
method on Postrender reply and link to context thread
func RenderPost
method on Postfunc RenderSummary
method on Posttype PostID
identNOTE: a PostID is relative to the userPosts.
type Reaction
identReaction is for the "enum" of ways to react to a post
type UserAndPostID
structtype UserPosts
struct1type UserPosts struct {
2 url string
3 userAddr address
4 threads bptree.BPTree // PostID -> *Post
5 homePosts bptree.BPTree // PostID -> *Post. Includes this user's threads posts plus posts of users being followed.
6 lastRefreshId PostID // Updated by refreshHomePosts
7 followers bptree.BPTree // address -> ""
8 following bptree.BPTree // address -> *FollowingInfo
9}UserPosts is similar to boards.Board where each user has their own "board" for posts which come from the user. The list of posts is identified by the user's address . A user's "home feed" may contain other posts (from followed users, etc.) but this only has the top-level posts from the user (not replies to other user's posts).
Methods on UserPosts
func GetFollowFormURL
method on UserPostsfunc GetPostFormURL
method on UserPostsfunc GetRefreshFormURL
method on UserPostsfunc GetThread
method on UserPostsfunc GetURLFromThreadAndReplyID
method on UserPostsfunc GetUnfollowFormURL
method on UserPostsfunc MarshalJSON
method on UserPostsMarshalJSON implements the json.Marshaler interface.
func RenderFollowers
method on UserPostsfunc RenderFollowing
method on UserPostsfunc RenderUserPosts
method on UserPostsRenders the userPosts for display suitable as plaintext in console. This is suitable for demonstration or tests, but not for prod.
10
- bytes stdlib
- gno.land/p/moul/txlink/v0 package
- gno.land/p/nt/bptree/v0 package
- gno.land/p/nt/markdown/sanitize/v0 package
- gno.land/p/nt/ufmt/v0 package
- gno.land/r/sys/users realm
- sort stdlib
- strconv stdlib
- strings stdlib
- time stdlib