1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00

Provide space add/remove event notifications

This commit is contained in:
sauls8t 2018-02-22 18:13:56 +00:00
parent c705e8c299
commit 8d4c6a19ee
2 changed files with 12 additions and 1 deletions

View file

@ -25,6 +25,10 @@ const (
TypeRemoveUser Type = "USER_DELETE" TypeRemoveUser Type = "USER_DELETE"
// TypeAddDocument for when document created // TypeAddDocument for when document created
TypeAddDocument Type = "DOCUMENT_ADD" TypeAddDocument Type = "DOCUMENT_ADD"
// TypeSystemLicenseChange for when adin updates license // TypeSystemLicenseChange for when global admin user updates license
TypeSystemLicenseChange Type = "LICENSE_CHANGE" TypeSystemLicenseChange Type = "LICENSE_CHANGE"
// TypeAddSpace for when space created
TypeAddSpace Type = "SPACE_ADD"
// TypeRemoveSpace for when space removed
TypeRemoveSpace Type = "SPACE_REMOVE"
) )

View file

@ -22,6 +22,7 @@ import (
"strings" "strings"
"github.com/documize/community/core/env" "github.com/documize/community/core/env"
"github.com/documize/community/core/event"
"github.com/documize/community/core/request" "github.com/documize/community/core/request"
"github.com/documize/community/core/response" "github.com/documize/community/core/response"
"github.com/documize/community/core/secrets" "github.com/documize/community/core/secrets"
@ -295,6 +296,8 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
ctx.Transaction.Commit() ctx.Transaction.Commit()
} }
event.Handler().Publish(string(event.TypeAddSpace))
response.WriteJSON(w, sp) response.WriteJSON(w, sp)
} }
@ -510,6 +513,8 @@ func (h *Handler) Remove(w http.ResponseWriter, r *http.Request) {
h.Store.Audit.Record(ctx, audit.EventTypeSpaceDelete) h.Store.Audit.Record(ctx, audit.EventTypeSpaceDelete)
event.Handler().Publish(string(event.TypeRemoveSpace))
response.WriteEmpty(w) response.WriteEmpty(w)
} }
@ -596,6 +601,8 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
h.Store.Audit.Record(ctx, audit.EventTypeSpaceDelete) h.Store.Audit.Record(ctx, audit.EventTypeSpaceDelete)
event.Handler().Publish(string(event.TypeRemoveSpace))
response.WriteEmpty(w) response.WriteEmpty(w)
} }