#83: accept boolean public field in create API (false->unlisted, true->public)
This commit is contained in:
@@ -30,6 +30,8 @@ type Paste struct {
|
||||
BurnAfterRead bool `json:"burn_after_read,omitempty"`
|
||||
BurnAfterReads *int `json:"burn_after_reads,omitempty"` // #49: readable N times (default 1)
|
||||
Visibility string `json:"visibility"`
|
||||
// #83: accept "public": true/false as an alias for visibility.
|
||||
Public *bool `json:"public,omitempty"`
|
||||
CanID *string `json:"can_id,omitempty"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
DeletedAt *int64 `json:"deleted_at,omitempty"`
|
||||
@@ -210,6 +212,14 @@ func (s *Store) CreatePaste(p *Paste) (*Paste, error) {
|
||||
}
|
||||
|
||||
visibility := p.Visibility
|
||||
// #83: "public": false -> unlisted, true -> public; overrides string field
|
||||
if p.Public != nil {
|
||||
if *p.Public {
|
||||
visibility = "public"
|
||||
} else {
|
||||
visibility = "unlisted"
|
||||
}
|
||||
}
|
||||
if visibility == "" {
|
||||
visibility = "public"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user