mirror of
https://github.com/documize/community.git
synced 2025-07-19 05:09:42 +02:00
Continued MySQL/PostgreSQL store provider refactoring
Refactored, renamed, removed storage related code. Basic smoke test passed for PostgreSQL whilst fully working on MySQL variants as per usual.
This commit is contained in:
parent
b455e5eaf5
commit
97beb3f4d3
81 changed files with 1454 additions and 1497 deletions
|
@ -22,7 +22,7 @@ import (
|
|||
"github.com/documize/community/core/api/convert/html"
|
||||
"github.com/documize/community/core/api/convert/md"
|
||||
api "github.com/documize/community/core/convapi"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/glick"
|
||||
)
|
||||
|
||||
|
@ -49,7 +49,7 @@ var Lib *glick.Library
|
|||
|
||||
// Setup configures the global library at Lib,
|
||||
// largely based on the "config.json" file. It should be called only once.
|
||||
func Setup(s *domain.Store) error {
|
||||
func Setup(s *store.Store) error {
|
||||
if insecure == "true" {
|
||||
glick.InsecureSkipVerifyTLS = true
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ ALTER TABLE dmz_doc
|
|||
CHANGE `protection` `c_protection` INT NOT NULL DEFAULT 0,
|
||||
CHANGE `approval` `c_approval` INT NOT NULL DEFAULT 0,
|
||||
CHANGE `lifecycle` `c_lifecycle` INT NOT NULL DEFAULT 1,
|
||||
CHANGE `versioned` `c_versioned` INT NOT NULL DEFAULT 0,
|
||||
CHANGE `versioned` `c_versioned` BOOL NOT NULL DEFAULT 0,
|
||||
CHANGE `versionid` `c_versionid` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
CHANGE `versionorder` `c_versionorder` INT NOT NULL DEFAULT 0,
|
||||
CHANGE `groupid` `c_groupid` CHAR(16) NOT NULL DEFAULT '',
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
DROP TABLE IF EXISTS dmz_action;
|
||||
CREATE TABLE dmz_action (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_requestorid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_requestorid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_actiontype int NOT NULL DEFAULT '0',
|
||||
c_note varchar(2000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_requested timestamp NULL DEFAULT NULL,
|
||||
c_due timestamp NULL DEFAULT NULL,
|
||||
c_completed timestamp NULL DEFAULT NULL,
|
||||
c_iscomplete bool NOT NULL DEFAULT '0',
|
||||
c_reftype char(1) COLLATE ucs_basic NOT NULL DEFAULT 'D',
|
||||
c_reftypeid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_reftype varchar(1) COLLATE ucs_basic NOT NULL DEFAULT 'D',
|
||||
c_reftypeid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id)
|
||||
|
@ -31,8 +31,8 @@ CREATE INDEX idx_action_4 ON dmz_action (c_requestorid);
|
|||
DROP TABLE IF EXISTS dmz_audit_log;
|
||||
CREATE TABLE dmz_audit_log (
|
||||
id bigserial NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_eventtype varchar(100) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_ip varchar(39) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
@ -45,9 +45,9 @@ CREATE INDEX idx_audit_log_3 ON dmz_audit_log (c_eventtype);
|
|||
DROP TABLE IF EXISTS dmz_category;
|
||||
CREATE TABLE dmz_category (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_name varchar(50) COLLATE ucs_basic NOT NULL,
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
@ -60,11 +60,11 @@ CREATE INDEX idx_category_3 ON dmz_category (c_orgid,c_spaceid);
|
|||
DROP TABLE IF EXISTS dmz_category_member;
|
||||
CREATE TABLE dmz_category_member (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_categoryid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_categoryid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (id)
|
||||
|
@ -75,7 +75,7 @@ CREATE INDEX idx_category_member_3 ON dmz_category_member (c_orgid,c_spaceid);
|
|||
|
||||
DROP TABLE IF EXISTS dmz_config;
|
||||
CREATE TABLE dmz_config (
|
||||
c_key char(200) COLLATE ucs_basic NOT NULL,
|
||||
c_key varchar(200) COLLATE ucs_basic NOT NULL,
|
||||
c_config json DEFAULT NULL,
|
||||
UNIQUE (c_key)
|
||||
);
|
||||
|
@ -83,11 +83,11 @@ CREATE TABLE dmz_config (
|
|||
DROP TABLE IF EXISTS dmz_doc;
|
||||
CREATE TABLE dmz_doc (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_job char(36) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_job varchar(36) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_location varchar(2000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_name varchar(2000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_desc varchar(2000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
|
@ -97,10 +97,10 @@ CREATE TABLE dmz_doc (
|
|||
c_protection int NOT NULL DEFAULT '0',
|
||||
c_approval int NOT NULL DEFAULT '0',
|
||||
c_lifecycle int NOT NULL DEFAULT '1',
|
||||
c_versioned int NOT NULL DEFAULT '0',
|
||||
c_versioned bool NOT NULL DEFAULT '0',
|
||||
c_versionid varchar(100) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_versionorder int NOT NULL DEFAULT '0',
|
||||
c_groupid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_groupid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (c_refid)
|
||||
|
@ -112,14 +112,14 @@ CREATE INDEX idx_doc_3 ON dmz_doc (c_spaceid);
|
|||
DROP TABLE IF EXISTS dmz_doc_attachment;
|
||||
CREATE TABLE dmz_doc_attachment (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_job char(36) COLLATE ucs_basic NOT NULL,
|
||||
c_fileid char(10) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_job varchar(36) COLLATE ucs_basic NOT NULL,
|
||||
c_fileid varchar(10) COLLATE ucs_basic NOT NULL,
|
||||
c_filename varchar(255) COLLATE ucs_basic NOT NULL,
|
||||
c_data BYTEA,
|
||||
c_extension char(6) COLLATE ucs_basic NOT NULL,
|
||||
c_extension varchar(6) COLLATE ucs_basic NOT NULL,
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (c_refid)
|
||||
|
@ -132,10 +132,10 @@ CREATE INDEX idx_doc_attachment_4 ON dmz_doc_attachment (c_job,c_fileid);
|
|||
DROP TABLE IF EXISTS dmz_doc_comment;
|
||||
CREATE TABLE dmz_doc_comment (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_email varchar(250) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_feedback text COLLATE ucs_basic,
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
@ -146,15 +146,15 @@ CREATE INDEX idx_doc_comment_1 ON dmz_doc_comment (c_refid);
|
|||
DROP TABLE IF EXISTS dmz_doc_link;
|
||||
CREATE TABLE dmz_doc_link (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_sourcedocid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_sourcesectionid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_type char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_targetdocid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_targetid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_sourcedocid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_sourcesectionid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_type varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_targetdocid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_targetid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_externalid varchar(1000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_orphan bool NOT NULL DEFAULT '0',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
@ -165,14 +165,14 @@ CREATE TABLE dmz_doc_link (
|
|||
DROP TABLE IF EXISTS dmz_doc_share;
|
||||
CREATE TABLE dmz_doc_share (
|
||||
id bigserial NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_email varchar(250) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_message varchar(500) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_viewed varchar(500) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_secret varchar(250) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_expires char(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_expires varchar(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_active bool NOT NULL DEFAULT '1',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id)
|
||||
|
@ -181,10 +181,10 @@ CREATE TABLE dmz_doc_share (
|
|||
DROP TABLE IF EXISTS dmz_doc_vote;
|
||||
CREATE TABLE dmz_doc_vote (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_voter char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_voter varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_vote int NOT NULL DEFAULT '0',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
@ -198,8 +198,8 @@ CREATE INDEX idx_doc_vote_4 ON dmz_doc_vote (c_orgid,c_docid);
|
|||
DROP TABLE IF EXISTS dmz_group;
|
||||
CREATE TABLE dmz_group (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_name varchar(50) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_desc varchar(100) COLLATE ucs_basic DEFAULT '',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
@ -212,9 +212,9 @@ CREATE INDEX idx_group_2 ON dmz_group (c_orgid);
|
|||
DROP TABLE IF EXISTS dmz_group_member;
|
||||
CREATE TABLE dmz_group_member (
|
||||
id bigserial NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_groupid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_groupid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
UNIQUE (id)
|
||||
);
|
||||
CREATE INDEX idx_group_member_1 ON dmz_group_member (c_groupid,c_userid);
|
||||
|
@ -223,7 +223,7 @@ CREATE INDEX idx_group_member_2 ON dmz_group_member (c_orgid,c_groupid,c_userid)
|
|||
DROP TABLE IF EXISTS dmz_org;
|
||||
CREATE TABLE dmz_org (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_company varchar(500) COLLATE ucs_basic NOT NULL,
|
||||
c_title varchar(500) COLLATE ucs_basic NOT NULL,
|
||||
c_message varchar(500) COLLATE ucs_basic NOT NULL,
|
||||
|
@ -231,7 +231,7 @@ CREATE TABLE dmz_org (
|
|||
c_service varchar(200) COLLATE ucs_basic NOT NULL DEFAULT 'https://api.documize.com',
|
||||
c_email varchar(500) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_anonaccess bool NOT NULL DEFAULT '0',
|
||||
c_authprovider char(20) COLLATE ucs_basic NOT NULL DEFAULT 'documize',
|
||||
c_authprovider varchar(20) COLLATE ucs_basic NOT NULL DEFAULT 'documize',
|
||||
c_authconfig json DEFAULT NULL,
|
||||
c_maxtags int NOT NULL DEFAULT '3',
|
||||
c_verified bool NOT NULL DEFAULT '0',
|
||||
|
@ -247,13 +247,13 @@ CREATE INDEX idx_org_2 ON dmz_org (c_domain);
|
|||
DROP TABLE IF EXISTS dmz_permission;
|
||||
CREATE TABLE dmz_permission (
|
||||
id bigserial NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_who varchar(30) COLLATE ucs_basic NOT NULL,
|
||||
c_whoid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_whoid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_action varchar(30) COLLATE ucs_basic NOT NULL,
|
||||
c_scope varchar(30) COLLATE ucs_basic NOT NULL,
|
||||
c_location varchar(100) COLLATE ucs_basic NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (id)
|
||||
);
|
||||
|
@ -266,13 +266,13 @@ CREATE INDEX idx_permission_5 ON dmz_permission (c_orgid,c_who,c_location,c_acti
|
|||
DROP TABLE IF EXISTS dmz_pin;
|
||||
CREATE TABLE dmz_pin (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_spaceid char(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_docid char(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_spaceid varchar(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_docid varchar(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_sequence BIGINT NOT NULL DEFAULT '99',
|
||||
c_name char(100) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_name varchar(100) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id)
|
||||
|
@ -282,9 +282,9 @@ CREATE INDEX idx_pin_1 ON dmz_pin (c_userid);
|
|||
DROP TABLE IF EXISTS dmz_search;
|
||||
CREATE TABLE dmz_search (
|
||||
id bigserial NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_itemid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_itemid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_itemtype varchar(10) COLLATE ucs_basic NOT NULL,
|
||||
c_content text COLLATE ucs_basic,
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
@ -297,20 +297,20 @@ CREATE INDEX idx_search_3 ON dmz_search USING GIN (to_tsvector('english', c_cont
|
|||
DROP TABLE IF EXISTS dmz_section;
|
||||
CREATE TABLE dmz_section (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_contenttype char(20) COLLATE ucs_basic NOT NULL DEFAULT 'wysiwyg',
|
||||
c_type char(10) COLLATE ucs_basic NOT NULL DEFAULT 'section',
|
||||
c_templateid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_contenttype varchar(20) COLLATE ucs_basic NOT NULL DEFAULT 'wysiwyg',
|
||||
c_type varchar(10) COLLATE ucs_basic NOT NULL DEFAULT 'section',
|
||||
c_templateid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_level bigint NOT NULL,
|
||||
c_sequence double precision NOT NULL,
|
||||
c_name varchar(2000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_body text COLLATE ucs_basic,
|
||||
c_revisions bigint NOT NULL,
|
||||
c_status int NOT NULL DEFAULT '0',
|
||||
c_relativeid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_relativeid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (c_refid)
|
||||
|
@ -322,10 +322,10 @@ CREATE INDEX idx_section_3 ON dmz_section (c_docid);
|
|||
DROP TABLE IF EXISTS dmz_section_meta;
|
||||
CREATE TABLE dmz_section_meta (
|
||||
id bigserial NOT NULL,
|
||||
c_sectionid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_sectionid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_rawbody BYTEA,
|
||||
c_config json DEFAULT NULL,
|
||||
c_external bool DEFAULT '0',
|
||||
|
@ -341,14 +341,14 @@ CREATE INDEX idx_section_meta_4 ON dmz_section_meta (c_docid);
|
|||
DROP TABLE IF EXISTS dmz_section_revision;
|
||||
CREATE TABLE dmz_section_revision (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_ownerid char(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_sectionid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_contenttype char(20) COLLATE ucs_basic NOT NULL DEFAULT 'wysiwyg',
|
||||
c_type char(10) COLLATE ucs_basic NOT NULL DEFAULT 'section',
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_ownerid varchar(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_sectionid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_contenttype varchar(20) COLLATE ucs_basic NOT NULL DEFAULT 'wysiwyg',
|
||||
c_type varchar(10) COLLATE ucs_basic NOT NULL DEFAULT 'section',
|
||||
c_name varchar(2000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_body text COLLATE ucs_basic,
|
||||
c_rawbody BYTEA,
|
||||
|
@ -365,12 +365,12 @@ CREATE INDEX idx_section_revision_4 ON dmz_section_revision (c_sectionid);
|
|||
DROP TABLE IF EXISTS dmz_section_template;
|
||||
CREATE TABLE dmz_section_template (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid char(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_userid char(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_contenttype char(20) COLLATE ucs_basic NOT NULL DEFAULT 'wysiwyg',
|
||||
c_type char(10) COLLATE ucs_basic NOT NULL DEFAULT 'section',
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid varchar(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_userid varchar(16) COLLATE ucs_basic DEFAULT '',
|
||||
c_contenttype varchar(20) COLLATE ucs_basic NOT NULL DEFAULT 'wysiwyg',
|
||||
c_type varchar(10) COLLATE ucs_basic NOT NULL DEFAULT 'section',
|
||||
c_name varchar(2000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_body text COLLATE ucs_basic,
|
||||
c_desc varchar(2000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
|
@ -388,10 +388,10 @@ CREATE INDEX idx_section_template_2 ON dmz_section_template (c_spaceid);
|
|||
DROP TABLE IF EXISTS dmz_space;
|
||||
CREATE TABLE dmz_space (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_name varchar(300) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_type int NOT NULL DEFAULT '1',
|
||||
c_lifecycle int NOT NULL DEFAULT '1',
|
||||
c_likes varchar(1000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
|
@ -406,7 +406,7 @@ CREATE INDEX idx_space_3 ON dmz_space (c_orgid);
|
|||
DROP TABLE IF EXISTS dmz_user;
|
||||
CREATE TABLE dmz_user (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_firstname varchar(500) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_lastname varchar(500) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_email varchar(500) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
|
@ -416,7 +416,7 @@ CREATE TABLE dmz_user (
|
|||
c_salt varchar(500) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_reset varchar(500) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_active bool NOT NULL DEFAULT '1',
|
||||
c_lastversion char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_lastversion varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
c_revised timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (c_refid)
|
||||
|
@ -427,9 +427,9 @@ CREATE INDEX idx_user_2 ON dmz_user (c_email);
|
|||
DROP TABLE IF EXISTS dmz_user_account;
|
||||
CREATE TABLE dmz_user_account (
|
||||
id bigserial NOT NULL,
|
||||
c_refid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_refid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_editor bool NOT NULL DEFAULT '0',
|
||||
c_admin bool NOT NULL DEFAULT '0',
|
||||
c_users bool NOT NULL DEFAULT '1',
|
||||
|
@ -446,30 +446,11 @@ CREATE INDEX idx_user_account_3 ON dmz_user_account (c_orgid);
|
|||
DROP TABLE IF EXISTS dmz_user_activity;
|
||||
CREATE TABLE dmz_user_activity (
|
||||
id bigserial NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_sectionid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_sourcetype int NOT NULL DEFAULT '0',
|
||||
c_activitytype int NOT NULL DEFAULT '0',
|
||||
c_metadata varchar(1000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE INDEX idx_user_activity_1 ON dmz_user_activity (c_orgid);
|
||||
CREATE INDEX idx_user_activity_2 ON dmz_user_activity (c_userid);
|
||||
CREATE INDEX idx_user_activity_3 ON dmz_user_activity (c_activitytype);
|
||||
CREATE INDEX idx_user_activity_4 ON dmz_user_activity (c_orgid,c_docid,c_sourcetype);
|
||||
CREATE INDEX idx_user_activity_5 ON dmz_user_activity (c_orgid,c_docid,c_userid,c_sourcetype);
|
||||
DROP TABLE IF EXISTS dmz_user_activity;
|
||||
CREATE TABLE dmz_user_activity (
|
||||
id bigserial NOT NULL,
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_sectionid char(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_spaceid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_docid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_sectionid varchar(16) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
c_sourcetype int NOT NULL DEFAULT '0',
|
||||
c_activitytype int NOT NULL DEFAULT '0',
|
||||
c_metadata varchar(1000) COLLATE ucs_basic NOT NULL DEFAULT '',
|
||||
|
@ -484,9 +465,9 @@ CREATE INDEX idx_user_activity_5 ON dmz_user_activity (c_orgid,c_docid,c_userid,
|
|||
|
||||
DROP TABLE IF EXISTS dmz_user_config;
|
||||
CREATE TABLE dmz_user_config (
|
||||
c_orgid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid char(16) COLLATE ucs_basic NOT NULL,
|
||||
c_key char(200) COLLATE ucs_basic NOT NULL,
|
||||
c_orgid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_userid varchar(16) COLLATE ucs_basic NOT NULL,
|
||||
c_key varchar(200) COLLATE ucs_basic NOT NULL,
|
||||
c_config json DEFAULT NULL,
|
||||
UNIQUE (c_orgid,c_userid,c_key)
|
||||
);
|
|
@ -21,14 +21,14 @@ import (
|
|||
"github.com/documize/community/core/secrets"
|
||||
"github.com/documize/community/core/stringutil"
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/server/web"
|
||||
)
|
||||
|
||||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Setup the tables in a blank database
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// Store provides data access to account information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.AccountStorer
|
||||
store.AccountStorer
|
||||
}
|
||||
|
||||
// Add inserts the given record into the datbase account table.
|
||||
|
@ -69,7 +69,7 @@ func (s Store) GetUserAccounts(ctx domain.RequestContext, userID string) (t []ac
|
|||
a.c_active AS active, a.c_created AS created, a.c_revised AS revised,
|
||||
b.c_company AS company, b.c_title AS title, b.c_message AS message, b.c_domain as domain
|
||||
FROM dmz_user_account a, dmz_org b
|
||||
WHERE a.c_userid=? AND a.c_orgid=b.c_refid AND a.c_active=1
|
||||
WHERE a.c_userid=? AND a.c_orgid=b.c_refid AND a.c_active=true
|
||||
ORDER BY b.c_title`),
|
||||
userID)
|
||||
|
||||
|
@ -88,7 +88,7 @@ func (s Store) GetAccountsByOrg(ctx domain.RequestContext) (t []account.Account,
|
|||
a.c_active AS active, a.c_created AS created, a.c_revised AS revised,
|
||||
b.c_company AS company, b.c_title AS title, b.c_message AS message, b.c_domain as domain
|
||||
FROM dmz_user_account a, dmz_org b
|
||||
WHERE a.c_orgid=b.c_refid AND a.c_orgid=? AND a.c_active=1`),
|
||||
WHERE a.c_orgid=b.c_refid AND a.c_orgid=? AND a.c_active=true`),
|
||||
ctx.OrgID)
|
||||
|
||||
if err != sql.ErrNoRows && err != nil {
|
||||
|
@ -100,7 +100,7 @@ func (s Store) GetAccountsByOrg(ctx domain.RequestContext) (t []account.Account,
|
|||
|
||||
// CountOrgAccounts returns the numnber of active user accounts for specified organization.
|
||||
func (s Store) CountOrgAccounts(ctx domain.RequestContext) (c int) {
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT count(*) FROM dmz_user_account WHERE c_orgid=? AND c_active=1"), ctx.OrgID)
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT count(*) FROM dmz_user_account WHERE c_orgid=? AND c_active=true"), ctx.OrgID)
|
||||
err := row.Scan(&c)
|
||||
if err == sql.ErrNoRows {
|
||||
return 0
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// Store provides data access to user activity information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.ActivityStorer
|
||||
store.ActivityStorer
|
||||
}
|
||||
|
||||
// RecordUserActivity logs user initiated data changes.
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/documize/community/domain/organization"
|
||||
"github.com/documize/community/domain/permission"
|
||||
indexer "github.com/documize/community/domain/search"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/attachment"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/workflow"
|
||||
|
@ -37,7 +38,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
Indexer indexer.Indexer
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
// Store provides data access to document/section attachments information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.AttachmentStorer
|
||||
store.AttachmentStorer
|
||||
}
|
||||
|
||||
// Add inserts the given record into the database attachement table.
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
// Store provides data access to audit log information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.AuditStorer
|
||||
store.AuditStorer
|
||||
}
|
||||
|
||||
// Record adds event entry for specified user using own DB TX.
|
||||
|
|
|
@ -17,13 +17,14 @@ import (
|
|||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
usr "github.com/documize/community/domain/user"
|
||||
"github.com/documize/community/model/account"
|
||||
"github.com/documize/community/model/user"
|
||||
)
|
||||
|
||||
// AddExternalUser method to setup user account in Documize using Keycloak/LDAP provided user data.
|
||||
func AddExternalUser(ctx domain.RequestContext, rt *env.Runtime, store *domain.Store, u user.User, addSpace bool) (nu user.User, err error) {
|
||||
func AddExternalUser(ctx domain.RequestContext, rt *env.Runtime, store *store.Store, u user.User, addSpace bool) (nu user.User, err error) {
|
||||
// only create account if not dupe
|
||||
addUser := true
|
||||
addAccount := true
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/organization"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/domain/user"
|
||||
"github.com/documize/community/model/auth"
|
||||
"github.com/documize/community/model/org"
|
||||
|
@ -31,7 +32,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Login user based up HTTP Authorization header.
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/documize/community/core/stringutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/auth"
|
||||
"github.com/documize/community/domain/store"
|
||||
usr "github.com/documize/community/domain/user"
|
||||
ath "github.com/documize/community/model/auth"
|
||||
"github.com/documize/community/model/user"
|
||||
|
@ -35,7 +36,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Sync gets list of Keycloak users and inserts new users into Documize
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/auth"
|
||||
"github.com/documize/community/domain/store"
|
||||
usr "github.com/documize/community/domain/user"
|
||||
ath "github.com/documize/community/model/auth"
|
||||
lm "github.com/documize/community/model/auth"
|
||||
|
@ -35,7 +36,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Preview connects to LDAP using paylaod and returns first 50 users.
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/permission"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/block"
|
||||
)
|
||||
|
@ -30,7 +31,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Add inserts new reusable content block into database.
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
// Store provides data access to section template information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.BlockStorer
|
||||
store.BlockStorer
|
||||
}
|
||||
|
||||
// Add saves reusable content block.
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/permission"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/category"
|
||||
pm "github.com/documize/community/model/permission"
|
||||
|
@ -34,7 +35,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Add saves space category.
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// Store provides data access to space category information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.CategoryStorer
|
||||
store.CategoryStorer
|
||||
}
|
||||
|
||||
// Add inserts the given record into the category table.
|
||||
|
@ -220,13 +220,13 @@ func (s Store) GetSpaceCategorySummary(ctx domain.RequestContext, spaceID string
|
|||
AND c_docid IN (
|
||||
SELECT c_refid
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_template=0 AND c_groupid=''
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_template=false AND c_groupid=''
|
||||
UNION ALL
|
||||
SELECT d.c_refid
|
||||
FROM (
|
||||
SELECT c_groupid, MIN(c_versionorder) AS latestversion
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_groupid!='' AND c_template=0
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_groupid!='' AND c_template=false
|
||||
GROUP BY c_groupid
|
||||
) AS x INNER JOIN dmz_doc AS d ON d.c_groupid=x.c_groupid AND d.c_versionorder=x.latestversion
|
||||
)
|
||||
|
|
|
@ -26,9 +26,10 @@ import (
|
|||
"github.com/documize/community/core/stringutil"
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/conversion/store"
|
||||
ls "github.com/documize/community/domain/conversion/store"
|
||||
"github.com/documize/community/domain/permission"
|
||||
indexer "github.com/documize/community/domain/search"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/activity"
|
||||
"github.com/documize/community/model/attachment"
|
||||
"github.com/documize/community/model/audit"
|
||||
|
@ -43,7 +44,7 @@ import (
|
|||
var storageProvider StorageProvider
|
||||
|
||||
func init() {
|
||||
storageProvider = new(store.LocalStorageProvider)
|
||||
storageProvider = new(ls.LocalStorageProvider)
|
||||
}
|
||||
|
||||
func (h *Handler) upload(w http.ResponseWriter, r *http.Request) (string, string, string) {
|
||||
|
@ -166,7 +167,7 @@ func (h *Handler) convert(w http.ResponseWriter, r *http.Request, job, folderID
|
|||
response.WriteJSON(w, nd)
|
||||
}
|
||||
|
||||
func processDocument(ctx domain.RequestContext, r *env.Runtime, store *domain.Store, indexer indexer.Indexer, filename, job string, sp space.Space, fileResult *api.DocumentConversionResponse) (newDocument doc.Document, err error) {
|
||||
func processDocument(ctx domain.RequestContext, r *env.Runtime, store *store.Store, indexer indexer.Indexer, filename, job string, sp space.Space, fileResult *api.DocumentConversionResponse) (newDocument doc.Document, err error) {
|
||||
// Convert into database objects
|
||||
document := convertFileResult(filename, fileResult)
|
||||
document.Job = job
|
||||
|
|
|
@ -16,14 +16,14 @@ import (
|
|||
|
||||
api "github.com/documize/community/core/convapi"
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
indexer "github.com/documize/community/domain/search"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
Indexer indexer.Indexer
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ package document
|
|||
import (
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/category"
|
||||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/page"
|
||||
|
@ -64,7 +65,7 @@ func FilterCategoryProtected(docs []doc.Document, cats []category.Category, memb
|
|||
}
|
||||
|
||||
// CopyDocument clones an existing document
|
||||
func CopyDocument(ctx domain.RequestContext, s domain.Store, documentID string) (newDocumentID string, err error) {
|
||||
func CopyDocument(ctx domain.RequestContext, s store.Store, documentID string) (newDocumentID string, err error) {
|
||||
doc, err := s.Document.Get(ctx, documentID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to fetch existing document")
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/documize/community/domain/organization"
|
||||
"github.com/documize/community/domain/permission"
|
||||
indexer "github.com/documize/community/domain/search"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/activity"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/doc"
|
||||
|
@ -43,7 +44,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
Indexer indexer.Indexer
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/permission"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/page"
|
||||
pm "github.com/documize/community/model/permission"
|
||||
|
@ -39,7 +40,7 @@ type exportTOC struct {
|
|||
}
|
||||
|
||||
// BuildExport generates self-enclosed HTML for content specified.
|
||||
func BuildExport(ctx domain.RequestContext, s domain.Store, spec exportSpec) (html string, err error) {
|
||||
func BuildExport(ctx domain.RequestContext, s store.Store, spec exportSpec) (html string, err error) {
|
||||
export := strings.Builder{}
|
||||
content := strings.Builder{}
|
||||
toc := []exportTOC{}
|
||||
|
@ -114,7 +115,7 @@ func BuildExport(ctx domain.RequestContext, s domain.Store, spec exportSpec) (ht
|
|||
}
|
||||
|
||||
// exportSpace returns documents exported.
|
||||
func exportSpace(ctx domain.RequestContext, s domain.Store, spaceID string) (toc []exportTOC, export string, err error) {
|
||||
func exportSpace(ctx domain.RequestContext, s store.Store, spaceID string) (toc []exportTOC, export string, err error) {
|
||||
// Permission check.
|
||||
if !permission.CanViewSpace(ctx, s, spaceID) {
|
||||
return toc, "", nil
|
||||
|
@ -164,7 +165,7 @@ func exportSpace(ctx domain.RequestContext, s domain.Store, spaceID string) (toc
|
|||
}
|
||||
|
||||
// exportCategory returns documents exported for selected categories.
|
||||
func exportCategory(ctx domain.RequestContext, s domain.Store, spaceID string, category []string) (toc []exportTOC, export string, err error) {
|
||||
func exportCategory(ctx domain.RequestContext, s store.Store, spaceID string, category []string) (toc []exportTOC, export string, err error) {
|
||||
// Permission check.
|
||||
if !permission.CanViewSpace(ctx, s, spaceID) {
|
||||
return toc, "", nil
|
||||
|
@ -232,7 +233,7 @@ func exportCategory(ctx domain.RequestContext, s domain.Store, spaceID string, c
|
|||
}
|
||||
|
||||
// exportDocument returns documents for export.
|
||||
func exportDocument(ctx domain.RequestContext, s domain.Store, spaceID string, document []string) (toc []exportTOC, export string, err error) {
|
||||
func exportDocument(ctx domain.RequestContext, s store.Store, spaceID string, document []string) (toc []exportTOC, export string, err error) {
|
||||
// Permission check.
|
||||
if !permission.CanViewSpace(ctx, s, spaceID) {
|
||||
return toc, "", nil
|
||||
|
@ -288,7 +289,7 @@ func exportDocument(ctx domain.RequestContext, s domain.Store, spaceID string, d
|
|||
}
|
||||
|
||||
// processDocument writes out document as HTML content
|
||||
func processDocument(ctx domain.RequestContext, s domain.Store, documentID string) (export string, err error) {
|
||||
func processDocument(ctx domain.RequestContext, s store.Store, documentID string) (export string, err error) {
|
||||
b := strings.Builder{}
|
||||
|
||||
// Permission check.
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// Store provides data access to space category information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.DocumentStorer
|
||||
store.DocumentStorer
|
||||
}
|
||||
|
||||
// Add inserts the given document record into the document table and audits that it has been done.
|
||||
|
@ -35,7 +35,8 @@ func (s Store) Add(ctx domain.RequestContext, d doc.Document) (err error) {
|
|||
d.Revised = d.Created // put same time in both fields
|
||||
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`
|
||||
INSERT INTO dmz_doc (c_refid, c_orgid, c_spaceid, c_userid, c_job, c_location, c_name, c_desc, c_slug, c_tags, c_template, c_protection, c_approval, c_lifecycle, c_versioned, c_versionid, c_versionorder, c_groupid, c_created, c_revised)
|
||||
INSERT INTO dmz_doc (c_refid, c_orgid, c_spaceid, c_userid, c_job, c_location, c_name, c_desc, c_slug, c_tags,
|
||||
c_template, c_protection, c_approval, c_lifecycle, c_versioned, c_versionid, c_versionorder, c_groupid, c_created, c_revised)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`),
|
||||
d.RefID, d.OrgID, d.SpaceID, d.UserID, d.Job, d.Location, d.Name, d.Excerpt, d.Slug, d.Tags,
|
||||
d.Template, d.Protection, d.Approval, d.Lifecycle, d.Versioned, d.VersionID, d.VersionOrder, d.GroupID, d.Created, d.Revised)
|
||||
|
@ -83,7 +84,7 @@ func (s Store) GetBySpace(ctx domain.RequestContext, spaceID string) (documents
|
|||
c_lifecycle AS lifecycle, c_versioned AS versioned, c_versionid AS versionid,
|
||||
c_versionorder AS versionorder, c_groupid AS groupid, c_created AS created, c_revised AS revised
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_template=0 AND c_spaceid IN
|
||||
WHERE c_orgid=? AND c_template=false AND c_spaceid IN
|
||||
(SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN
|
||||
(SELECT c_refid FROM dmz_permission WHERE c_orgid=? AND c_location='space' AND c_refid=? AND c_refid IN
|
||||
(SELECT c_refid from dmz_permission WHERE c_orgid=? AND c_who='user' AND (c_whoid=? OR c_whoid='0') AND c_location='space' AND c_action='view'
|
||||
|
@ -115,7 +116,7 @@ func (s Store) TemplatesBySpace(ctx domain.RequestContext, spaceID string) (docu
|
|||
c_lifecycle AS lifecycle, c_versioned AS versioned, c_versionid AS versionid,
|
||||
c_versionorder AS versionorder, c_groupid AS groupid, c_created AS created, c_revised AS revised
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_template=1 AND c_lifecycle=1
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_template=true AND c_lifecycle=1
|
||||
AND c_spaceid IN
|
||||
(SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN
|
||||
(SELECT c_refid FROM dmz_permission WHERE c_orgid=? AND c_location='space' AND c_refid IN
|
||||
|
@ -146,7 +147,7 @@ func (s Store) PublicDocuments(ctx domain.RequestContext, orgID string) (documen
|
|||
SELECT d.c_refid AS documentid, d.c_name AS document, d.c_revised as revised, l.c_refid AS spaceid, l.c_name AS space
|
||||
FROM dmz_doc d
|
||||
LEFT JOIN dmz_space l ON l.c_refid=d.c_spaceid
|
||||
WHERE d.c_orgid=? AND l.c_type=1 AND d.c_lifecycle=1 AND d.c_template=0`),
|
||||
WHERE d.c_orgid=? AND l.c_type=1 AND d.c_lifecycle=1 AND d.c_template=false`),
|
||||
orgID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/documize/community/core/response"
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/group"
|
||||
)
|
||||
|
@ -28,7 +29,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Add saves new user group.
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// Store provides data access to space category information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.DocumentStorer
|
||||
store.DocumentStorer
|
||||
}
|
||||
|
||||
// Add inserts new user group into store.
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/permission"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/attachment"
|
||||
"github.com/documize/community/model/link"
|
||||
"github.com/documize/community/model/page"
|
||||
|
@ -30,7 +31,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// GetLinkCandidates returns references to documents/sections/attachments.
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
// Store provides data access to space category information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.LinkStorer
|
||||
store.LinkStorer
|
||||
}
|
||||
|
||||
// Add inserts wiki-link into the store.
|
||||
|
@ -94,7 +94,7 @@ func (s Store) GetPageLinks(ctx domain.RequestContext, documentID, pageID string
|
|||
func (s Store) MarkOrphanDocumentLink(ctx domain.RequestContext, documentID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc_link SET
|
||||
c_orphan=1, c_revised=?
|
||||
c_orphan=true, c_revised=?
|
||||
WHERE c_type='document' AND c_orgid=? AND c_targetdocid=?`),
|
||||
revised, ctx.OrgID, documentID)
|
||||
|
||||
|
@ -109,7 +109,7 @@ func (s Store) MarkOrphanDocumentLink(ctx domain.RequestContext, documentID stri
|
|||
func (s Store) MarkOrphanPageLink(ctx domain.RequestContext, pageID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc_link SET
|
||||
c_orphan=1, c_revised=?
|
||||
c_orphan=true, c_revised=?
|
||||
WHERE c_type='section' AND c_orgid=? AND c_targetid=?`),
|
||||
revised, ctx.OrgID, pageID)
|
||||
|
||||
|
@ -124,7 +124,7 @@ func (s Store) MarkOrphanPageLink(ctx domain.RequestContext, pageID string) (err
|
|||
func (s Store) MarkOrphanAttachmentLink(ctx domain.RequestContext, attachmentID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc_link SET
|
||||
c_orphan=1, c_revised=?
|
||||
c_orphan=true, c_revised=?
|
||||
WHERE c_type='file' AND c_orgid=? AND c_targetid=?`),
|
||||
revised, ctx.OrgID, attachmentID)
|
||||
|
||||
|
|
|
@ -20,13 +20,14 @@ import (
|
|||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/setting"
|
||||
ds "github.com/documize/community/domain/smtp"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/server/web"
|
||||
)
|
||||
|
||||
// Mailer provides emailing facilities
|
||||
type Mailer struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
Context domain.RequestContext
|
||||
Config ds.Config
|
||||
Dialer *mail.Dialer
|
||||
|
|
|
@ -62,7 +62,7 @@ func (m *Mailer) InviteNewUser(recipient, inviterName, inviterEmail, url, userna
|
|||
m.Runtime.Log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
||||
}
|
||||
if !ok {
|
||||
m.Runtime.Log.Info(fmt.Sprintf("%s unable to send email"))
|
||||
m.Runtime.Log.Info(fmt.Sprintf("%s unable to send email", method))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
|
@ -24,6 +25,7 @@ import (
|
|||
"github.com/documize/community/domain/auth"
|
||||
"github.com/documize/community/domain/organization"
|
||||
indexer "github.com/documize/community/domain/search"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/org"
|
||||
"github.com/documize/community/model/space"
|
||||
|
@ -32,7 +34,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
Indexer indexer.Indexer
|
||||
}
|
||||
|
||||
|
@ -52,7 +54,7 @@ func (h *Handler) Meta(w http.ResponseWriter, r *http.Request) {
|
|||
data.Title = org.Title
|
||||
data.Message = org.Message
|
||||
data.AllowAnonymousAccess = org.AllowAnonymousAccess
|
||||
data.AuthProvider = org.AuthProvider
|
||||
data.AuthProvider = strings.TrimSpace(org.AuthProvider)
|
||||
data.AuthConfig = org.AuthConfig
|
||||
data.MaxTags = org.MaxTags
|
||||
data.Version = h.Runtime.Product.Version
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
// Store provides data access to space category information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.MetaStorer
|
||||
store.MetaStorer
|
||||
}
|
||||
|
||||
// GetDocumentsID returns every document ID value stored.
|
||||
|
|
|
@ -22,13 +22,14 @@ import (
|
|||
"github.com/documize/community/core/response"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/org"
|
||||
)
|
||||
|
||||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Get returns the requested organization.
|
||||
|
@ -96,90 +97,3 @@ func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
response.WriteJSON(w, org)
|
||||
}
|
||||
|
||||
// GetInstanceSetting returns the requested organization level setting.
|
||||
func (h *Handler) GetInstanceSetting(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
orgID := request.Param(r, "orgID")
|
||||
if orgID != ctx.OrgID || !ctx.Administrator {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
key := request.Query(r, "key")
|
||||
setting, _ := h.Store.Setting.GetUser(orgID, "", key, "")
|
||||
if len(setting) == 0 {
|
||||
setting = "{}"
|
||||
}
|
||||
|
||||
response.WriteJSON(w, setting)
|
||||
}
|
||||
|
||||
// SaveInstanceSetting saves org level setting.
|
||||
func (h *Handler) SaveInstanceSetting(w http.ResponseWriter, r *http.Request) {
|
||||
method := "org.SaveInstanceSetting"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
orgID := request.Param(r, "orgID")
|
||||
if orgID != ctx.OrgID || !ctx.Administrator {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
key := request.Query(r, "key")
|
||||
|
||||
defer streamutil.Close(r.Body)
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
config := string(body)
|
||||
h.Store.Setting.SetUser(orgID, "", key, config)
|
||||
|
||||
response.WriteEmpty(w)
|
||||
}
|
||||
|
||||
// GetGlobalSetting returns the requested organization level setting.
|
||||
func (h *Handler) GetGlobalSetting(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
if !ctx.GlobalAdmin {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
key := request.Query(r, "key")
|
||||
setting, _ := h.Store.Setting.Get(key, "")
|
||||
|
||||
response.WriteJSON(w, setting)
|
||||
}
|
||||
|
||||
// SaveGlobalSetting saves org level setting.
|
||||
func (h *Handler) SaveGlobalSetting(w http.ResponseWriter, r *http.Request) {
|
||||
method := "org.SaveGlobalSetting"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
if !ctx.GlobalAdmin {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
key := request.Query(r, "key")
|
||||
|
||||
defer streamutil.Close(r.Body)
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
config := string(body)
|
||||
h.Store.Setting.Set(key, config)
|
||||
|
||||
response.WriteEmpty(w)
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
// Store provides data access to organization (tenant) information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.OrganizationStorer
|
||||
store.OrganizationStorer
|
||||
}
|
||||
|
||||
// AddOrganization inserts the passed organization record into the organization table.
|
||||
|
@ -94,12 +94,11 @@ func (s Store) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
coalesce(c_authconfig,`+s.EmptyJSON()+`) AS authconfig, c_maxtags AS maxtags,
|
||||
c_created AS created, c_revised AS revised
|
||||
FROM dmz_org
|
||||
WHERE c_domain=? AND c_active=1`),
|
||||
WHERE c_domain=? AND c_active=true`),
|
||||
subdomain)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
fmt.Println(err)
|
||||
err = nil
|
||||
|
||||
// match on empty domain AS last resort
|
||||
|
@ -110,7 +109,7 @@ func (s Store) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
coalesce(c_authconfig,`+s.EmptyJSON()+`) AS authconfig, c_maxtags AS maxtags,
|
||||
c_created AS created, c_revised AS revised
|
||||
FROM dmz_org
|
||||
WHERE c_domain='' AND c_active=1`))
|
||||
WHERE c_domain='' AND c_active=true`))
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "unable to execute select for empty subdomain")
|
||||
|
@ -143,7 +142,7 @@ func (s Store) DeleteOrganization(ctx domain.RequestContext, orgID string) (rows
|
|||
|
||||
// RemoveOrganization sets the orgID organization to be inactive, thus executing a "soft delete" operation.
|
||||
func (s Store) RemoveOrganization(ctx domain.RequestContext, orgID string) (err error) {
|
||||
_, err = ctx.Transaction.Exec(s.Bind("UPDATE dmz_org SET c_active=0 WHERE c_refid=?"), orgID)
|
||||
_, err = ctx.Transaction.Exec(s.Bind("UPDATE dmz_org SET c_active=false WHERE c_refid=?"), orgID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute soft delete for org %s", orgID))
|
||||
|
@ -171,7 +170,7 @@ func (s Store) UpdateAuthConfig(ctx domain.RequestContext, org org.Organization)
|
|||
|
||||
// CheckDomain makes sure there is an organisation with the correct domain
|
||||
func (s Store) CheckDomain(ctx domain.RequestContext, domain string) string {
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT COUNT(*) FROM dmz_org WHERE c_domain=? AND c_active=1"), domain)
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT COUNT(*) FROM dmz_org WHERE c_domain=? AND c_active=true"), domain)
|
||||
|
||||
var count int
|
||||
err := row.Scan(&count)
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/documize/community/domain/permission"
|
||||
indexer "github.com/documize/community/domain/search"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/activity"
|
||||
"github.com/documize/community/model/audit"
|
||||
dm "github.com/documize/community/model/doc"
|
||||
|
@ -42,7 +43,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
Indexer indexer.Indexer
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// Store provides data access to organization (tenant) information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.OrganizationStorer
|
||||
store.OrganizationStorer
|
||||
}
|
||||
|
||||
//**************************************************
|
||||
|
@ -256,7 +256,7 @@ func (s Store) GetPageMeta(ctx domain.RequestContext, pageID string) (meta page.
|
|||
func (s Store) GetDocumentPageMeta(ctx domain.RequestContext, documentID string, externalSourceOnly bool) (meta []page.Meta, err error) {
|
||||
filter := ""
|
||||
if externalSourceOnly {
|
||||
filter = " AND c_external=1"
|
||||
filter = " AND c_external=true"
|
||||
}
|
||||
|
||||
err = s.Runtime.Db.Select(&meta, s.Bind(`SELECT id, c_sectionid AS sectionid,
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/documize/community/core/stringutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/mail"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/group"
|
||||
"github.com/documize/community/model/permission"
|
||||
|
@ -37,7 +38,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// SetSpacePermissions persists specified space permissions
|
||||
|
|
|
@ -15,13 +15,14 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
group "github.com/documize/community/model/group"
|
||||
pm "github.com/documize/community/model/permission"
|
||||
u "github.com/documize/community/model/user"
|
||||
)
|
||||
|
||||
// CanViewSpaceDocument returns if the user has permission to view a document within the specified folder.
|
||||
func CanViewSpaceDocument(ctx domain.RequestContext, s domain.Store, labelID string) bool {
|
||||
func CanViewSpaceDocument(ctx domain.RequestContext, s store.Store, labelID string) bool {
|
||||
roles, err := s.Permission.GetUserSpacePermissions(ctx, labelID)
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
|
@ -41,7 +42,7 @@ func CanViewSpaceDocument(ctx domain.RequestContext, s domain.Store, labelID str
|
|||
}
|
||||
|
||||
// CanViewDocument returns if the client has permission to view a given document.
|
||||
func CanViewDocument(ctx domain.RequestContext, s domain.Store, documentID string) bool {
|
||||
func CanViewDocument(ctx domain.RequestContext, s store.Store, documentID string) bool {
|
||||
document, err := s.Document.Get(ctx, documentID)
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
|
@ -69,7 +70,7 @@ func CanViewDocument(ctx domain.RequestContext, s domain.Store, documentID strin
|
|||
}
|
||||
|
||||
// CanChangeDocument returns if the clinet has permission to change a given document.
|
||||
func CanChangeDocument(ctx domain.RequestContext, s domain.Store, documentID string) bool {
|
||||
func CanChangeDocument(ctx domain.RequestContext, s store.Store, documentID string) bool {
|
||||
document, err := s.Document.Get(ctx, documentID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
@ -98,7 +99,7 @@ func CanChangeDocument(ctx domain.RequestContext, s domain.Store, documentID str
|
|||
}
|
||||
|
||||
// CanDeleteDocument returns if the clinet has permission to change a given document.
|
||||
func CanDeleteDocument(ctx domain.RequestContext, s domain.Store, documentID string) bool {
|
||||
func CanDeleteDocument(ctx domain.RequestContext, s store.Store, documentID string) bool {
|
||||
document, err := s.Document.Get(ctx, documentID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
@ -127,7 +128,7 @@ func CanDeleteDocument(ctx domain.RequestContext, s domain.Store, documentID str
|
|||
}
|
||||
|
||||
// CanUploadDocument returns if the client has permission to upload documents to the given space.
|
||||
func CanUploadDocument(ctx domain.RequestContext, s domain.Store, spaceID string) bool {
|
||||
func CanUploadDocument(ctx domain.RequestContext, s store.Store, spaceID string) bool {
|
||||
roles, err := s.Permission.GetUserSpacePermissions(ctx, spaceID)
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
|
@ -147,7 +148,7 @@ func CanUploadDocument(ctx domain.RequestContext, s domain.Store, spaceID string
|
|||
}
|
||||
|
||||
// CanViewSpace returns if the user has permission to view the given spaceID.
|
||||
func CanViewSpace(ctx domain.RequestContext, s domain.Store, spaceID string) bool {
|
||||
func CanViewSpace(ctx domain.RequestContext, s store.Store, spaceID string) bool {
|
||||
roles, err := s.Permission.GetUserSpacePermissions(ctx, spaceID)
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
|
@ -166,7 +167,7 @@ func CanViewSpace(ctx domain.RequestContext, s domain.Store, spaceID string) boo
|
|||
}
|
||||
|
||||
// CanViewDrafts returns if the user has permission to view drafts in space.
|
||||
func CanViewDrafts(ctx domain.RequestContext, s domain.Store, spaceID string) bool {
|
||||
func CanViewDrafts(ctx domain.RequestContext, s store.Store, spaceID string) bool {
|
||||
roles, err := s.Permission.GetUserSpacePermissions(ctx, spaceID)
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
|
@ -185,7 +186,7 @@ func CanViewDrafts(ctx domain.RequestContext, s domain.Store, spaceID string) bo
|
|||
}
|
||||
|
||||
// CanManageVersion returns if the user has permission to manage versions in space.
|
||||
func CanManageVersion(ctx domain.RequestContext, s domain.Store, spaceID string) bool {
|
||||
func CanManageVersion(ctx domain.RequestContext, s store.Store, spaceID string) bool {
|
||||
roles, err := s.Permission.GetUserSpacePermissions(ctx, spaceID)
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
|
@ -204,7 +205,7 @@ func CanManageVersion(ctx domain.RequestContext, s domain.Store, spaceID string)
|
|||
}
|
||||
|
||||
// HasPermission returns if current user can perform specified actions.
|
||||
func HasPermission(ctx domain.RequestContext, s domain.Store, spaceID string, actions ...pm.Action) bool {
|
||||
func HasPermission(ctx domain.RequestContext, s store.Store, spaceID string, actions ...pm.Action) bool {
|
||||
roles, err := s.Permission.GetUserSpacePermissions(ctx, spaceID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
@ -228,7 +229,7 @@ func HasPermission(ctx domain.RequestContext, s domain.Store, spaceID string, ac
|
|||
}
|
||||
|
||||
// CheckPermission returns if specified user can perform specified actions.
|
||||
func CheckPermission(ctx domain.RequestContext, s domain.Store, spaceID string, userID string, actions ...pm.Action) bool {
|
||||
func CheckPermission(ctx domain.RequestContext, s store.Store, spaceID string, userID string, actions ...pm.Action) bool {
|
||||
roles, err := s.Permission.GetSpacePermissionsForUser(ctx, spaceID, userID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
@ -252,7 +253,7 @@ func CheckPermission(ctx domain.RequestContext, s domain.Store, spaceID string,
|
|||
}
|
||||
|
||||
// GetUsersWithDocumentPermission returns list of users who have specified document permission in given space
|
||||
func GetUsersWithDocumentPermission(ctx domain.RequestContext, s domain.Store, spaceID, documentID string, permissionRequired pm.Action) (users []u.User, err error) {
|
||||
func GetUsersWithDocumentPermission(ctx domain.RequestContext, s store.Store, spaceID, documentID string, permissionRequired pm.Action) (users []u.User, err error) {
|
||||
users = []u.User{}
|
||||
prev := make(map[string]bool) // used to ensure we only process user once
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
// Store provides data access to user permission information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.PermissionStorer
|
||||
store.PermissionStorer
|
||||
}
|
||||
|
||||
// AddPermission inserts the given record into the permisssion table.
|
||||
|
@ -164,7 +164,7 @@ func (s Store) GetCategoryUsers(ctx domain.RequestContext, catID string) (u []us
|
|||
SELECT u.id, COALESCE(u.c_refid, '') AS refid, COALESCE(u.c_firstname, '') AS firstname, COALESCE(u.c_lastname, '') as lastname, u.email AS email, u.initials AS initials, u.password AS password, u.salt AS salt, u.c_reset AS reset, u.c_created AS created, u.c_revised AS revised
|
||||
FROM dmz_user u
|
||||
LEFT JOIN dmz_user_account a ON u.c_refid = a.c_userid
|
||||
WHERE a.c_orgid=? AND a.c_active=1 AND u.c_refid IN (
|
||||
WHERE a.c_orgid=? AND a.c_active=true AND u.c_refid IN (
|
||||
SELECT c_whoid from dmz_permission
|
||||
WHERE c_orgid=? AND c_who='user' AND c_location='category' AND c_refid=?
|
||||
UNION ALL
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/documize/community/core/response"
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/pin"
|
||||
)
|
||||
|
@ -30,7 +31,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Add saves pinned item.
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
// Store provides data access to user permission information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.PinStorer
|
||||
store.PinStorer
|
||||
}
|
||||
|
||||
// Add saves pinned item.
|
||||
|
|
|
@ -13,17 +13,17 @@ package search
|
|||
|
||||
import (
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Indexer documents!
|
||||
type Indexer struct {
|
||||
runtime *env.Runtime
|
||||
store *domain.Store
|
||||
store *store.Store
|
||||
}
|
||||
|
||||
// NewIndexer provides background search indexer
|
||||
func NewIndexer(rt *env.Runtime, s *domain.Store) (i Indexer) {
|
||||
func NewIndexer(rt *env.Runtime, s *store.Store) (i Indexer) {
|
||||
i = Indexer{}
|
||||
i.runtime = rt
|
||||
i.store = s
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/core/stringutil"
|
||||
"github.com/documize/community/domain"
|
||||
|
@ -32,7 +33,7 @@ import (
|
|||
// Store provides data access to space information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.SearchStorer
|
||||
store.SearchStorer
|
||||
}
|
||||
|
||||
// IndexDocument adds search index entries for document inserting title, tags and attachments as
|
||||
|
@ -214,7 +215,17 @@ func (s Store) Documents(ctx domain.RequestContext, q search.QueryOptions) (resu
|
|||
}
|
||||
|
||||
func (s Store) matchFullText(ctx domain.RequestContext, keywords, itemType string) (r []search.QueryResult, err error) {
|
||||
sql1 := `
|
||||
// Full text search clause specific to database provider
|
||||
fts := ""
|
||||
|
||||
switch s.Runtime.StoreProvider.Type() {
|
||||
case env.StoreTypeMySQL:
|
||||
fts = " AND MATCH(s.c_content) AGAINST(? IN BOOLEAN MODE)"
|
||||
case env.StoreTypePostgreSQL:
|
||||
fts = ""
|
||||
}
|
||||
|
||||
sql1 := s.Bind(`
|
||||
SELECT
|
||||
s.id, s.c_orgid AS orgid, s.c_docid AS documentid, s.c_itemid AS itemid, s.c_itemtype AS itemtype,
|
||||
d.c_spaceid as spaceid, COALESCE(d.c_name,'Unknown') AS document, d.c_tags AS tags,
|
||||
|
@ -239,7 +250,7 @@ func (s Store) matchFullText(ctx domain.RequestContext, keywords, itemType strin
|
|||
AND p.c_location='space' AND (r.c_userid=? OR r.c_userid='0')
|
||||
)
|
||||
)
|
||||
AND MATCH(s.c_content) AGAINST(? IN BOOLEAN MODE)`
|
||||
` + fts)
|
||||
|
||||
err = s.Runtime.Db.Select(&r,
|
||||
sql1,
|
||||
|
@ -270,8 +281,7 @@ func (s Store) matchLike(ctx domain.RequestContext, keywords, itemType string) (
|
|||
keywords = strings.Replace(keywords, "%", "", -1)
|
||||
keywords = fmt.Sprintf("%%%s%%", keywords)
|
||||
|
||||
sql1 := `
|
||||
SELECT
|
||||
sql1 := s.Bind(`SELECT
|
||||
s.id, s.c_orgid AS orgid, s.c_docid AS documentid, s.c_itemid AS itemid, s.c_itemtype AS itemtype,
|
||||
d.c_spaceid as spaceid, COALESCE(d.c_name,'Unknown') AS document, d.c_tags AS tags, d.c_desc AS excerpt,
|
||||
COALESCE(l.c_name,'Unknown') AS space
|
||||
|
@ -294,7 +304,7 @@ func (s Store) matchLike(ctx domain.RequestContext, keywords, itemType string) (
|
|||
AND p.c_location='space' AND (r.c_userid=? OR r.c_userid='0')
|
||||
)
|
||||
)
|
||||
AND s.c_content LIKE ?`
|
||||
AND s.c_content LIKE ?`)
|
||||
|
||||
err = s.Runtime.Db.Select(&r,
|
||||
sql1,
|
||||
|
|
|
@ -15,14 +15,14 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Provider represents Airtable
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us
|
||||
|
|
|
@ -15,14 +15,14 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Provider represents code snippet
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us.
|
||||
|
|
|
@ -22,13 +22,14 @@ import (
|
|||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/permission"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/page"
|
||||
)
|
||||
|
||||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// GetSections returns available smart sections.
|
||||
|
|
|
@ -15,14 +15,14 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Provider represents Draw.io
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us
|
||||
|
|
|
@ -21,14 +21,14 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Provider represents Gemini
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us.
|
||||
|
@ -154,7 +154,7 @@ func (p *Provider) Refresh(ctx *provider.Context, config, data string) (newData
|
|||
return
|
||||
}
|
||||
|
||||
func auth(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func auth(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
|
||||
|
@ -222,7 +222,7 @@ func auth(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *
|
|||
provider.WriteJSON(w, g)
|
||||
}
|
||||
|
||||
func workspace(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func workspace(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
|
||||
|
@ -294,7 +294,7 @@ func workspace(ctx *provider.Context, store *domain.Store, w http.ResponseWriter
|
|||
provider.WriteJSON(w, workspace)
|
||||
}
|
||||
|
||||
func items(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func items(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
|
||||
|
@ -369,7 +369,7 @@ func items(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r
|
|||
provider.WriteJSON(w, items)
|
||||
}
|
||||
|
||||
func secs(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func secs(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
sec, _ := getSecrets(ctx, store)
|
||||
provider.WriteJSON(w, sec)
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ package gemini
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// the HTML that is rendered by this section.
|
||||
|
@ -87,7 +87,7 @@ type geminiConfig struct {
|
|||
Filter map[string]interface{} `json:"filter"`
|
||||
}
|
||||
|
||||
func (c *geminiConfig) Clean(ctx *provider.Context, store *domain.Store) {
|
||||
func (c *geminiConfig) Clean(ctx *provider.Context, store *store.Store) {
|
||||
if ctx != nil {
|
||||
sec, err := getSecrets(ctx, store)
|
||||
if err == nil {
|
||||
|
@ -103,7 +103,7 @@ func (c *geminiConfig) Clean(ctx *provider.Context, store *domain.Store) {
|
|||
c.URL = strings.TrimSpace(c.URL)
|
||||
}
|
||||
|
||||
func (c *geminiConfig) SaveSecrets(ctx *provider.Context, store *domain.Store) {
|
||||
func (c *geminiConfig) SaveSecrets(ctx *provider.Context, store *store.Store) {
|
||||
var sec secrets
|
||||
sec.APIKey = strings.TrimSpace(c.APIKey)
|
||||
sec.Username = strings.TrimSpace(c.Username)
|
||||
|
@ -117,7 +117,7 @@ type secrets struct {
|
|||
APIKey string `json:"apikey"`
|
||||
}
|
||||
|
||||
func getSecrets(ctx *provider.Context, store *domain.Store) (sec secrets, err error) {
|
||||
func getSecrets(ctx *provider.Context, store *store.Store) (sec secrets, err error) {
|
||||
err = ctx.UnmarshalSecrets(&sec, store)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
jira "gopkg.in/andygrunwald/go-jira.v1"
|
||||
)
|
||||
|
||||
|
@ -34,7 +34,7 @@ const (
|
|||
// Provider represents Gemini
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us.
|
||||
|
@ -129,7 +129,7 @@ func (p *Provider) Command(ctx *provider.Context, w http.ResponseWriter, r *http
|
|||
}
|
||||
}
|
||||
|
||||
func auth(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func auth(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
creds, err := getCredentials(ctx, store)
|
||||
if err != nil {
|
||||
provider.WriteForbidden(w)
|
||||
|
@ -147,7 +147,7 @@ func auth(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *
|
|||
provider.WriteJSON(w, "OK")
|
||||
}
|
||||
|
||||
func previewIssues(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func previewIssues(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
creds, err := getCredentials(ctx, store)
|
||||
if err != nil {
|
||||
provider.WriteForbidden(w)
|
||||
|
@ -173,7 +173,7 @@ func previewIssues(ctx *provider.Context, store *domain.Store, w http.ResponseWr
|
|||
provider.WriteJSON(w, issues)
|
||||
}
|
||||
|
||||
func previewGrid(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) {
|
||||
func previewGrid(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) {
|
||||
creds, err := getCredentials(ctx, store)
|
||||
if err != nil {
|
||||
provider.WriteForbidden(w)
|
||||
|
@ -202,7 +202,7 @@ func previewGrid(ctx *provider.Context, store *domain.Store, w http.ResponseWrit
|
|||
}
|
||||
|
||||
// Pull config from HTTP request.
|
||||
func readConfig(ctx *provider.Context, store *domain.Store, w http.ResponseWriter, r *http.Request) (config jiraConfig, err error) {
|
||||
func readConfig(ctx *provider.Context, store *store.Store, w http.ResponseWriter, r *http.Request) (config jiraConfig, err error) {
|
||||
defer r.Body.Close()
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
|
@ -218,7 +218,7 @@ func readConfig(ctx *provider.Context, store *domain.Store, w http.ResponseWrite
|
|||
}
|
||||
|
||||
// Get Jira connector configuration.
|
||||
func getCredentials(ctx *provider.Context, store *domain.Store) (login jiraLogin, err error) {
|
||||
func getCredentials(ctx *provider.Context, store *store.Store) (login jiraLogin, err error) {
|
||||
creds, err := store.Setting.GetUser(ctx.OrgID, "", "jira", "")
|
||||
|
||||
err = json.Unmarshal([]byte(creds), &login)
|
||||
|
|
|
@ -16,14 +16,14 @@ import (
|
|||
|
||||
"github.com/documize/blackfriday"
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Provider represents Markdown
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us
|
||||
|
|
|
@ -22,8 +22,8 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
const me = "papertrail"
|
||||
|
@ -31,7 +31,7 @@ const me = "papertrail"
|
|||
// Provider represents Papertrail
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us.
|
||||
|
@ -162,7 +162,7 @@ func (p *Provider) Refresh(ctx *provider.Context, config, data string) (newData
|
|||
return
|
||||
}
|
||||
|
||||
func auth(rt *env.Runtime, store *domain.Store, ctx *provider.Context, config papertrailConfig, w http.ResponseWriter, r *http.Request) {
|
||||
func auth(rt *env.Runtime, store *store.Store, ctx *provider.Context, config papertrailConfig, w http.ResponseWriter, r *http.Request) {
|
||||
result, err := fetchEvents(rt, config)
|
||||
|
||||
if result == nil {
|
||||
|
|
|
@ -21,14 +21,14 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Provider represents PlantUML Text Diagram
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// SecretReplacement is a constant used to replace secrets in data-structures when required.
|
||||
|
@ -39,7 +40,7 @@ type TypeMeta struct {
|
|||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Preview bool `json:"preview"` // coming soon!
|
||||
Callback func(*env.Runtime, *domain.Store, http.ResponseWriter, *http.Request) error `json:"-"`
|
||||
Callback func(*env.Runtime, *store.Store, http.ResponseWriter, *http.Request) error `json:"-"`
|
||||
}
|
||||
|
||||
// ConfigHandle returns the key name for database config table
|
||||
|
@ -102,7 +103,7 @@ func Command(section string, ctx *Context, w http.ResponseWriter, r *http.Reques
|
|||
}
|
||||
|
||||
// Callback passes parameters to the given section callback, the returned error indicates success.
|
||||
func Callback(section string, rt *env.Runtime, store *domain.Store, w http.ResponseWriter, r *http.Request) error {
|
||||
func Callback(section string, rt *env.Runtime, store *store.Store, w http.ResponseWriter, r *http.Request) error {
|
||||
s, ok := sectionsMap[section]
|
||||
if ok {
|
||||
if cb := s.Meta().Callback; cb != nil {
|
||||
|
@ -194,7 +195,7 @@ func WriteForbidden(w http.ResponseWriter) {
|
|||
// The secrets must be in the form of a JSON format string, for example `{"mysecret":"lover"}`.
|
||||
// An empty string signifies no valid secrets for this user/org combination.
|
||||
// Note that this function can only be called within the Command method of a section.
|
||||
func (c *Context) SaveSecrets(JSONobj string, s *domain.Store) error {
|
||||
func (c *Context) SaveSecrets(JSONobj string, s *store.Store) error {
|
||||
if !c.inCommand {
|
||||
return errors.New("SaveSecrets() may only be called from within Command()")
|
||||
}
|
||||
|
@ -204,7 +205,7 @@ func (c *Context) SaveSecrets(JSONobj string, s *domain.Store) error {
|
|||
|
||||
// MarshalSecrets to the database.
|
||||
// Parameter the same as for json.Marshal().
|
||||
func (c *Context) MarshalSecrets(sec interface{}, s *domain.Store) error {
|
||||
func (c *Context) MarshalSecrets(sec interface{}, s *store.Store) error {
|
||||
if !c.inCommand {
|
||||
return errors.New("MarshalSecrets() may only be called from within Command()")
|
||||
}
|
||||
|
@ -220,7 +221,7 @@ func (c *Context) MarshalSecrets(sec interface{}, s *domain.Store) error {
|
|||
// JSONpath format is defined at https://dev.mysql.com/doc/refman/5.7/en/json-path-syntax.html .
|
||||
// An empty JSONpath returns the whole JSON object, as JSON.
|
||||
// Errors return the empty string.
|
||||
func (c *Context) GetSecrets(JSONpath string, s *domain.Store) string {
|
||||
func (c *Context) GetSecrets(JSONpath string, s *store.Store) string {
|
||||
m := c.prov.Meta()
|
||||
v, _ := s.Setting.GetUser(c.OrgID, c.UserID, m.ContentType, JSONpath)
|
||||
|
||||
|
@ -232,7 +233,7 @@ var ErrNoSecrets = errors.New("no secrets in database")
|
|||
|
||||
// UnmarshalSecrets from the database.
|
||||
// Parameter the same as for "v" in json.Unmarshal().
|
||||
func (c *Context) UnmarshalSecrets(v interface{}, s *domain.Store) error {
|
||||
func (c *Context) UnmarshalSecrets(v interface{}, s *store.Store) error {
|
||||
secTxt := c.GetSecrets("", s) // get all the json of the secrets
|
||||
if len(secTxt) > 0 {
|
||||
return json.Unmarshal([]byte(secTxt), v)
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/airtable"
|
||||
"github.com/documize/community/domain/section/code"
|
||||
"github.com/documize/community/domain/section/flowchart"
|
||||
|
@ -28,10 +27,11 @@ import (
|
|||
"github.com/documize/community/domain/section/table"
|
||||
"github.com/documize/community/domain/section/trello"
|
||||
"github.com/documize/community/domain/section/wysiwyg"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Register sections
|
||||
func Register(rt *env.Runtime, s *domain.Store) {
|
||||
func Register(rt *env.Runtime, s *store.Store) {
|
||||
provider.Register("code", &code.Provider{Runtime: rt, Store: s})
|
||||
provider.Register("jira", &jira.Provider{Runtime: rt, Store: s})
|
||||
provider.Register("gemini", &gemini.Provider{Runtime: rt, Store: s})
|
||||
|
|
|
@ -15,14 +15,14 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Provider represents Table
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us
|
||||
|
|
|
@ -20,8 +20,8 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
var meta provider.TypeMeta
|
||||
|
@ -39,7 +39,7 @@ func init() {
|
|||
// Provider represents Trello
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us.
|
||||
|
|
|
@ -15,14 +15,14 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section/provider"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// Provider represents WYSIWYG
|
||||
type Provider struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Meta describes us
|
||||
|
|
|
@ -21,16 +21,19 @@ import (
|
|||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/event"
|
||||
"github.com/documize/community/core/request"
|
||||
"github.com/documize/community/core/response"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/smtp"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/audit"
|
||||
)
|
||||
|
||||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// SMTP returns installation-wide SMTP settings
|
||||
|
@ -294,3 +297,90 @@ func (h *Handler) SetAuthConfig(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
response.WriteEmpty(w)
|
||||
}
|
||||
|
||||
// GetInstanceSetting returns the requested organization level setting.
|
||||
func (h *Handler) GetInstanceSetting(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
orgID := request.Param(r, "orgID")
|
||||
if orgID != ctx.OrgID || !ctx.Administrator {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
key := request.Query(r, "key")
|
||||
setting, _ := h.Store.Setting.GetUser(orgID, "", key, "")
|
||||
if len(setting) == 0 {
|
||||
setting = "{}"
|
||||
}
|
||||
|
||||
response.WriteJSON(w, setting)
|
||||
}
|
||||
|
||||
// SaveInstanceSetting saves org level setting.
|
||||
func (h *Handler) SaveInstanceSetting(w http.ResponseWriter, r *http.Request) {
|
||||
method := "org.SaveInstanceSetting"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
orgID := request.Param(r, "orgID")
|
||||
if orgID != ctx.OrgID || !ctx.Administrator {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
key := request.Query(r, "key")
|
||||
|
||||
defer streamutil.Close(r.Body)
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
config := string(body)
|
||||
h.Store.Setting.SetUser(orgID, "", key, config)
|
||||
|
||||
response.WriteEmpty(w)
|
||||
}
|
||||
|
||||
// GetGlobalSetting returns the requested organization level setting.
|
||||
func (h *Handler) GetGlobalSetting(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
if !ctx.GlobalAdmin {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
key := request.Query(r, "key")
|
||||
setting, _ := h.Store.Setting.Get(key, "")
|
||||
|
||||
response.WriteJSON(w, setting)
|
||||
}
|
||||
|
||||
// SaveGlobalSetting saves org level setting.
|
||||
func (h *Handler) SaveGlobalSetting(w http.ResponseWriter, r *http.Request) {
|
||||
method := "org.SaveGlobalSetting"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
if !ctx.GlobalAdmin {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
key := request.Query(r, "key")
|
||||
|
||||
defer streamutil.Close(r.Body)
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
config := string(body)
|
||||
h.Store.Setting.Set(key, config)
|
||||
|
||||
response.WriteEmpty(w)
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@ package setting
|
|||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/smtp"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// GetSMTPConfig returns SMTP configuration.
|
||||
func GetSMTPConfig(s *domain.Store) (c smtp.Config) {
|
||||
func GetSMTPConfig(s *store.Store) (c smtp.Config) {
|
||||
c = smtp.Config{}
|
||||
|
||||
// server
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -24,14 +23,14 @@ import (
|
|||
// Store provides data access to user permission information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.SettingStorer
|
||||
store.SettingStorer
|
||||
}
|
||||
|
||||
// Get fetches a configuration JSON element from the config table.
|
||||
func (s Store) Get(area, path string) (value string, err error) {
|
||||
qry := fmt.Sprintf("SELECT %s FROM dmz_config WHERE c_key = '%s';", s.GetJSONValue("c_config", path), area)
|
||||
|
||||
var item = make([]uint8, 0)
|
||||
item := []byte{}
|
||||
err = s.Runtime.Db.Get(&item, qry)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -83,7 +82,7 @@ func (s Store) Set(area, json string) (err error) {
|
|||
func (s Store) GetUser(orgID, userID, key, path string) (value string, err error) {
|
||||
var item = make([]uint8, 0)
|
||||
|
||||
qry := fmt.Sprintf("SELECT %s FROM dmz_config WHERE c_key = '%s' AND c_orgid='%s' AND c_userid='%s';",
|
||||
qry := fmt.Sprintf("SELECT %s FROM dmz_user_config WHERE c_key = '%s' AND c_orgid='%s' AND c_userid='%s';",
|
||||
s.GetJSONValue("c_config", path), key, orgID, userID)
|
||||
|
||||
err = s.Runtime.Db.Get(&item, qry)
|
||||
|
|
|
@ -32,6 +32,7 @@ import (
|
|||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/mail"
|
||||
"github.com/documize/community/domain/organization"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/account"
|
||||
"github.com/documize/community/model/activity"
|
||||
"github.com/documize/community/model/audit"
|
||||
|
@ -47,7 +48,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Add creates a new space.
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/mail"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/account"
|
||||
"github.com/documize/community/model/permission"
|
||||
"github.com/documize/community/model/space"
|
||||
|
@ -29,7 +30,7 @@ import (
|
|||
// We create the user account with default values and then take them
|
||||
// through a welcome process designed to capture profile data.
|
||||
// We add them to the organization and grant them view-only space access.
|
||||
func inviteNewUserToSharedSpace(ctx domain.RequestContext, rt *env.Runtime, s *domain.Store, email string, invitedBy user.User,
|
||||
func inviteNewUserToSharedSpace(ctx domain.RequestContext, rt *env.Runtime, s *store.Store, email string, invitedBy user.User,
|
||||
baseURL string, sp space.Space, invitationMessage string) (err error) {
|
||||
|
||||
var u = user.User{}
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// Store provides data access to space information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.SpaceStorer
|
||||
store.SpaceStorer
|
||||
}
|
||||
|
||||
// Add adds new folder into the store.
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// BaseQuery provides common MySQL methods.
|
||||
type BaseQuery struct {
|
||||
}
|
||||
|
||||
// Delete record.
|
||||
func (m *BaseQuery) Delete(tx *sqlx.Tx, table string, id string) (rows int64, err error) {
|
||||
result, err := tx.Exec("DELETE FROM "+table+" WHERE c_refid=?", id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to delete row in table %s", table))
|
||||
return
|
||||
}
|
||||
|
||||
rows, err = result.RowsAffected()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteConstrained record constrained to Organization using refid.
|
||||
func (m *BaseQuery) DeleteConstrained(tx *sqlx.Tx, table string, orgID, id string) (rows int64, err error) {
|
||||
result, err := tx.Exec("DELETE FROM "+table+" WHERE c_orgid=? AND c_refid=?", orgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to delete row in table %s", table))
|
||||
return
|
||||
}
|
||||
|
||||
rows, err = result.RowsAffected()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteConstrainedWithID record constrained to Organization using non refid.
|
||||
func (m *BaseQuery) DeleteConstrainedWithID(tx *sqlx.Tx, table string, orgID, id string) (rows int64, err error) {
|
||||
result, err := tx.Exec("DELETE FROM "+table+" WHERE c_orgid=? AND id=?", orgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to delete row in table %s", table))
|
||||
return
|
||||
}
|
||||
|
||||
rows, err = result.RowsAffected()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteWhere free form query.
|
||||
func (m *BaseQuery) DeleteWhere(tx *sqlx.Tx, statement string) (rows int64, err error) {
|
||||
result, err := tx.Exec(statement)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to delete rows: %s", statement))
|
||||
return
|
||||
}
|
||||
|
||||
rows, err = result.RowsAffected()
|
||||
|
||||
return
|
||||
}
|
296
domain/store/storer.go
Normal file
296
domain/store/storer.go
Normal file
|
@ -0,0 +1,296 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package store
|
||||
|
||||
import (
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/model/account"
|
||||
"github.com/documize/community/model/activity"
|
||||
"github.com/documize/community/model/attachment"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/block"
|
||||
"github.com/documize/community/model/category"
|
||||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/group"
|
||||
"github.com/documize/community/model/link"
|
||||
"github.com/documize/community/model/org"
|
||||
"github.com/documize/community/model/page"
|
||||
"github.com/documize/community/model/permission"
|
||||
"github.com/documize/community/model/pin"
|
||||
"github.com/documize/community/model/search"
|
||||
"github.com/documize/community/model/space"
|
||||
"github.com/documize/community/model/user"
|
||||
)
|
||||
|
||||
// Store provides access to data store (database)
|
||||
type Store struct {
|
||||
Account AccountStorer
|
||||
Activity ActivityStorer
|
||||
Attachment AttachmentStorer
|
||||
Audit AuditStorer
|
||||
Block BlockStorer
|
||||
Category CategoryStorer
|
||||
Document DocumentStorer
|
||||
Group GroupStorer
|
||||
Link LinkStorer
|
||||
Meta MetaStorer
|
||||
Organization OrganizationStorer
|
||||
Page PageStorer
|
||||
Pin PinStorer
|
||||
Permission PermissionStorer
|
||||
Search SearchStorer
|
||||
Setting SettingStorer
|
||||
Space SpaceStorer
|
||||
User UserStorer
|
||||
}
|
||||
|
||||
// SpaceStorer defines required methods for space management
|
||||
type SpaceStorer interface {
|
||||
Add(ctx domain.RequestContext, sp space.Space) (err error)
|
||||
Get(ctx domain.RequestContext, id string) (sp space.Space, err error)
|
||||
PublicSpaces(ctx domain.RequestContext, orgID string) (sp []space.Space, err error)
|
||||
GetViewable(ctx domain.RequestContext) (sp []space.Space, err error)
|
||||
GetAll(ctx domain.RequestContext) (sp []space.Space, err error)
|
||||
Update(ctx domain.RequestContext, sp space.Space) (err error)
|
||||
Delete(ctx domain.RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// CategoryStorer defines required methods for category and category membership management
|
||||
type CategoryStorer interface {
|
||||
Add(ctx domain.RequestContext, c category.Category) (err error)
|
||||
Update(ctx domain.RequestContext, c category.Category) (err error)
|
||||
Get(ctx domain.RequestContext, id string) (c category.Category, err error)
|
||||
GetBySpace(ctx domain.RequestContext, spaceID string) (c []category.Category, err error)
|
||||
GetAllBySpace(ctx domain.RequestContext, spaceID string) (c []category.Category, err error)
|
||||
GetSpaceCategorySummary(ctx domain.RequestContext, spaceID string) (c []category.SummaryModel, err error)
|
||||
Delete(ctx domain.RequestContext, id string) (rows int64, err error)
|
||||
AssociateDocument(ctx domain.RequestContext, m category.Member) (err error)
|
||||
DisassociateDocument(ctx domain.RequestContext, categoryID, documentID string) (rows int64, err error)
|
||||
RemoveCategoryMembership(ctx domain.RequestContext, categoryID string) (rows int64, err error)
|
||||
DeleteBySpace(ctx domain.RequestContext, spaceID string) (rows int64, err error)
|
||||
GetDocumentCategoryMembership(ctx domain.RequestContext, documentID string) (c []category.Category, err error)
|
||||
GetSpaceCategoryMembership(ctx domain.RequestContext, spaceID string) (c []category.Member, err error)
|
||||
RemoveDocumentCategories(ctx domain.RequestContext, documentID string) (rows int64, err error)
|
||||
RemoveSpaceCategoryMemberships(ctx domain.RequestContext, spaceID string) (rows int64, err error)
|
||||
GetByOrg(ctx domain.RequestContext, userID string) (c []category.Category, err error)
|
||||
GetOrgCategoryMembership(ctx domain.RequestContext, userID string) (c []category.Member, err error)
|
||||
}
|
||||
|
||||
// PermissionStorer defines required methods for space/document permission management
|
||||
type PermissionStorer interface {
|
||||
AddPermission(ctx domain.RequestContext, r permission.Permission) (err error)
|
||||
AddPermissions(ctx domain.RequestContext, r permission.Permission, actions ...permission.Action) (err error)
|
||||
GetUserSpacePermissions(ctx domain.RequestContext, spaceID string) (r []permission.Permission, err error)
|
||||
GetSpacePermissionsForUser(ctx domain.RequestContext, spaceID, userID string) (r []permission.Permission, err error)
|
||||
GetSpacePermissions(ctx domain.RequestContext, spaceID string) (r []permission.Permission, err error)
|
||||
GetCategoryPermissions(ctx domain.RequestContext, catID string) (r []permission.Permission, err error)
|
||||
GetCategoryUsers(ctx domain.RequestContext, catID string) (u []user.User, err error)
|
||||
GetUserCategoryPermissions(ctx domain.RequestContext, userID string) (r []permission.Permission, err error)
|
||||
GetUserDocumentPermissions(ctx domain.RequestContext, documentID string) (r []permission.Permission, err error)
|
||||
GetDocumentPermissions(ctx domain.RequestContext, documentID string) (r []permission.Permission, err error)
|
||||
DeleteDocumentPermissions(ctx domain.RequestContext, documentID string) (rows int64, err error)
|
||||
DeleteSpacePermissions(ctx domain.RequestContext, spaceID string) (rows int64, err error)
|
||||
DeleteUserSpacePermissions(ctx domain.RequestContext, spaceID, userID string) (rows int64, err error)
|
||||
DeleteUserPermissions(ctx domain.RequestContext, userID string) (rows int64, err error)
|
||||
DeleteCategoryPermissions(ctx domain.RequestContext, categoryID string) (rows int64, err error)
|
||||
DeleteSpaceCategoryPermissions(ctx domain.RequestContext, spaceID string) (rows int64, err error)
|
||||
DeleteGroupPermissions(ctx domain.RequestContext, groupID string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// UserStorer defines required methods for user management
|
||||
type UserStorer interface {
|
||||
Add(ctx domain.RequestContext, u user.User) (err error)
|
||||
Get(ctx domain.RequestContext, id string) (u user.User, err error)
|
||||
GetByDomain(ctx domain.RequestContext, domain, email string) (u user.User, err error)
|
||||
GetByEmail(ctx domain.RequestContext, email string) (u user.User, err error)
|
||||
GetByToken(ctx domain.RequestContext, token string) (u user.User, err error)
|
||||
GetBySerial(ctx domain.RequestContext, serial string) (u user.User, err error)
|
||||
GetActiveUsersForOrganization(ctx domain.RequestContext) (u []user.User, err error)
|
||||
GetUsersForOrganization(ctx domain.RequestContext, filter string, limit int) (u []user.User, err error)
|
||||
GetSpaceUsers(ctx domain.RequestContext, spaceID string) (u []user.User, err error)
|
||||
GetUsersForSpaces(ctx domain.RequestContext, spaces []string) (u []user.User, err error)
|
||||
UpdateUser(ctx domain.RequestContext, u user.User) (err error)
|
||||
UpdateUserPassword(ctx domain.RequestContext, userID, salt, password string) (err error)
|
||||
DeactiveUser(ctx domain.RequestContext, userID string) (err error)
|
||||
ForgotUserPassword(ctx domain.RequestContext, email, token string) (err error)
|
||||
CountActiveUsers() (c int)
|
||||
MatchUsers(ctx domain.RequestContext, text string, maxMatches int) (u []user.User, err error)
|
||||
}
|
||||
|
||||
// AccountStorer defines required methods for account management
|
||||
type AccountStorer interface {
|
||||
Add(ctx domain.RequestContext, account account.Account) (err error)
|
||||
GetUserAccount(ctx domain.RequestContext, userID string) (account account.Account, err error)
|
||||
GetUserAccounts(ctx domain.RequestContext, userID string) (t []account.Account, err error)
|
||||
GetAccountsByOrg(ctx domain.RequestContext) (t []account.Account, err error)
|
||||
DeleteAccount(ctx domain.RequestContext, ID string) (rows int64, err error)
|
||||
UpdateAccount(ctx domain.RequestContext, account account.Account) (err error)
|
||||
HasOrgAccount(ctx domain.RequestContext, orgID, userID string) bool
|
||||
CountOrgAccounts(ctx domain.RequestContext) int
|
||||
}
|
||||
|
||||
// OrganizationStorer defines required methods for organization management
|
||||
type OrganizationStorer interface {
|
||||
AddOrganization(ctx domain.RequestContext, org org.Organization) error
|
||||
GetOrganization(ctx domain.RequestContext, id string) (org org.Organization, err error)
|
||||
GetOrganizationByDomain(subdomain string) (org org.Organization, err error)
|
||||
UpdateOrganization(ctx domain.RequestContext, org org.Organization) (err error)
|
||||
DeleteOrganization(ctx domain.RequestContext, orgID string) (rows int64, err error)
|
||||
RemoveOrganization(ctx domain.RequestContext, orgID string) (err error)
|
||||
UpdateAuthConfig(ctx domain.RequestContext, org org.Organization) (err error)
|
||||
CheckDomain(ctx domain.RequestContext, domain string) string
|
||||
}
|
||||
|
||||
// PinStorer defines required methods for pin management
|
||||
type PinStorer interface {
|
||||
Add(ctx domain.RequestContext, pin pin.Pin) (err error)
|
||||
GetPin(ctx domain.RequestContext, id string) (pin pin.Pin, err error)
|
||||
GetUserPins(ctx domain.RequestContext, userID string) (pins []pin.Pin, err error)
|
||||
UpdatePin(ctx domain.RequestContext, pin pin.Pin) (err error)
|
||||
UpdatePinSequence(ctx domain.RequestContext, pinID string, sequence int) (err error)
|
||||
DeletePin(ctx domain.RequestContext, id string) (rows int64, err error)
|
||||
DeletePinnedSpace(ctx domain.RequestContext, spaceID string) (rows int64, err error)
|
||||
DeletePinnedDocument(ctx domain.RequestContext, documentID string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// AuditStorer defines required methods for audit trails
|
||||
type AuditStorer interface {
|
||||
// Record logs audit entry using own DB Transaction
|
||||
Record(ctx domain.RequestContext, t audit.EventType)
|
||||
}
|
||||
|
||||
// DocumentStorer defines required methods for document handling
|
||||
type DocumentStorer interface {
|
||||
Add(ctx domain.RequestContext, document doc.Document) (err error)
|
||||
Get(ctx domain.RequestContext, id string) (document doc.Document, err error)
|
||||
GetBySpace(ctx domain.RequestContext, spaceID string) (documents []doc.Document, err error)
|
||||
TemplatesBySpace(ctx domain.RequestContext, spaceID string) (documents []doc.Document, err error)
|
||||
PublicDocuments(ctx domain.RequestContext, orgID string) (documents []doc.SitemapDocument, err error)
|
||||
Update(ctx domain.RequestContext, document doc.Document) (err error)
|
||||
UpdateGroup(ctx domain.RequestContext, document doc.Document) (err error)
|
||||
ChangeDocumentSpace(ctx domain.RequestContext, document, space string) (err error)
|
||||
MoveDocumentSpace(ctx domain.RequestContext, id, move string) (err error)
|
||||
Delete(ctx domain.RequestContext, documentID string) (rows int64, err error)
|
||||
DeleteBySpace(ctx domain.RequestContext, spaceID string) (rows int64, err error)
|
||||
GetVersions(ctx domain.RequestContext, groupID string) (v []doc.Version, err error)
|
||||
MoveActivity(ctx domain.RequestContext, documentID, oldSpaceID, newSpaceID string) (err error)
|
||||
Vote(ctx domain.RequestContext, refID, orgID, documentID, userID string, vote int) (err error)
|
||||
}
|
||||
|
||||
// SettingStorer defines required methods for persisting global and user level settings
|
||||
type SettingStorer interface {
|
||||
Get(area, path string) (val string, err error)
|
||||
Set(area, value string) error
|
||||
GetUser(orgID, userID, area, path string) (val string, err error)
|
||||
SetUser(orgID, userID, area, json string) error
|
||||
}
|
||||
|
||||
// AttachmentStorer defines required methods for persisting document attachments
|
||||
type AttachmentStorer interface {
|
||||
Add(ctx domain.RequestContext, a attachment.Attachment) (err error)
|
||||
GetAttachment(ctx domain.RequestContext, orgID, attachmentID string) (a attachment.Attachment, err error)
|
||||
GetAttachments(ctx domain.RequestContext, docID string) (a []attachment.Attachment, err error)
|
||||
GetAttachmentsWithData(ctx domain.RequestContext, docID string) (a []attachment.Attachment, err error)
|
||||
Delete(ctx domain.RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// LinkStorer defines required methods for persisting content links
|
||||
type LinkStorer interface {
|
||||
Add(ctx domain.RequestContext, l link.Link) (err error)
|
||||
SearchCandidates(ctx domain.RequestContext, keywords string) (docs []link.Candidate, pages []link.Candidate, attachments []link.Candidate, err error)
|
||||
GetDocumentOutboundLinks(ctx domain.RequestContext, documentID string) (links []link.Link, err error)
|
||||
GetPageLinks(ctx domain.RequestContext, documentID, pageID string) (links []link.Link, err error)
|
||||
MarkOrphanDocumentLink(ctx domain.RequestContext, documentID string) (err error)
|
||||
MarkOrphanPageLink(ctx domain.RequestContext, pageID string) (err error)
|
||||
MarkOrphanAttachmentLink(ctx domain.RequestContext, attachmentID string) (err error)
|
||||
DeleteSourcePageLinks(ctx domain.RequestContext, pageID string) (rows int64, err error)
|
||||
DeleteSourceDocumentLinks(ctx domain.RequestContext, documentID string) (rows int64, err error)
|
||||
DeleteLink(ctx domain.RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// ActivityStorer defines required methods for persisting document activity
|
||||
type ActivityStorer interface {
|
||||
RecordUserActivity(ctx domain.RequestContext, activity activity.UserActivity) (err error)
|
||||
GetDocumentActivity(ctx domain.RequestContext, id string) (a []activity.DocumentActivity, err error)
|
||||
DeleteDocumentChangeActivity(ctx domain.RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// SearchStorer defines required methods for persisting search queries
|
||||
type SearchStorer interface {
|
||||
IndexDocument(ctx domain.RequestContext, doc doc.Document, a []attachment.Attachment) (err error)
|
||||
DeleteDocument(ctx domain.RequestContext, ID string) (err error)
|
||||
IndexContent(ctx domain.RequestContext, p page.Page) (err error)
|
||||
DeleteContent(ctx domain.RequestContext, pageID string) (err error)
|
||||
Documents(ctx domain.RequestContext, q search.QueryOptions) (results []search.QueryResult, err error)
|
||||
}
|
||||
|
||||
// Indexer defines required methods for managing search indexing process
|
||||
type Indexer interface {
|
||||
IndexDocument(ctx domain.RequestContext, d doc.Document, a []attachment.Attachment)
|
||||
DeleteDocument(ctx domain.RequestContext, ID string)
|
||||
IndexContent(ctx domain.RequestContext, p page.Page)
|
||||
DeleteContent(ctx domain.RequestContext, pageID string)
|
||||
}
|
||||
|
||||
// BlockStorer defines required methods for persisting reusable content blocks
|
||||
type BlockStorer interface {
|
||||
Add(ctx domain.RequestContext, b block.Block) (err error)
|
||||
Get(ctx domain.RequestContext, id string) (b block.Block, err error)
|
||||
GetBySpace(ctx domain.RequestContext, spaceID string) (b []block.Block, err error)
|
||||
IncrementUsage(ctx domain.RequestContext, id string) (err error)
|
||||
DecrementUsage(ctx domain.RequestContext, id string) (err error)
|
||||
RemoveReference(ctx domain.RequestContext, id string) (err error)
|
||||
Update(ctx domain.RequestContext, b block.Block) (err error)
|
||||
Delete(ctx domain.RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// PageStorer defines required methods for persisting document pages
|
||||
type PageStorer interface {
|
||||
Add(ctx domain.RequestContext, model page.NewPage) (err error)
|
||||
Get(ctx domain.RequestContext, pageID string) (p page.Page, err error)
|
||||
GetPages(ctx domain.RequestContext, documentID string) (p []page.Page, err error)
|
||||
GetUnpublishedPages(ctx domain.RequestContext, documentID string) (p []page.Page, err error)
|
||||
GetPagesWithoutContent(ctx domain.RequestContext, documentID string) (pages []page.Page, err error)
|
||||
Update(ctx domain.RequestContext, page page.Page, refID, userID string, skipRevision bool) (err error)
|
||||
Delete(ctx domain.RequestContext, documentID, pageID string) (rows int64, err error)
|
||||
GetPageMeta(ctx domain.RequestContext, pageID string) (meta page.Meta, err error)
|
||||
GetDocumentPageMeta(ctx domain.RequestContext, documentID string, externalSourceOnly bool) (meta []page.Meta, err error)
|
||||
UpdateMeta(ctx domain.RequestContext, meta page.Meta, updateUserID bool) (err error)
|
||||
UpdateSequence(ctx domain.RequestContext, documentID, pageID string, sequence float64) (err error)
|
||||
UpdateLevel(ctx domain.RequestContext, documentID, pageID string, level int) (err error)
|
||||
UpdateLevelSequence(ctx domain.RequestContext, documentID, pageID string, level int, sequence float64) (err error)
|
||||
GetNextPageSequence(ctx domain.RequestContext, documentID string) (maxSeq float64, err error)
|
||||
GetPageRevision(ctx domain.RequestContext, revisionID string) (revision page.Revision, err error)
|
||||
GetPageRevisions(ctx domain.RequestContext, pageID string) (revisions []page.Revision, err error)
|
||||
GetDocumentRevisions(ctx domain.RequestContext, documentID string) (revisions []page.Revision, err error)
|
||||
DeletePageRevisions(ctx domain.RequestContext, pageID string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// GroupStorer defines required methods for persisting user groups and memberships
|
||||
type GroupStorer interface {
|
||||
Add(ctx domain.RequestContext, g group.Group) (err error)
|
||||
Get(ctx domain.RequestContext, refID string) (g group.Group, err error)
|
||||
GetAll(ctx domain.RequestContext) (g []group.Group, err error)
|
||||
Update(ctx domain.RequestContext, g group.Group) (err error)
|
||||
Delete(ctx domain.RequestContext, refID string) (rows int64, err error)
|
||||
GetGroupMembers(ctx domain.RequestContext, groupID string) (m []group.Member, err error)
|
||||
GetMembers(ctx domain.RequestContext) (r []group.Record, err error)
|
||||
JoinGroup(ctx domain.RequestContext, groupID, userID string) (err error)
|
||||
LeaveGroup(ctx domain.RequestContext, groupID, userID string) (err error)
|
||||
}
|
||||
|
||||
// MetaStorer provide specialist methods for global administrators.
|
||||
type MetaStorer interface {
|
||||
GetDocumentsID(ctx domain.RequestContext) (documents []string, err error)
|
||||
GetDocumentPages(ctx domain.RequestContext, documentID string) (p []page.Page, err error)
|
||||
SearchIndexCount(ctx domain.RequestContext) (c int, err error)
|
||||
}
|
296
domain/storer.go
296
domain/storer.go
|
@ -1,296 +0,0 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
// Package domain ...
|
||||
package domain
|
||||
|
||||
import (
|
||||
"github.com/documize/community/model/account"
|
||||
"github.com/documize/community/model/activity"
|
||||
"github.com/documize/community/model/attachment"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/block"
|
||||
"github.com/documize/community/model/category"
|
||||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/group"
|
||||
"github.com/documize/community/model/link"
|
||||
"github.com/documize/community/model/org"
|
||||
"github.com/documize/community/model/page"
|
||||
"github.com/documize/community/model/permission"
|
||||
"github.com/documize/community/model/pin"
|
||||
"github.com/documize/community/model/search"
|
||||
"github.com/documize/community/model/space"
|
||||
"github.com/documize/community/model/user"
|
||||
)
|
||||
|
||||
// Store provides access to data store (database)
|
||||
type Store struct {
|
||||
Account AccountStorer
|
||||
Activity ActivityStorer
|
||||
Attachment AttachmentStorer
|
||||
Audit AuditStorer
|
||||
Block BlockStorer
|
||||
Category CategoryStorer
|
||||
Document DocumentStorer
|
||||
Group GroupStorer
|
||||
Link LinkStorer
|
||||
Meta MetaStorer
|
||||
Organization OrganizationStorer
|
||||
Page PageStorer
|
||||
Pin PinStorer
|
||||
Permission PermissionStorer
|
||||
Search SearchStorer
|
||||
Setting SettingStorer
|
||||
Space SpaceStorer
|
||||
User UserStorer
|
||||
}
|
||||
|
||||
// SpaceStorer defines required methods for space management
|
||||
type SpaceStorer interface {
|
||||
Add(ctx RequestContext, sp space.Space) (err error)
|
||||
Get(ctx RequestContext, id string) (sp space.Space, err error)
|
||||
PublicSpaces(ctx RequestContext, orgID string) (sp []space.Space, err error)
|
||||
GetViewable(ctx RequestContext) (sp []space.Space, err error)
|
||||
GetAll(ctx RequestContext) (sp []space.Space, err error)
|
||||
Update(ctx RequestContext, sp space.Space) (err error)
|
||||
Delete(ctx RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// CategoryStorer defines required methods for category and category membership management
|
||||
type CategoryStorer interface {
|
||||
Add(ctx RequestContext, c category.Category) (err error)
|
||||
Update(ctx RequestContext, c category.Category) (err error)
|
||||
Get(ctx RequestContext, id string) (c category.Category, err error)
|
||||
GetBySpace(ctx RequestContext, spaceID string) (c []category.Category, err error)
|
||||
GetAllBySpace(ctx RequestContext, spaceID string) (c []category.Category, err error)
|
||||
GetSpaceCategorySummary(ctx RequestContext, spaceID string) (c []category.SummaryModel, err error)
|
||||
Delete(ctx RequestContext, id string) (rows int64, err error)
|
||||
AssociateDocument(ctx RequestContext, m category.Member) (err error)
|
||||
DisassociateDocument(ctx RequestContext, categoryID, documentID string) (rows int64, err error)
|
||||
RemoveCategoryMembership(ctx RequestContext, categoryID string) (rows int64, err error)
|
||||
DeleteBySpace(ctx RequestContext, spaceID string) (rows int64, err error)
|
||||
GetDocumentCategoryMembership(ctx RequestContext, documentID string) (c []category.Category, err error)
|
||||
GetSpaceCategoryMembership(ctx RequestContext, spaceID string) (c []category.Member, err error)
|
||||
RemoveDocumentCategories(ctx RequestContext, documentID string) (rows int64, err error)
|
||||
RemoveSpaceCategoryMemberships(ctx RequestContext, spaceID string) (rows int64, err error)
|
||||
GetByOrg(ctx RequestContext, userID string) (c []category.Category, err error)
|
||||
GetOrgCategoryMembership(ctx RequestContext, userID string) (c []category.Member, err error)
|
||||
}
|
||||
|
||||
// PermissionStorer defines required methods for space/document permission management
|
||||
type PermissionStorer interface {
|
||||
AddPermission(ctx RequestContext, r permission.Permission) (err error)
|
||||
AddPermissions(ctx RequestContext, r permission.Permission, actions ...permission.Action) (err error)
|
||||
GetUserSpacePermissions(ctx RequestContext, spaceID string) (r []permission.Permission, err error)
|
||||
GetSpacePermissionsForUser(ctx RequestContext, spaceID, userID string) (r []permission.Permission, err error)
|
||||
GetSpacePermissions(ctx RequestContext, spaceID string) (r []permission.Permission, err error)
|
||||
GetCategoryPermissions(ctx RequestContext, catID string) (r []permission.Permission, err error)
|
||||
GetCategoryUsers(ctx RequestContext, catID string) (u []user.User, err error)
|
||||
GetUserCategoryPermissions(ctx RequestContext, userID string) (r []permission.Permission, err error)
|
||||
GetUserDocumentPermissions(ctx RequestContext, documentID string) (r []permission.Permission, err error)
|
||||
GetDocumentPermissions(ctx RequestContext, documentID string) (r []permission.Permission, err error)
|
||||
DeleteDocumentPermissions(ctx RequestContext, documentID string) (rows int64, err error)
|
||||
DeleteSpacePermissions(ctx RequestContext, spaceID string) (rows int64, err error)
|
||||
DeleteUserSpacePermissions(ctx RequestContext, spaceID, userID string) (rows int64, err error)
|
||||
DeleteUserPermissions(ctx RequestContext, userID string) (rows int64, err error)
|
||||
DeleteCategoryPermissions(ctx RequestContext, categoryID string) (rows int64, err error)
|
||||
DeleteSpaceCategoryPermissions(ctx RequestContext, spaceID string) (rows int64, err error)
|
||||
DeleteGroupPermissions(ctx RequestContext, groupID string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// UserStorer defines required methods for user management
|
||||
type UserStorer interface {
|
||||
Add(ctx RequestContext, u user.User) (err error)
|
||||
Get(ctx RequestContext, id string) (u user.User, err error)
|
||||
GetByDomain(ctx RequestContext, domain, email string) (u user.User, err error)
|
||||
GetByEmail(ctx RequestContext, email string) (u user.User, err error)
|
||||
GetByToken(ctx RequestContext, token string) (u user.User, err error)
|
||||
GetBySerial(ctx RequestContext, serial string) (u user.User, err error)
|
||||
GetActiveUsersForOrganization(ctx RequestContext) (u []user.User, err error)
|
||||
GetUsersForOrganization(ctx RequestContext, filter string, limit int) (u []user.User, err error)
|
||||
GetSpaceUsers(ctx RequestContext, spaceID string) (u []user.User, err error)
|
||||
GetUsersForSpaces(ctx RequestContext, spaces []string) (u []user.User, err error)
|
||||
UpdateUser(ctx RequestContext, u user.User) (err error)
|
||||
UpdateUserPassword(ctx RequestContext, userID, salt, password string) (err error)
|
||||
DeactiveUser(ctx RequestContext, userID string) (err error)
|
||||
ForgotUserPassword(ctx RequestContext, email, token string) (err error)
|
||||
CountActiveUsers() (c int)
|
||||
MatchUsers(ctx RequestContext, text string, maxMatches int) (u []user.User, err error)
|
||||
}
|
||||
|
||||
// AccountStorer defines required methods for account management
|
||||
type AccountStorer interface {
|
||||
Add(ctx RequestContext, account account.Account) (err error)
|
||||
GetUserAccount(ctx RequestContext, userID string) (account account.Account, err error)
|
||||
GetUserAccounts(ctx RequestContext, userID string) (t []account.Account, err error)
|
||||
GetAccountsByOrg(ctx RequestContext) (t []account.Account, err error)
|
||||
DeleteAccount(ctx RequestContext, ID string) (rows int64, err error)
|
||||
UpdateAccount(ctx RequestContext, account account.Account) (err error)
|
||||
HasOrgAccount(ctx RequestContext, orgID, userID string) bool
|
||||
CountOrgAccounts(ctx RequestContext) int
|
||||
}
|
||||
|
||||
// OrganizationStorer defines required methods for organization management
|
||||
type OrganizationStorer interface {
|
||||
AddOrganization(ctx RequestContext, org org.Organization) error
|
||||
GetOrganization(ctx RequestContext, id string) (org org.Organization, err error)
|
||||
GetOrganizationByDomain(subdomain string) (org org.Organization, err error)
|
||||
UpdateOrganization(ctx RequestContext, org org.Organization) (err error)
|
||||
DeleteOrganization(ctx RequestContext, orgID string) (rows int64, err error)
|
||||
RemoveOrganization(ctx RequestContext, orgID string) (err error)
|
||||
UpdateAuthConfig(ctx RequestContext, org org.Organization) (err error)
|
||||
CheckDomain(ctx RequestContext, domain string) string
|
||||
}
|
||||
|
||||
// PinStorer defines required methods for pin management
|
||||
type PinStorer interface {
|
||||
Add(ctx RequestContext, pin pin.Pin) (err error)
|
||||
GetPin(ctx RequestContext, id string) (pin pin.Pin, err error)
|
||||
GetUserPins(ctx RequestContext, userID string) (pins []pin.Pin, err error)
|
||||
UpdatePin(ctx RequestContext, pin pin.Pin) (err error)
|
||||
UpdatePinSequence(ctx RequestContext, pinID string, sequence int) (err error)
|
||||
DeletePin(ctx RequestContext, id string) (rows int64, err error)
|
||||
DeletePinnedSpace(ctx RequestContext, spaceID string) (rows int64, err error)
|
||||
DeletePinnedDocument(ctx RequestContext, documentID string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// AuditStorer defines required methods for audit trails
|
||||
type AuditStorer interface {
|
||||
// Record logs audit entry using own DB Transaction
|
||||
Record(ctx RequestContext, t audit.EventType)
|
||||
}
|
||||
|
||||
// DocumentStorer defines required methods for document handling
|
||||
type DocumentStorer interface {
|
||||
Add(ctx RequestContext, document doc.Document) (err error)
|
||||
Get(ctx RequestContext, id string) (document doc.Document, err error)
|
||||
GetBySpace(ctx RequestContext, spaceID string) (documents []doc.Document, err error)
|
||||
TemplatesBySpace(ctx RequestContext, spaceID string) (documents []doc.Document, err error)
|
||||
PublicDocuments(ctx RequestContext, orgID string) (documents []doc.SitemapDocument, err error)
|
||||
Update(ctx RequestContext, document doc.Document) (err error)
|
||||
UpdateGroup(ctx RequestContext, document doc.Document) (err error)
|
||||
ChangeDocumentSpace(ctx RequestContext, document, space string) (err error)
|
||||
MoveDocumentSpace(ctx RequestContext, id, move string) (err error)
|
||||
Delete(ctx RequestContext, documentID string) (rows int64, err error)
|
||||
DeleteBySpace(ctx RequestContext, spaceID string) (rows int64, err error)
|
||||
GetVersions(ctx RequestContext, groupID string) (v []doc.Version, err error)
|
||||
MoveActivity(ctx RequestContext, documentID, oldSpaceID, newSpaceID string) (err error)
|
||||
Vote(ctx RequestContext, refID, orgID, documentID, userID string, vote int) (err error)
|
||||
}
|
||||
|
||||
// SettingStorer defines required methods for persisting global and user level settings
|
||||
type SettingStorer interface {
|
||||
Get(area, path string) (val string, err error)
|
||||
Set(area, value string) error
|
||||
GetUser(orgID, userID, area, path string) (val string, err error)
|
||||
SetUser(orgID, userID, area, json string) error
|
||||
}
|
||||
|
||||
// AttachmentStorer defines required methods for persisting document attachments
|
||||
type AttachmentStorer interface {
|
||||
Add(ctx RequestContext, a attachment.Attachment) (err error)
|
||||
GetAttachment(ctx RequestContext, orgID, attachmentID string) (a attachment.Attachment, err error)
|
||||
GetAttachments(ctx RequestContext, docID string) (a []attachment.Attachment, err error)
|
||||
GetAttachmentsWithData(ctx RequestContext, docID string) (a []attachment.Attachment, err error)
|
||||
Delete(ctx RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// LinkStorer defines required methods for persisting content links
|
||||
type LinkStorer interface {
|
||||
Add(ctx RequestContext, l link.Link) (err error)
|
||||
SearchCandidates(ctx RequestContext, keywords string) (docs []link.Candidate, pages []link.Candidate, attachments []link.Candidate, err error)
|
||||
GetDocumentOutboundLinks(ctx RequestContext, documentID string) (links []link.Link, err error)
|
||||
GetPageLinks(ctx RequestContext, documentID, pageID string) (links []link.Link, err error)
|
||||
MarkOrphanDocumentLink(ctx RequestContext, documentID string) (err error)
|
||||
MarkOrphanPageLink(ctx RequestContext, pageID string) (err error)
|
||||
MarkOrphanAttachmentLink(ctx RequestContext, attachmentID string) (err error)
|
||||
DeleteSourcePageLinks(ctx RequestContext, pageID string) (rows int64, err error)
|
||||
DeleteSourceDocumentLinks(ctx RequestContext, documentID string) (rows int64, err error)
|
||||
DeleteLink(ctx RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// ActivityStorer defines required methods for persisting document activity
|
||||
type ActivityStorer interface {
|
||||
RecordUserActivity(ctx RequestContext, activity activity.UserActivity) (err error)
|
||||
GetDocumentActivity(ctx RequestContext, id string) (a []activity.DocumentActivity, err error)
|
||||
DeleteDocumentChangeActivity(ctx RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// SearchStorer defines required methods for persisting search queries
|
||||
type SearchStorer interface {
|
||||
IndexDocument(ctx RequestContext, doc doc.Document, a []attachment.Attachment) (err error)
|
||||
DeleteDocument(ctx RequestContext, ID string) (err error)
|
||||
IndexContent(ctx RequestContext, p page.Page) (err error)
|
||||
DeleteContent(ctx RequestContext, pageID string) (err error)
|
||||
Documents(ctx RequestContext, q search.QueryOptions) (results []search.QueryResult, err error)
|
||||
}
|
||||
|
||||
// Indexer defines required methods for managing search indexing process
|
||||
type Indexer interface {
|
||||
IndexDocument(ctx RequestContext, d doc.Document, a []attachment.Attachment)
|
||||
DeleteDocument(ctx RequestContext, ID string)
|
||||
IndexContent(ctx RequestContext, p page.Page)
|
||||
DeleteContent(ctx RequestContext, pageID string)
|
||||
}
|
||||
|
||||
// BlockStorer defines required methods for persisting reusable content blocks
|
||||
type BlockStorer interface {
|
||||
Add(ctx RequestContext, b block.Block) (err error)
|
||||
Get(ctx RequestContext, id string) (b block.Block, err error)
|
||||
GetBySpace(ctx RequestContext, spaceID string) (b []block.Block, err error)
|
||||
IncrementUsage(ctx RequestContext, id string) (err error)
|
||||
DecrementUsage(ctx RequestContext, id string) (err error)
|
||||
RemoveReference(ctx RequestContext, id string) (err error)
|
||||
Update(ctx RequestContext, b block.Block) (err error)
|
||||
Delete(ctx RequestContext, id string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// PageStorer defines required methods for persisting document pages
|
||||
type PageStorer interface {
|
||||
Add(ctx RequestContext, model page.NewPage) (err error)
|
||||
Get(ctx RequestContext, pageID string) (p page.Page, err error)
|
||||
GetPages(ctx RequestContext, documentID string) (p []page.Page, err error)
|
||||
GetUnpublishedPages(ctx RequestContext, documentID string) (p []page.Page, err error)
|
||||
GetPagesWithoutContent(ctx RequestContext, documentID string) (pages []page.Page, err error)
|
||||
Update(ctx RequestContext, page page.Page, refID, userID string, skipRevision bool) (err error)
|
||||
Delete(ctx RequestContext, documentID, pageID string) (rows int64, err error)
|
||||
GetPageMeta(ctx RequestContext, pageID string) (meta page.Meta, err error)
|
||||
GetDocumentPageMeta(ctx RequestContext, documentID string, externalSourceOnly bool) (meta []page.Meta, err error)
|
||||
UpdateMeta(ctx RequestContext, meta page.Meta, updateUserID bool) (err error)
|
||||
UpdateSequence(ctx RequestContext, documentID, pageID string, sequence float64) (err error)
|
||||
UpdateLevel(ctx RequestContext, documentID, pageID string, level int) (err error)
|
||||
UpdateLevelSequence(ctx RequestContext, documentID, pageID string, level int, sequence float64) (err error)
|
||||
GetNextPageSequence(ctx RequestContext, documentID string) (maxSeq float64, err error)
|
||||
GetPageRevision(ctx RequestContext, revisionID string) (revision page.Revision, err error)
|
||||
GetPageRevisions(ctx RequestContext, pageID string) (revisions []page.Revision, err error)
|
||||
GetDocumentRevisions(ctx RequestContext, documentID string) (revisions []page.Revision, err error)
|
||||
DeletePageRevisions(ctx RequestContext, pageID string) (rows int64, err error)
|
||||
}
|
||||
|
||||
// GroupStorer defines required methods for persisting user groups and memberships
|
||||
type GroupStorer interface {
|
||||
Add(ctx RequestContext, g group.Group) (err error)
|
||||
Get(ctx RequestContext, refID string) (g group.Group, err error)
|
||||
GetAll(ctx RequestContext) (g []group.Group, err error)
|
||||
Update(ctx RequestContext, g group.Group) (err error)
|
||||
Delete(ctx RequestContext, refID string) (rows int64, err error)
|
||||
GetGroupMembers(ctx RequestContext, groupID string) (m []group.Member, err error)
|
||||
GetMembers(ctx RequestContext) (r []group.Record, err error)
|
||||
JoinGroup(ctx RequestContext, groupID, userID string) (err error)
|
||||
LeaveGroup(ctx RequestContext, groupID, userID string) (err error)
|
||||
}
|
||||
|
||||
// MetaStorer provide specialist methods for global administrators.
|
||||
type MetaStorer interface {
|
||||
GetDocumentsID(ctx RequestContext) (documents []string, err error)
|
||||
GetDocumentPages(ctx RequestContext, documentID string) (p []page.Page, err error)
|
||||
SearchIndexCount(ctx RequestContext) (c int, err error)
|
||||
}
|
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/permission"
|
||||
indexer "github.com/documize/community/domain/search"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/attachment"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/doc"
|
||||
|
@ -43,7 +44,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
Indexer indexer.Indexer
|
||||
}
|
||||
|
||||
|
@ -262,7 +263,7 @@ func (h *Handler) SaveAs(w http.ResponseWriter, r *http.Request) {
|
|||
// Use creates new document using a saved document as a template.
|
||||
// If template ID is ZERO then we provide an Empty Document as the new document.
|
||||
func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
|
||||
method := "template.saved"
|
||||
method := "template.use"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
folderID := request.Param(r, "folderID")
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/mail"
|
||||
"github.com/documize/community/domain/organization"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/account"
|
||||
"github.com/documize/community/model/audit"
|
||||
"github.com/documize/community/model/group"
|
||||
|
@ -42,7 +43,7 @@ import (
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// Add is the endpoint that enables an administrator to add a new user for their organization.
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
// Store provides data access to space information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.UserStorer
|
||||
store.UserStorer
|
||||
}
|
||||
|
||||
// Add adds the given user record to the user table.
|
||||
|
@ -153,7 +153,7 @@ func (s Store) GetActiveUsersForOrganization(ctx domain.RequestContext) (u []use
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? AND a.c_active=1
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? AND a.c_active=true
|
||||
ORDER BY u.c_firstname, u.c_lastname`),
|
||||
ctx.OrgID)
|
||||
|
||||
|
@ -210,7 +210,7 @@ func (s Store) GetSpaceUsers(ctx domain.RequestContext, spaceID string) (u []use
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=1 AND u.c_refid IN (
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=true AND u.c_refid IN (
|
||||
SELECT c_whoid from dmz_permission WHERE c_orgid=? AND c_who='user' AND c_scope='object' AND c_location='space' AND c_refid=?
|
||||
UNION ALL
|
||||
SELECT r.c_userid from dmz_group_member r LEFT JOIN dmz_permission p ON p.c_whoid=r.c_groupid WHERE p.c_orgid=? AND p.c_who='role' AND p.c_scope='object' AND p.c_location='space' AND p.c_refid=?
|
||||
|
@ -244,7 +244,7 @@ func (s Store) GetUsersForSpaces(ctx domain.RequestContext, spaces []string) (u
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=1 AND u.c_refid IN (
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=true AND u.c_refid IN (
|
||||
SELECT c_whoid from dmz_permission WHERE c_orgid=? AND c_who='user' AND c_scope='object' AND c_location='space' AND c_refid IN(?)
|
||||
UNION ALL
|
||||
SELECT r.c_userid from dmz_group_member r LEFT JOIN dmz_permission p ON p.c_whoid=r.c_groupid WHERE p.c_orgid=? AND p.c_who='role' AND p.c_scope='object' AND p.c_location='space' AND p.c_refid IN(?)
|
||||
|
@ -313,7 +313,7 @@ func (s Store) ForgotUserPassword(ctx domain.RequestContext, email, token string
|
|||
|
||||
// CountActiveUsers returns the number of active users in the system.
|
||||
func (s Store) CountActiveUsers() (c int) {
|
||||
row := s.Runtime.Db.QueryRow("SELECT count(*) FROM dmz_user WHERE c_refid IN (SELECT c_userid FROM dmz_user_account WHERE c_active=1)")
|
||||
row := s.Runtime.Db.QueryRow("SELECT count(*) FROM dmz_user WHERE c_refid IN (SELECT c_userid FROM dmz_user_account WHERE c_active=true)")
|
||||
|
||||
err := row.Scan(&c)
|
||||
if err == sql.ErrNoRows {
|
||||
|
@ -346,7 +346,7 @@ func (s Store) MatchUsers(ctx domain.RequestContext, text string, maxMatches int
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE a.c_orgid=? AND u.c_refid=a.c_userid AND a.c_active=1 `+likeQuery+` ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(maxMatches)),
|
||||
WHERE a.c_orgid=? AND u.c_refid=a.c_userid AND a.c_active=true `+likeQuery+` ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(maxMatches)),
|
||||
ctx.OrgID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
|
|
@ -13,12 +13,13 @@ package user
|
|||
|
||||
import (
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/user"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetSecuredUser contain associated accounts but credentials are wiped.
|
||||
func GetSecuredUser(ctx domain.RequestContext, s domain.Store, orgID, id string) (u user.User, err error) {
|
||||
func GetSecuredUser(ctx domain.RequestContext, s store.Store, orgID, id string) (u user.User, err error) {
|
||||
u, err = s.User.Get(ctx, id)
|
||||
AttachUserAccounts(ctx, s, orgID, &u)
|
||||
|
||||
|
@ -26,7 +27,7 @@ func GetSecuredUser(ctx domain.RequestContext, s domain.Store, orgID, id string)
|
|||
}
|
||||
|
||||
// AttachUserAccounts attachs user accounts to user object.
|
||||
func AttachUserAccounts(ctx domain.RequestContext, s domain.Store, orgID string, u *user.User) {
|
||||
func AttachUserAccounts(ctx domain.RequestContext, s store.Store, orgID string, u *user.User) {
|
||||
u.ProtectSecrets()
|
||||
|
||||
a, err := s.Account.GetUserAccounts(ctx, u.RefID)
|
||||
|
|
|
@ -18,13 +18,13 @@ import (
|
|||
"github.com/documize/community/core/database"
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/secrets"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/edition/storage"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
// InitRuntime prepares runtime using command line and environment variables.
|
||||
func InitRuntime(r *env.Runtime, s *domain.Store) bool {
|
||||
func InitRuntime(r *env.Runtime, s *store.Store) bool {
|
||||
// We need SALT to hash auth JWT tokens
|
||||
if r.Flags.Salt == "" {
|
||||
r.Flags.Salt = secrets.RandSalt()
|
||||
|
|
|
@ -16,8 +16,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/section"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/edition/boot"
|
||||
"github.com/documize/community/edition/logging"
|
||||
"github.com/documize/community/embed"
|
||||
|
@ -52,7 +52,7 @@ func main() {
|
|||
rt.Product.License.Edition = "Community"
|
||||
|
||||
// setup store
|
||||
s := domain.Store{}
|
||||
s := store.Store{}
|
||||
|
||||
// parse settings from command line and environment
|
||||
rt.Flags = env.ParseFlags()
|
||||
|
|
|
@ -19,7 +19,6 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
account "github.com/documize/community/domain/account"
|
||||
activity "github.com/documize/community/domain/activity"
|
||||
attachment "github.com/documize/community/domain/attachment"
|
||||
|
@ -37,12 +36,13 @@ import (
|
|||
search "github.com/documize/community/domain/search"
|
||||
setting "github.com/documize/community/domain/setting"
|
||||
space "github.com/documize/community/domain/space"
|
||||
"github.com/documize/community/domain/store"
|
||||
user "github.com/documize/community/domain/user"
|
||||
_ "github.com/go-sql-driver/mysql" // the mysql driver is required behind the scenes
|
||||
)
|
||||
|
||||
// SetMySQLProvider creates MySQL provider
|
||||
func SetMySQLProvider(r *env.Runtime, s *domain.Store) {
|
||||
func SetMySQLProvider(r *env.Runtime, s *store.Store) {
|
||||
// Set up provider specific details and wire up data prividers.
|
||||
r.StoreProvider = MySQLProvider{
|
||||
ConnectionString: r.Flags.DBConn,
|
||||
|
@ -296,9 +296,13 @@ func (p MySQLProvider) JSONEmpty() string {
|
|||
// JSONGetValue returns JSON attribute selection syntax.
|
||||
// Typically used in SELECT <my_json_field> query.
|
||||
func (p MySQLProvider) JSONGetValue(column, attribute string) string {
|
||||
if len(attribute) > 0 {
|
||||
return fmt.Sprintf("JSON_EXTRACT(%s,'$.%s')", column, attribute)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("JSON_EXTRACT(%s,'$')", column)
|
||||
}
|
||||
|
||||
// VerfiyVersion checks to see if actual database meets
|
||||
// minimum version requirements.``
|
||||
func (p MySQLProvider) VerfiyVersion(dbVersion string) (bool, string) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
account "github.com/documize/community/domain/account"
|
||||
activity "github.com/documize/community/domain/activity"
|
||||
attachment "github.com/documize/community/domain/attachment"
|
||||
|
@ -35,6 +34,7 @@ import (
|
|||
search "github.com/documize/community/domain/search"
|
||||
setting "github.com/documize/community/domain/setting"
|
||||
space "github.com/documize/community/domain/space"
|
||||
"github.com/documize/community/domain/store"
|
||||
user "github.com/documize/community/domain/user"
|
||||
_ "github.com/lib/pq" // the mysql driver is required behind the scenes
|
||||
)
|
||||
|
@ -49,7 +49,7 @@ type PostgreSQLProvider struct {
|
|||
}
|
||||
|
||||
// SetPostgreSQLProvider creates PostgreSQL provider
|
||||
func SetPostgreSQLProvider(r *env.Runtime, s *domain.Store) {
|
||||
func SetPostgreSQLProvider(r *env.Runtime, s *store.Store) {
|
||||
// Set up provider specific details and wire up data prividers.
|
||||
r.StoreProvider = PostgreSQLProvider{
|
||||
ConnectionString: r.Flags.DBConn,
|
||||
|
@ -270,9 +270,13 @@ func (p PostgreSQLProvider) JSONEmpty() string {
|
|||
// JSONGetValue returns JSON attribute selection syntax.
|
||||
// Typically used in SELECT <my_json_field> query.
|
||||
func (p PostgreSQLProvider) JSONGetValue(column, attribute string) string {
|
||||
if len(attribute) > 0 {
|
||||
return fmt.Sprintf("%s -> '%s'", column, attribute)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s", column)
|
||||
}
|
||||
|
||||
// VerfiyVersion checks to see if actual database meets
|
||||
// minimum version requirements.``
|
||||
func (p PostgreSQLProvider) VerfiyVersion(dbVersion string) (bool, string) {
|
||||
|
|
1348
embed/bindata.go
1348
embed/bindata.go
File diff suppressed because one or more lines are too long
|
@ -23,11 +23,11 @@ export default Component.extend(Notifier, {
|
|||
// Jira specific.
|
||||
let jira = this.get('jira');
|
||||
|
||||
if (is.not.object(jira)) {
|
||||
if (is.empty(jira) || is.not.object(jira)) {
|
||||
jira = {
|
||||
url: '',
|
||||
username: '',
|
||||
password: ''
|
||||
secret: ''
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,14 @@
|
|||
{{/if}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{#if isAuthProviderDocumize}}
|
||||
<label for="authPassword">Password</label>
|
||||
{{input type="password" value=password id="authPassword" class="form-control" placeholder="network password" autocomplete="current-password"}}
|
||||
{{input type="password" value=password id="authPassword" class="form-control" autocomplete="current-password"}}
|
||||
{{/if}}
|
||||
{{#if isAuthProviderLDAP}}
|
||||
<label for="authPassword">Network Password</label>
|
||||
{{input type="password" value=password id="authPassword" class="form-control" autocomplete="current-password"}}
|
||||
{{/if}}
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success font-weight-bold text-uppercase mt-4">Sign in</button>
|
||||
<div class="{{unless invalidCredentials "invisible"}} color-red mt-3">Invalid credentials</div>
|
||||
|
|
|
@ -25,13 +25,14 @@ import (
|
|||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/auth"
|
||||
"github.com/documize/community/domain/organization"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/domain/user"
|
||||
"github.com/documize/community/model/org"
|
||||
)
|
||||
|
||||
type middleware struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
func (m *middleware) cors(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/attachment"
|
||||
"github.com/documize/community/domain/auth"
|
||||
"github.com/documize/community/domain/auth/keycloak"
|
||||
|
@ -35,13 +34,14 @@ import (
|
|||
"github.com/documize/community/domain/section"
|
||||
"github.com/documize/community/domain/setting"
|
||||
"github.com/documize/community/domain/space"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/domain/template"
|
||||
"github.com/documize/community/domain/user"
|
||||
"github.com/documize/community/server/web"
|
||||
)
|
||||
|
||||
// RegisterEndpoints register routes for serving API endpoints
|
||||
func RegisterEndpoints(rt *env.Runtime, s *domain.Store) {
|
||||
func RegisterEndpoints(rt *env.Runtime, s *store.Store) {
|
||||
// base services
|
||||
indexer := search.NewIndexer(rt, s)
|
||||
|
||||
|
@ -120,12 +120,12 @@ func RegisterEndpoints(rt *env.Runtime, s *domain.Store) {
|
|||
AddPrivate(rt, "documents/{documentID}/pages/{pageID}/meta", []string{"GET", "OPTIONS"}, nil, page.GetMeta)
|
||||
AddPrivate(rt, "documents/{documentID}/pages/{pageID}/copy/{targetID}", []string{"POST", "OPTIONS"}, nil, page.Copy)
|
||||
|
||||
AddPrivate(rt, "organization/setting", []string{"GET", "OPTIONS"}, nil, organization.GetGlobalSetting)
|
||||
AddPrivate(rt, "organization/setting", []string{"POST", "OPTIONS"}, nil, organization.SaveGlobalSetting)
|
||||
AddPrivate(rt, "organization/setting", []string{"GET", "OPTIONS"}, nil, setting.GetGlobalSetting)
|
||||
AddPrivate(rt, "organization/setting", []string{"POST", "OPTIONS"}, nil, setting.SaveGlobalSetting)
|
||||
AddPrivate(rt, "organization/{orgID}", []string{"GET", "OPTIONS"}, nil, organization.Get)
|
||||
AddPrivate(rt, "organization/{orgID}", []string{"PUT", "OPTIONS"}, nil, organization.Update)
|
||||
AddPrivate(rt, "organization/{orgID}/setting", []string{"GET", "OPTIONS"}, nil, organization.GetInstanceSetting)
|
||||
AddPrivate(rt, "organization/{orgID}/setting", []string{"POST", "OPTIONS"}, nil, organization.SaveInstanceSetting)
|
||||
AddPrivate(rt, "organization/{orgID}/setting", []string{"GET", "OPTIONS"}, nil, setting.GetInstanceSetting)
|
||||
AddPrivate(rt, "organization/{orgID}/setting", []string{"POST", "OPTIONS"}, nil, setting.SaveInstanceSetting)
|
||||
|
||||
AddPrivate(rt, "space/{spaceID}", []string{"DELETE", "OPTIONS"}, nil, space.Delete)
|
||||
AddPrivate(rt, "space/{spaceID}/move/{moveToId}", []string{"DELETE", "OPTIONS"}, nil, space.Remove)
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"github.com/documize/community/core/api/plugins"
|
||||
"github.com/documize/community/core/database"
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/server/routing"
|
||||
"github.com/documize/community/server/web"
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -29,7 +29,7 @@ import (
|
|||
var testHost string // used during automated testing
|
||||
|
||||
// Start router to handle all HTTP traffic.
|
||||
func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
|
||||
func Start(rt *env.Runtime, s *store.Store, ready chan struct{}) {
|
||||
rt.Log.Info(fmt.Sprintf("Product: %s version %s", rt.Product.Title, rt.Product.Version))
|
||||
|
||||
// decide which mode to serve up
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/secrets"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
)
|
||||
|
||||
// SiteInfo describes set-up information about the site
|
||||
|
@ -33,7 +33,7 @@ func init() {
|
|||
// Handler contains the runtime information such as logging and database.
|
||||
type Handler struct {
|
||||
Runtime *env.Runtime
|
||||
Store *domain.Store
|
||||
Store *store.Store
|
||||
}
|
||||
|
||||
// EmberHandler serves HTML web pages
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue