Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

social source realm

Constants 1

Functions 20

func AddReaction

crossing Action
1func AddReaction(cur realm, userPostsAddr address, threadid, postid PostID, reaction Reaction) bool
source

Add 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

Action
1func GetHomePostsCount(userPostsAddr address) int
source

Get 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

Action
1func GetJsonFollowers(address address, startIndex int, endIndex int) string
source

Get 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

Action
1func GetJsonFollowing(address address, startIndex int, endIndex int) string
source

Get 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

Action
1func GetJsonHomePosts(userPostsAddr address, startIndex int, endIndex int) string
source

Get 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

Action
1func GetJsonTopPostsByID(addrAndIDs []UserAndPostID) string
source

For 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

Action
1func GetJsonUserByAddress(addr address) string
source

Call 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

Action
1func GetJsonUserByName(name string) string
source

Call 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

Action
1func GetJsonUserPostsInfo(address address) string
source

Get 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

Action
1func GetThreadPosts(userPostsAddr address, threadID int, replyID int, startIndex int, endIndex int) string
source

Get 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

Action
1func ListJsonUsersByPrefix(prefix string, maxResults int) string
source

Get 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

Action
1func ListUsersByPrefix(prefix string, maxResults int) []string
source

Get a list of user names starting from the given prefix. Limit the number of results to maxResults.

func RefreshHomePosts

crossing Action
1func RefreshHomePosts(_ realm, userPostsAddr address) int
source

Update 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 Action
1func RemoveReaction(cur realm, userPostsAddr address, threadid, postid PostID, reaction Reaction) bool
source

Remove 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 Unfollow

crossing Action
1func Unfollow(cur realm, followedAddr address)
source

Update the caller to unfollow the user with followedAddr. See UserPosts.unfollow.

func Follow

crossing Action
1func Follow(cur realm, followedAddr address) PostID
source

Update the caller to follow the user with followedAddr. See UserPosts.follow.

func PostMessage

crossing Action
1func PostMessage(cur realm, body string) PostID
source

Post 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 Action
1func PostReply(cur realm, userPostsAddr address, threadid, postid PostID, body string) PostID
source

Post 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 Action
1func RepostThread(cur realm, userPostsAddr address, threadid PostID, comment string) PostID
source

Repost 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.)

Types 6

type FollowingInfo

struct
1type FollowingInfo struct {
2	startedFollowingAt time.Time
3	startedPostsCtr    PostID
4}
source

type 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}
source

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 GetPostID

method on Post
1func (post *Post) GetPostID() PostID
source

func GetReactionCount

method on Post
1func (post *Post) GetReactionCount(reaction Reaction) int
source

Return the count of reactions for the reaction.

func GetReply

method on Post
1func (post *Post) GetReply(pid PostID) *Post
source

func GetURL

method on Post
1func (post *Post) GetURL() string
source

func IsThread

method on Post
1func (post *Post) IsThread() bool
source

func MarshalJSON

method on Post
1func (post *Post) MarshalJSON() ([]byte, error)
source

MarshalJSON implements the json.Marshaler interface.

func RenderInner

method on Post
1func (post *Post) RenderInner() string
source

render reply and link to context thread

func RenderPost

method on Post
1func (post *Post) RenderPost(indent string, levels int) string
source

type PostID

ident
1type PostID uint64
source

NOTE: a PostID is relative to the userPosts.

Methods on PostID

func String

method on PostID
1func (pid PostID) String() string
source

type Reaction

ident
1type Reaction int
source

Reaction is for the "enum" of ways to react to a post

type UserPosts

struct
1type 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}
source

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 GetPostFormURL

method on UserPosts
1func (userPosts *UserPosts) GetPostFormURL() string
source

func GetThread

method on UserPosts
1func (userPosts *UserPosts) GetThread(pid PostID) *Post
source

func GetUnfollowFormURL

method on UserPosts
1func (userPosts *UserPosts) GetUnfollowFormURL(followedAddr address) string
source

func MarshalJSON

method on UserPosts
1func (userPosts *UserPosts) MarshalJSON() ([]byte, error)
source

MarshalJSON implements the json.Marshaler interface.

func RenderUserPosts

method on UserPosts
1func (userPosts *UserPosts) RenderUserPosts(includeFollowed bool) string
source

Renders the userPosts for display suitable as plaintext in console. This is suitable for demonstration or tests, but not for prod.

Imports 10

Source Files 7