Commit ff91ef92 authored by putro's avatar putro

added newsletters in types

parent db2850a9
...@@ -378,6 +378,7 @@ const ( ...@@ -378,6 +378,7 @@ const (
const ( const (
ResourceTypeEmail = "email" ResourceTypeEmail = "email"
ResourceTypeMailingList = "list" ResourceTypeMailingList = "list"
ResourceTypeNewsletter = "newsletter"
ResourceTypeWebsite = "web" ResourceTypeWebsite = "web"
ResourceTypeDomain = "domain" ResourceTypeDomain = "domain"
ResourceTypeDAV = "dav" ResourceTypeDAV = "dav"
...@@ -395,7 +396,7 @@ const ( ...@@ -395,7 +396,7 @@ const (
// Returns true if the given status is valid for the given resource type. // Returns true if the given status is valid for the given resource type.
func isValidStatusByResourceType(rtype, rstatus string) bool { func isValidStatusByResourceType(rtype, rstatus string) bool {
switch rtype { switch rtype {
case ResourceTypeEmail, ResourceTypeMailingList: case ResourceTypeEmail, ResourceTypeMailingList, ResourceTypeNewsletter:
switch rstatus { switch rstatus {
case ResourceStatusActive, ResourceStatusInactive, ResourceStatusReadonly: case ResourceStatusActive, ResourceStatusInactive, ResourceStatusReadonly:
return true return true
...@@ -478,11 +479,12 @@ type Resource struct { ...@@ -478,11 +479,12 @@ type Resource struct {
// Details about the specific type (only one of these can be // Details about the specific type (only one of these can be
// set, depending on the value of 'type'). // set, depending on the value of 'type').
Email *Email `json:"email,omitempty"` Email *Email `json:"email,omitempty"`
List *MailingList `json:"list,omitempty"` List *MailingList `json:"list,omitempty"`
Website *Website `json:"website,omitempty"` Newsletter *Newsletter `json:"newsletter,omitempty"`
DAV *WebDAV `json:"dav,omitempty"` Website *Website `json:"website,omitempty"`
Database *Database `json:"database,omitempty"` DAV *WebDAV `json:"dav,omitempty"`
Database *Database `json:"database,omitempty"`
} }
// Copy the resource (makes a deep copy). // Copy the resource (makes a deep copy).
...@@ -498,6 +500,9 @@ func (r *Resource) Copy() *Resource { ...@@ -498,6 +500,9 @@ func (r *Resource) Copy() *Resource {
case r.List != nil: case r.List != nil:
l := *r.List l := *r.List
rr.List = &l rr.List = &l
case r.Newsletter != nil:
l := *r.Newsletter
rr.Newsletter = &l
case r.DAV != nil: case r.DAV != nil:
d := *r.DAV d := *r.DAV
rr.DAV = &d rr.DAV = &d
...@@ -537,6 +542,13 @@ type MailingList struct { ...@@ -537,6 +542,13 @@ type MailingList struct {
Public bool `json:"public"` Public bool `json:"public"`
} }
// Newsletter resource attributes.
type Newsletter struct {
Admins []string `json:"admins"`
Public bool `json:"public"`
}
// WebDAV represents a hosting account. // WebDAV represents a hosting account.
type WebDAV struct { type WebDAV struct {
UID int `json:"uid"` UID int `json:"uid"`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment