Skip to content

Commit c94fd9c

Browse files
committed
Enforce non-draft mode lifecycle for CE
Closes #151 by enforcing non-draft mode settings for Community Edition.
1 parent fb193ce commit c94fd9c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

core/env/runtime.go

+7
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ const (
5050
// DBVariantPostgreSQL is PostgreSQL
5151
DBVariantPostgreSQL DbVariant = "PostgreSQL"
5252
)
53+
54+
const (
55+
// CommunityEdition is AGPL product variant
56+
CommunityEdition = "Community"
57+
// EnterpriseEdition is commercial licensed product variant
58+
EnterpriseEdition = "Enterprise"
59+
)

domain/conversion/conversion.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/documize/community/model/doc"
3636
"github.com/documize/community/model/page"
3737
"github.com/documize/community/model/space"
38+
"github.com/documize/community/model/workflow"
3839
uuid "github.com/nu7hatch/gouuid"
3940
"github.com/pkg/errors"
4041
)
@@ -174,8 +175,12 @@ func processDocument(ctx domain.RequestContext, r *env.Runtime, store *domain.St
174175
document.UserID = ctx.UserID
175176
documentID := uniqueid.Generate()
176177
document.RefID = documentID
177-
document.Lifecycle = sp.Lifecycle
178178

179+
if r.Product.Edition == env.CommunityEdition {
180+
document.Lifecycle = workflow.LifecycleLive
181+
} else {
182+
document.Lifecycle = sp.Lifecycle
183+
}
179184
err = store.Document.Add(ctx, document)
180185
if err != nil {
181186
ctx.Transaction.Rollback()

domain/template/endpoint.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
316316
d.LabelID = folderID
317317
d.UserID = ctx.UserID
318318
d.Title = docTitle
319-
d.Lifecycle = sp.Lifecycle
319+
320+
if h.Runtime.Product.Edition == env.CommunityEdition {
321+
d.Lifecycle = workflow.LifecycleLive
322+
} else {
323+
d.Lifecycle = sp.Lifecycle
324+
}
320325

321326
err = h.Store.Document.Add(ctx, d)
322327
if err != nil {

0 commit comments

Comments
 (0)