Back to godoc.org
github.com/documize/community / domain

package domain

v3.2.0+incompatible
Latest Go to latest
Published: Aug 29, 2019 | License: AGPL-3.0 | Module: github.com/documize/community

Overview

Package domain defines data structures for moving data between services.

Index

Constants

const (
	// CommunityEdition is AGPL licensed open core of product.
	CommunityEdition Edition = "Community"

	// EnterpriseEdition is proprietary closed-source product.
	EnterpriseEdition Edition = "Enterprise"

	// PackageEssentials provides core capabilities.
	PackageEssentials Package = "Essentials"

	// PackageAdvanced provides analytics, reporting,
	// content lifecycle, content verisoning, and audit logs.
	PackageAdvanced Package = "Advanced"

	// PackagePremium provides actions, feedback capture,
	// approvals workflow, secure external sharing.
	PackagePremium Package = "Premium"

	// PackageDataCenter provides multi-tenanting
	// and a bunch of professional services.
	PackageDataCenter Package = "Data Center"

	// PlanCloud represents *.documize.com hosting.
	PlanCloud Plan = "Cloud"

	// PlanSelfHost represents privately hosted Documize instance.
	PlanSelfHost Plan = "Self-host"

	// Seats0 is 0 users.
	Seats0 Seats = 0

	// Seats1 is 10 users.
	Seats1 Seats = 10

	// Seats2 is 25 users.
	Seats2 Seats = 25

	//Seats3 is 50 users.
	Seats3 Seats = 50

	// Seats4 is 100 users.
	Seats4 Seats = 100

	//Seats5 is 250 users.
	Seats5 Seats = 250

	// Seats6 is unlimited.
	Seats6 Seats = 9999
)
const DocumizeContextKey key = "documize context key"

DocumizeContextKey prevents key name collisions.

func SubscriptionAsXML

func SubscriptionAsXML(j SubscriptionData) (b []byte, err error)

SubscriptionAsXML returns subscription data as XML document:

<DocumizeLicense>

<Key>some key</Key>
<Signature>some signature</Signature>

</DocumizeLicense>

XML document is empty in case of error.

type Edition

type Edition string

Edition is either Community or Enterprise.

type Package

type Package string

Package controls feature-set within edition.

type Plan

type Plan string

Plan tells us if instance if self-hosted or Documize SaaS/Cloud.

type Product

type Product struct {
	Edition  Edition
	Title    string
	Version  string
	Major    string
	Minor    string
	Patch    string
	Revision string

	// UserCount is number of users within Documize instance by tenant.
	UserCount map[string]int
}

Product provides product meta information and handles subscription validation for Enterprise edition.

func (*Product) IsValid

func (p *Product) IsValid(ctx RequestContext) bool

IsValid returns if subscription is valid using RequestContext.

type RequestContext

type RequestContext struct {
	AllowAnonymousAccess bool
	Authenticated        bool
	Guest                bool
	UserID               string
	OrgID                string
	OrgName              string
	SSL                  bool
	AppURL               string // e.g. https://{url}.documize.com
	Subdomain            string
	ClientIP             string
	Expires              time.Time
	Fullname             string
	Transaction          *sqlx.Tx
	Administrator        bool
	Analytics            bool
	Active               bool
	Editor               bool
	GlobalAdmin          bool
	ViewUsers            bool
	Subscription         Subscription
}

RequestContext provides per request scoped values required for HTTP handlers.

func GetRequestContext

func GetRequestContext(r *http.Request) (ctx RequestContext)

GetRequestContext returns RequestContext from context.Context

func (*RequestContext) GetAppURL

func (c *RequestContext) GetAppURL(endpoint string) string

GetAppURL returns full HTTP url for the app

type Seats

type Seats int

Seats represents number of users.

type Subscription

type Subscription struct {
	ID      string    `json:"id"`
	Name    string    `json:"name"`
	Email   string    `json:"email"`
	Edition Edition   `json:"edition"`
	Plan    Plan      `json:"plan"`
	Start   time.Time `json:"start"`
	End     time.Time `json:"end"`
	Seats   Seats     `json:"seats"`
	Trial   bool      `json:"trial"`
	Price   uint64    `json:"price"`
	// Derived fields
	ActiveUsers int `json:"activeUsers"`
	Status      int `json:"status"`
}

Subscription data for customer.

func DecodeSubscription

func DecodeSubscription(sd SubscriptionData) (sub Subscription, err error)

DecodeSubscription returns Documize issued product licensing information.

func (*Subscription) IsEmpty

func (s *Subscription) IsEmpty() bool

IsEmpty determines if we have a license.

type SubscriptionData

type SubscriptionData struct {
	Key       string `json:"key"`
	Signature string `json:"signature"`
}

SubscriptionData holds encrypted data and is unpacked into Subscription.

type SubscriptionUserAccount

type SubscriptionUserAccount struct {
	OrgID string `json:"orgId"`
	Users int    `json:"users"`
}

SubscriptionUserAccount states number of active users by tenant.

type SubscriptionXML

type SubscriptionXML struct {
	XMLName   xml.Name `xml:"Documize"`
	Key       string
	Signature string
}

SubscriptionXML represents subscription data as XML document.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier