github.com/decred/politeia@v1.4.0/politeiad/cmd/legacypoliteia/gitbe/journals.go (about)

     1  // Copyright (c) 2022 The Decred developers
     2  // Use of this source code is governed by an ISC
     3  // license that can be found in the LICENSE file.
     4  
     5  package gitbe
     6  
     7  const (
     8  	// Journal filenames
     9  	CommentsJournalFilename = "comments.journal"
    10  	BallotJournalFilename   = "ballot.journal"
    11  
    12  	// Journal actions
    13  	JournalActionAdd     = "add"     // Add entry
    14  	JournalActionDel     = "del"     // Delete entry
    15  	JournalActionAddLike = "addlike" // Add comment like
    16  )
    17  
    18  // JournalAction prefixes and determines what the next structure is in the JSON
    19  // journal.
    20  //
    21  // Version is used to determine what version of the comment journal structure
    22  // follows.
    23  type JournalAction struct {
    24  	Version string `json:"version"`
    25  	Action  string `json:"action"`
    26  }
    27  
    28  // Comment is the journal entry for a JournalActionAdd action.
    29  //
    30  // Signature is the client signature of the Token+ParentID+Comment.
    31  //
    32  // Receipt is the server signature of the client signature.
    33  type Comment struct {
    34  	Token     string `json:"token"`     // Censorship token
    35  	ParentID  string `json:"parentid"`  // Parent comment ID
    36  	Comment   string `json:"comment"`   // Comment text
    37  	Signature string `json:"signature"` // Client signature
    38  	PublicKey string `json:"publickey"` // Client public key
    39  	CommentID string `json:"commentid"` // Comment ID
    40  	Receipt   string `json:"receipt"`   // Server receipt
    41  	Timestamp int64  `json:"timestamp"` // Received UNIX timestamp
    42  
    43  	// The following fields exist but will always be their zero value. This
    44  	// is the result of the initial implementation including these fields in
    45  	// error.
    46  	TotalVotes  uint64 `json:"totalvotes"`  // Total number of up/down votes
    47  	ResultVotes int64  `json:"resultvotes"` // Vote score
    48  	Censored    bool   `json:"censored"`    // Has this comment been censored
    49  }
    50  
    51  // CensorComment is a journal entry for a JournalActionDel action.
    52  //
    53  // Signature is the admin signature of the Token+CommentID+Reason.
    54  //
    55  // Receipt is the server signature of the admin signature.
    56  type CensorComment struct {
    57  	Token     string `json:"token"`     // Censorship token
    58  	CommentID string `json:"commentid"` // Comment ID
    59  	Reason    string `json:"reason"`    // Reason comment was censored
    60  	Signature string `json:"signature"` // Admin signature
    61  	PublicKey string `json:"publickey"` // Admin public key
    62  
    63  	// Generated by the server
    64  	Receipt   string `json:"receipt"`   // Server receipt
    65  	Timestamp int64  `json:"timestamp"` // Received UNIX timestamp
    66  }
    67  
    68  // LikeComment is the journal entry for a JournalActionAddLike action.
    69  //
    70  // Signature is the client signature of the Token+CommentID+Action.
    71  //
    72  // Receipt is the server signature of the client signature.
    73  type LikeComment struct {
    74  	Token     string `json:"token"`     // Censorship token
    75  	CommentID string `json:"commentid"` // Comment ID
    76  	Action    string `json:"action"`    // Up or downvote (1, -1)
    77  	Signature string `json:"signature"` // Client signature
    78  	PublicKey string `json:"publickey"` // Client public key
    79  
    80  	// Generated by the server
    81  	Receipt   string `json:"receipt"`   // Server receipt
    82  	Timestamp int64  `json:"timestamp"` // Received UNIX timestamp
    83  }
    84  
    85  // CastVoteJournal represents a ballot journal entry.
    86  type CastVoteJournal struct {
    87  	CastVote CastVote `json:"castvote"`
    88  	Receipt  string   `json:"receipt"` // Server receipt
    89  }
    90  
    91  // CastVote is a signed vote.
    92  //
    93  // Signature is the signature of the Token+Ticket+VoteBit.
    94  type CastVote struct {
    95  	Token     string `json:"token"`
    96  	Ticket    string `json:"ticket"`
    97  	VoteBit   string `json:"votebit"`
    98  	Signature string `json:"signature"`
    99  }