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

reviews_reads.gno

1.56 Kb · 19 lines
 1package memba_weighted_host
 2
 3import "strconv"
 4
 5func (h *Host) reviewsConfigJSON() string {
 6	if h.reviewsPolicy == nil {
 7		return ""
 8	}
 9	return `,"reviewsPolicy":{"target":` + quoteJSON(h.reviewsPolicy.Target()) + `,"successor":` + quoteJSON(string(h.reviewsPolicy.Successor())) + `,"moderationCategory":"routine","returnStagesOnly":true,"invalidatesOtherProposals":true}`
10}
11func reviewsItemJSON(i ReviewsItem) string {
12	return `{"id":` + quoteJSON(strconv.FormatUint(i.ID, 10)) + `,"review":` + strconv.FormatBool(i.Review) + `,"parentId":` + quoteJSON(strconv.FormatUint(i.ParentID, 10)) + `,"subject":` + quoteJSON(i.Subject) + `,"author":` + quoteJSON(string(i.Author)) + `,"rating":` + quoteJSON(strconv.Itoa(i.Rating)) + `,"bodyHash":` + quoteJSON(i.BodyHash) + `,"createdAtHeight":` + quoteJSON(strconv.FormatInt(i.CreatedAt, 10)) + `,"editedAtHeight":` + quoteJSON(strconv.FormatInt(i.EditedAt, 10)) + `,"hidden":` + strconv.FormatBool(i.Hidden) + `,"deleted":` + strconv.FormatBool(i.Deleted) + `,"flagged":` + strconv.FormatBool(i.Flagged) + `}`
13}
14func reviewsStateJSON(s ReviewsState) string {
15	return `{"moderator":` + quoteJSON(string(s.Moderator)) + `,"pendingModerator":` + quoteJSON(string(s.PendingModerator)) + `,"item":` + reviewsItemJSON(s.Item) + `}`
16}
17func reviewsActionJSON(a ReviewsAction, s ReviewsState) string {
18	return `{"type":"reviews","target":` + quoteJSON(a.Target()) + `,"operation":` + quoteJSON(string(a.Kind())) + `,"id":` + quoteJSON(strconv.FormatUint(a.ID(), 10)) + `,"recipient":` + quoteJSON(string(a.Recipient())) + `,"before":` + reviewsStateJSON(s) + `}`
19}