Merge remote-tracking branch 'origin/refactor/sam-to-messaging'
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
.PHONY: nothing docker docker-push realize dep dep.update test test.rbac test.sam test.crm qa critic vet codegen
|
||||
.PHONY: nothing docker docker-push realize dep dep.update test test.rbac test.messaging test.crm qa critic vet codegen
|
||||
|
||||
PKG = "github.com/$(shell cat .project)"
|
||||
|
||||
GO = go
|
||||
GOGET = $(GO) get -u
|
||||
|
||||
BASEPKGS = rbac system crm sam
|
||||
BASEPKGS = rbac system crm messaging
|
||||
IMAGES = system crm messaging
|
||||
|
||||
########################################################################################################################
|
||||
# Tool bins
|
||||
DEP = $(GOPATH)/bin/dep
|
||||
SPEC = $(GOPATH)/bin/spec
|
||||
PROTOC = $(GOPATH)/bin/protoc-gen-go
|
||||
REALIZE = ${GOPATH}/bin/realize
|
||||
GOTEST = ${GOPATH}/bin/gotest
|
||||
GOCRITIC = ${GOPATH}/bin/gocritic
|
||||
@@ -28,7 +26,7 @@ nothing:
|
||||
@echo - vet - run go vet on all code
|
||||
@echo - critic - run go critic on all code
|
||||
@echo - test.crm - individual package unit tests
|
||||
@echo - test.sam - individual package unit tests
|
||||
@echo - test.messaging - individual package unit tests
|
||||
@echo - test.rbac - individual package unit tests
|
||||
@echo - test - run all available unit tests
|
||||
@echo - qa - run vet, critic and test on code
|
||||
@@ -61,7 +59,7 @@ dep.update: $(DEP)
|
||||
dep: $(DEP)
|
||||
$(DEP) ensure -v
|
||||
|
||||
codegen: $(SPEC) dep.codegen
|
||||
codegen: dep.codegen
|
||||
@PATH=${PATH}:${GOPATH}/bin ./codegen.sh
|
||||
|
||||
mailhog.up:
|
||||
@@ -74,22 +72,22 @@ test: $(GOTEST)
|
||||
$(GOTEST) -covermode count -coverprofile .cover.out -v ./...
|
||||
$(GO) tool cover -func=.cover.out
|
||||
|
||||
test.sam: $(GOTEST)
|
||||
$(GOTEST) -covermode count -coverprofile .cover.out -v ./sam/repository/... ./sam/service/...
|
||||
test.messaging: $(GOTEST)
|
||||
$(GOTEST) -covermode count -coverprofile .cover.out -v ./messaging/repository/... ./messaging/service/...
|
||||
$(GO) tool cover -func=.cover.out | grep --color "^\|[^0-9]0.0%"
|
||||
|
||||
test.sam.db: $(GOTEST)
|
||||
$(GOTEST) -covermode count -coverprofile .cover.out -v ./sam/db/...
|
||||
test.messaging.db: $(GOTEST)
|
||||
$(GOTEST) -covermode count -coverprofile .cover.out -v ./messaging/db/...
|
||||
$(GO) tool cover -func=.cover.out | grep --color "^\|[^0-9]0.0%"
|
||||
|
||||
test.pubsub: $(GOTEST)
|
||||
$(GOTEST) -run PubSubMemory -covermode count -coverprofile .cover.out -v ./sam/repository/pubsub*.go ./sam/repository/flags*.go ./sam/repository/error*.go
|
||||
perl -pi -e 's/command-line-arguments/.\/sam\/repository/g' .cover.out
|
||||
$(GOTEST) -run PubSubMemory -covermode count -coverprofile .cover.out -v ./messaging/repository/pubsub*.go ./messaging/repository/flags*.go ./messaging/repository/error*.go
|
||||
perl -pi -e 's/command-line-arguments/.\/messaging\/repository/g' .cover.out
|
||||
$(GO) tool cover -func=.cover.out | grep --color "^\|[^0-9]0.0%"
|
||||
|
||||
test.events: $(GOTEST)
|
||||
$(GOTEST) -run Events -covermode count -coverprofile .cover.out -v ./sam/repository/events*.go ./sam/repository/flags*.go ./sam/repository/error*.go
|
||||
perl -pi -e 's/command-line-arguments/.\/sam\/repository/g' .cover.out
|
||||
$(GOTEST) -run Events -covermode count -coverprofile .cover.out -v ./messaging/repository/events*.go ./messaging/repository/flags*.go ./messaging/repository/error*.go
|
||||
perl -pi -e 's/command-line-arguments/.\/messaging\/repository/g' .cover.out
|
||||
$(GO) tool cover -func=.cover.out | grep --color "^\|[^0-9]0.0%"
|
||||
|
||||
test.crm: $(GOTEST)
|
||||
@@ -149,9 +147,9 @@ mocks: $(GOMOCK)
|
||||
# See https://github.com/golang/mock for details
|
||||
$(MOCKGEN) -package service -source crm/service/notification.go -destination crm/service/notification_mock_test.go
|
||||
|
||||
$(MOCKGEN) -package service -source sam/service/attachment.go -destination sam/service/attachment_mock_test.go
|
||||
$(MOCKGEN) -package service -source sam/service/channel.go -destination sam/service/channel_mock_test.go
|
||||
$(MOCKGEN) -package service -source sam/service/message.go -destination sam/service/message_mock_test.go
|
||||
$(MOCKGEN) -package service -source messaging/service/attachment.go -destination messaging/service/attachment_mock_test.go
|
||||
$(MOCKGEN) -package service -source messaging/service/channel.go -destination messaging/service/channel_mock_test.go
|
||||
$(MOCKGEN) -package service -source messaging/service/message.go -destination messaging/service/message_mock_test.go
|
||||
$(MOCKGEN) -package service -source system/service/organisation.go -destination system/service/organisation_mock_test.go
|
||||
$(MOCKGEN) -package service -source system/service/team.go -destination system/service/team_mock_test.go
|
||||
$(MOCKGEN) -package service -source system/service/user.go -destination system/service/user_mock_test.go
|
||||
@@ -172,12 +170,6 @@ $(GOTEST):
|
||||
$(REALIZE):
|
||||
$(GOGET) github.com/tockins/realize
|
||||
|
||||
$(SPEC):
|
||||
$(GOGET) github.com/titpetric/spec/cmd/spec
|
||||
|
||||
$(PROTOC):
|
||||
$(GOGET) github.com/golang/protobuf/protoc-gen-go
|
||||
|
||||
$(GOCRITIC):
|
||||
$(GOGET) github.com/go-critic/go-critic/...
|
||||
|
||||
@@ -189,6 +181,6 @@ $(MOCKGEN):
|
||||
$(GOGET) github.com/golang/mock/mockgen
|
||||
|
||||
clean:
|
||||
rm -f $(SPEC) $(PROTOC) $(REALIZE) $(GOCRITIC) $(GOTEST)
|
||||
rm -f $(REALIZE) $(GOCRITIC) $(GOTEST)
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
{
|
||||
"title": "Pages",
|
||||
"description": "CRM module pages",
|
||||
"package": "crm",
|
||||
"entrypoint": "page",
|
||||
"path": "/page",
|
||||
"authentication": [],
|
||||
@@ -198,7 +197,6 @@
|
||||
{
|
||||
"title": "Modules",
|
||||
"description": "CRM module definitions",
|
||||
"package": "crm",
|
||||
"entrypoint": "module",
|
||||
"path": "/module",
|
||||
"authentication": [],
|
||||
@@ -609,7 +607,6 @@
|
||||
{
|
||||
"title": "Triggers",
|
||||
"description": "CRM Triggers",
|
||||
"package": "crm",
|
||||
"entrypoint": "trigger",
|
||||
"path": "/trigger",
|
||||
"authentication": [],
|
||||
@@ -755,7 +752,6 @@
|
||||
{
|
||||
"title": "Notifications",
|
||||
"description": "CRM Notifications",
|
||||
"package": "crm",
|
||||
"entrypoint": "notification",
|
||||
"path": "/notification",
|
||||
"authentication": [],
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"Title": "Charts",
|
||||
"Package": "",
|
||||
"Interface": "Chart",
|
||||
"Struct": [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"Title": "Modules",
|
||||
"Description": "CRM module definitions",
|
||||
"Package": "crm",
|
||||
"Interface": "Module",
|
||||
"Struct": [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"Title": "Notifications",
|
||||
"Description": "CRM Notifications",
|
||||
"Package": "crm",
|
||||
"Interface": "Notification",
|
||||
"Struct": [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"Title": "Pages",
|
||||
"Description": "CRM module pages",
|
||||
"Package": "crm",
|
||||
"Interface": "Page",
|
||||
"Struct": [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"Title": "Triggers",
|
||||
"Description": "CRM Triggers",
|
||||
"Package": "crm",
|
||||
"Interface": "Trigger",
|
||||
"Struct": null,
|
||||
"Parameters": null,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
{
|
||||
"title": "Channels",
|
||||
"description": "A channel is a representation of a sequence of messages. It has meta data like channel subject. Channels may be public, private or group.",
|
||||
"package": "sam",
|
||||
"entrypoint": "channel",
|
||||
"path": "/channels",
|
||||
"authentication": [
|
||||
@@ -300,7 +299,6 @@
|
||||
},
|
||||
{
|
||||
"title": "Messages",
|
||||
"package": "sam",
|
||||
"path": "/channels/{channelID}/messages",
|
||||
"parameters": {
|
||||
"path": [
|
||||
@@ -566,7 +564,6 @@
|
||||
},
|
||||
{
|
||||
"title": "Attachments",
|
||||
"package": "sam",
|
||||
"path": "/attachment/{attachmentID}",
|
||||
"parameters": {
|
||||
"path": [
|
||||
@@ -685,7 +682,6 @@
|
||||
},
|
||||
{
|
||||
"title": "Permissions",
|
||||
"package": "sam",
|
||||
"parameters": {},
|
||||
"entrypoint": "permissions",
|
||||
"authentication": [
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"Title": "Attachments",
|
||||
"Package": "sam",
|
||||
"Interface": "Attachment",
|
||||
"Struct": null,
|
||||
"Parameters": {
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"Title": "Channels",
|
||||
"Description": "A channel is a representation of a sequence of messages. It has meta data like channel subject. Channels may be public, private or group.",
|
||||
"Package": "sam",
|
||||
"Interface": "Channel",
|
||||
"Struct": null,
|
||||
"Parameters": null,
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"Title": "Messages",
|
||||
"Package": "sam",
|
||||
"Interface": "Message",
|
||||
"Struct": null,
|
||||
"Parameters": {
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"Title": "Permissions",
|
||||
"Package": "sam",
|
||||
"Interface": "Permissions",
|
||||
"Struct": [
|
||||
{
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"Title": "Search entry point",
|
||||
"Package": "",
|
||||
"Interface": "Search",
|
||||
"Struct": null,
|
||||
"Parameters": {
|
||||
@@ -1,7 +1,6 @@
|
||||
[
|
||||
{
|
||||
"title": "Authentication",
|
||||
"package": "auth",
|
||||
"path": "/auth",
|
||||
"entrypoint": "auth",
|
||||
"authentication": [],
|
||||
@@ -47,7 +46,6 @@
|
||||
{
|
||||
"title": "Organisations",
|
||||
"description": "Organisations represent a top-level grouping entity. There may be many organisations defined in a single deployment.",
|
||||
"package": "sam",
|
||||
"path": "/organisations",
|
||||
"entrypoint": "organisation",
|
||||
"authentication": [
|
||||
@@ -164,7 +162,6 @@
|
||||
{
|
||||
"title": "Teams",
|
||||
"description": "An organisation may have many teams. Teams may have many channels available. Access to channels may be shared between teams.",
|
||||
"package": "sam",
|
||||
"path": "/teams",
|
||||
"entrypoint": "team",
|
||||
"authentication": [
|
||||
@@ -388,7 +385,6 @@
|
||||
},
|
||||
{
|
||||
"title": "Users",
|
||||
"package": "sam",
|
||||
"path": "/users",
|
||||
"entrypoint": "user",
|
||||
"authentication": [
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"Title": "Authentication",
|
||||
"Package": "auth",
|
||||
"Interface": "Auth",
|
||||
"Struct": null,
|
||||
"Parameters": null,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"Title": "Organisations",
|
||||
"Description": "Organisations represent a top-level grouping entity. There may be many organisations defined in a single deployment.",
|
||||
"Package": "sam",
|
||||
"Interface": "Organisation",
|
||||
"Struct": null,
|
||||
"Parameters": null,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"Title": "Teams",
|
||||
"Description": "An organisation may have many teams. Teams may have many channels available. Access to channels may be shared between teams.",
|
||||
"Package": "sam",
|
||||
"Interface": "Team",
|
||||
"Struct": null,
|
||||
"Parameters": null,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"Title": "Users",
|
||||
"Package": "sam",
|
||||
"Interface": "User",
|
||||
"Struct": [
|
||||
{
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
protoc --go_out=plugins=grpc:. -I. sam/chat/*.proto
|
||||
+15
-5
@@ -5,23 +5,33 @@ import (
|
||||
"os"
|
||||
|
||||
service "github.com/crusttech/crust/crm"
|
||||
"github.com/crusttech/crust/internal/mail"
|
||||
|
||||
"github.com/crusttech/crust/internal/auth"
|
||||
"github.com/crusttech/crust/internal/rbac"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flags("crm", service.Flags, auth.Flags, rbac.Flags, mail.Flags)
|
||||
flags("crm", service.Flags, auth.Flags, rbac.Flags)
|
||||
|
||||
// log to stdout not stderr
|
||||
log.SetOutput(os.Stdout)
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
|
||||
if err := service.Init(); err != nil {
|
||||
log.Fatalf("Error initializing crm: %+v", err)
|
||||
log.Fatalf("Error initializing: %+v", err)
|
||||
}
|
||||
if err := service.Start(); err != nil {
|
||||
log.Fatalf("Error starting/running crm: %+v", err)
|
||||
|
||||
var command string
|
||||
if len(os.Args) > 1 {
|
||||
command = os.Args[1]
|
||||
}
|
||||
|
||||
switch command {
|
||||
case "help":
|
||||
case "merge-users":
|
||||
default:
|
||||
if err := service.Start(); err != nil {
|
||||
log.Fatalf("Error starting/running: %+v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-4
@@ -4,7 +4,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
service "github.com/crusttech/crust/sam"
|
||||
service "github.com/crusttech/crust/messaging"
|
||||
|
||||
"github.com/crusttech/crust/internal/auth"
|
||||
"github.com/crusttech/crust/internal/rbac"
|
||||
@@ -18,9 +18,20 @@ func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
|
||||
if err := service.Init(); err != nil {
|
||||
log.Fatalf("Error initializing sam: %+v", err)
|
||||
log.Fatalf("Error initializing: %+v", err)
|
||||
}
|
||||
if err := service.Start(); err != nil {
|
||||
log.Fatalf("Error starting/running sam: %+v", err)
|
||||
|
||||
var command string
|
||||
if len(os.Args) > 1 {
|
||||
command = os.Args[1]
|
||||
}
|
||||
|
||||
switch command {
|
||||
case "help":
|
||||
case "merge-users":
|
||||
default:
|
||||
if err := service.Start(); err != nil {
|
||||
log.Fatalf("Error starting/running: %+v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,5 +44,6 @@ func cliRouter(commands ...string) {
|
||||
switch commands[0] {
|
||||
case "users":
|
||||
cliExecUsers(commands[1:]...)
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
crmRepository "github.com/crusttech/crust/crm/repository"
|
||||
"github.com/crusttech/crust/internal/payload"
|
||||
messagingRepository "github.com/crusttech/crust/sam/repository"
|
||||
messagingRepository "github.com/crusttech/crust/messaging/repository"
|
||||
"github.com/crusttech/crust/system/service"
|
||||
"github.com/crusttech/crust/system/types"
|
||||
)
|
||||
|
||||
+3
-4
@@ -4,7 +4,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/crusttech/crust/system"
|
||||
service "github.com/crusttech/crust/system"
|
||||
|
||||
"github.com/crusttech/crust/internal/auth"
|
||||
"github.com/crusttech/crust/internal/rbac"
|
||||
@@ -18,7 +18,7 @@ func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
|
||||
if err := service.Init(); err != nil {
|
||||
log.Fatalf("Error initializing system: %+v", err)
|
||||
log.Fatalf("Error initializing: %+v", err)
|
||||
}
|
||||
|
||||
var command string
|
||||
@@ -31,8 +31,7 @@ func main() {
|
||||
case "merge-users":
|
||||
default:
|
||||
if err := service.Start(); err != nil {
|
||||
log.Fatalf("Error starting/running system: %+v", err)
|
||||
log.Fatalf("Error starting/running: %+v", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+34
-26
@@ -22,9 +22,9 @@ function permissions {
|
||||
CGO_ENABLED=0 go build -o ./build/gen-permissions codegen/v2/permissions.go
|
||||
fi
|
||||
|
||||
./build/gen-permissions -package types -function "func (c *Organisation) Permissions() []rules.OperationGroup" -input sam/types/permissions/1-organisation.json -output sam/types/organisation.perms.gen.go
|
||||
./build/gen-permissions -package types -function "func (c *Team) Permissions() []rules.OperationGroup" -input sam/types/permissions/2-team.json -output sam/types/team.perms.gen.go
|
||||
./build/gen-permissions -package types -function "func (c *Channel) Permissions() []rules.OperationGroup" -input sam/types/permissions/3-channel.json -output sam/types/channel.perms.gen.go
|
||||
./build/gen-permissions -package types -function "func (c *Organisation) Permissions() []rules.OperationGroup" -input messaging/types/permissions/1-organisation.json -output messaging/types/organisation.perms.gen.go
|
||||
./build/gen-permissions -package types -function "func (c *Team) Permissions() []rules.OperationGroup" -input messaging/types/permissions/2-team.json -output messaging/types/team.perms.gen.go
|
||||
./build/gen-permissions -package types -function "func (c *Channel) Permissions() []rules.OperationGroup" -input messaging/types/permissions/3-channel.json -output messaging/types/channel.perms.gen.go
|
||||
|
||||
green "OK"
|
||||
}
|
||||
@@ -42,14 +42,14 @@ function types {
|
||||
./build/gen-type-set --with-primary-key=false --types ModuleField,RecordValue \
|
||||
--output crm/types/type.other.gen.go
|
||||
|
||||
./build/gen-type-set --types MessageAttachment --output sam/types/attachment.gen.go
|
||||
./build/gen-type-set --with-resources=true --types Channel --resource-type "types.Resource" --imports "github.com/crusttech/crust/system/types" --output sam/types/channel.gen.go
|
||||
./build/gen-type-set --with-primary-key=false --types ChannelMember --output sam/types/channel_member.gen.go
|
||||
./build/gen-type-set --with-primary-key=false --types Command,CommandParam --output sam/types/command.gen.go
|
||||
./build/gen-type-set --types Mention --output sam/types/mention.gen.go
|
||||
./build/gen-type-set --types MessageFlag --output sam/types/message_flag.gen.go
|
||||
./build/gen-type-set --types Message --output sam/types/message.gen.go
|
||||
./build/gen-type-set --with-primary-key=false --types Unread --output sam/types/unread.gen.go
|
||||
./build/gen-type-set --types MessageAttachment --output messaging/types/attachment.gen.go
|
||||
./build/gen-type-set --with-resources=true --types Channel --resource-type "types.Resource" --imports "github.com/crusttech/crust/system/types" --output messaging/types/channel.gen.go
|
||||
./build/gen-type-set --with-primary-key=false --types ChannelMember --output messaging/types/channel_member.gen.go
|
||||
./build/gen-type-set --with-primary-key=false --types Command,CommandParam --output messaging/types/command.gen.go
|
||||
./build/gen-type-set --types Mention --output messaging/types/mention.gen.go
|
||||
./build/gen-type-set --types MessageFlag --output messaging/types/message_flag.gen.go
|
||||
./build/gen-type-set --types Message --output messaging/types/message.gen.go
|
||||
./build/gen-type-set --with-primary-key=false --types Unread --output messaging/types/unread.gen.go
|
||||
|
||||
./build/gen-type-set --types User --output system/types/user.gen.go
|
||||
./build/gen-type-set --with-resources=true --resource-type "Resource" --types Team --output system/types/team.gen.go
|
||||
@@ -88,21 +88,29 @@ function files {
|
||||
|
||||
files
|
||||
|
||||
_PWD=$PWD
|
||||
SPECS=$(find $PWD -name 'spec.json' | xargs -n1 dirname)
|
||||
for SPEC in $SPECS; do
|
||||
yellow "> spec $SPEC"
|
||||
cd $SPEC && rm -rf spec && /usr/bin/env spec && cd $_PWD
|
||||
green "OK"
|
||||
done
|
||||
|
||||
for SPEC in $SPECS; do
|
||||
SRC=$(basename $SPEC)
|
||||
if [ -d "codegen/$SRC" ]; then
|
||||
yellow "> README $SRC"
|
||||
codegen/codegen.php $SRC
|
||||
green "OK"
|
||||
function specs {
|
||||
yellow "> specs"
|
||||
if [ ! -f "build/gen-spec" ]; then
|
||||
CGO_ENABLED=0 go build -o ./build/gen-spec codegen/v2/spec.go
|
||||
fi
|
||||
done
|
||||
_PWD=$PWD
|
||||
SPECS=$(find $PWD -name 'spec.json' | xargs -n1 dirname)
|
||||
for SPEC in $SPECS; do
|
||||
yellow "> spec $SPEC"
|
||||
cd $SPEC && rm -rf spec && ../../build/gen-spec && cd $_PWD
|
||||
green "OK"
|
||||
done
|
||||
|
||||
for SPEC in $SPECS; do
|
||||
SRC=$(basename $SPEC)
|
||||
if [ -d "codegen/$SRC" ]; then
|
||||
yellow "> README $SRC"
|
||||
codegen/codegen.php $SRC
|
||||
green "OK"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
specs
|
||||
|
||||
gofmt
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL^E_NOTICE);
|
||||
|
||||
include("docs/vendor/autoload.php");
|
||||
|
||||
function capitalize($name) {
|
||||
$names = explode("/", $name);
|
||||
return implode("", array_map("ucfirst", $names));
|
||||
}
|
||||
|
||||
function array_change_key_case_recursive($arr) {
|
||||
return array_map(function ($item) {
|
||||
if (is_array($item)) {
|
||||
$item = array_change_key_case_recursive($item);
|
||||
}
|
||||
return $item;
|
||||
}, array_change_key_case($arr));
|
||||
}
|
||||
|
||||
$tpl = new Monotek\MiniTPL\Template;
|
||||
$tpl->set_paths(array(__DIR__ . "/"));
|
||||
$tpl->set_compile_location("/tmp", true);
|
||||
$tpl->add_default("newline", "\n");
|
||||
|
||||
$api_files = glob("docs/src/spec/*.json");
|
||||
$apis = array_map(function($filename) {
|
||||
return array_change_key_case_recursive(json_decode(file_get_contents($filename), true));
|
||||
}, $api_files);
|
||||
|
||||
usort($apis, function($a, $b) {
|
||||
return strcmp($a['interface'], $b['interface']);
|
||||
});
|
||||
|
||||
foreach (array("structs", "handlers", "interfaces", "request", "") as $type) {
|
||||
foreach ($apis as $api) {
|
||||
if (is_array($api['struct'])) {
|
||||
$name = ucfirst($api['interface']);
|
||||
$filename = str_replace("..", ".", strtolower($name) . "." . $type . ".go");
|
||||
|
||||
$tpl->load("http_$type.tpl");
|
||||
$tpl->assign("parsers", array(
|
||||
"uint64" => "parseUInt64",
|
||||
"bool" => "parseBool",
|
||||
));
|
||||
$tpl->assign("package", $api['package']);
|
||||
$tpl->assign("name", $name);
|
||||
$tpl->assign("self", strtolower(substr($name, 0, 1)));
|
||||
$tpl->assign("api", $api);
|
||||
$tpl->assign("structs", $api['struct']);
|
||||
$imports = array();
|
||||
foreach ($api['struct'] as $struct) {
|
||||
if (isset($struct['imports']))
|
||||
foreach ($struct['imports'] as $import) {
|
||||
$imports[] = $import;
|
||||
}
|
||||
}
|
||||
$tpl->assign("imports", $imports);
|
||||
$tpl->assign("calls", $api['apis']);
|
||||
$contents = str_replace("\n\n}", "\n}", $tpl->get());
|
||||
|
||||
$save = true;
|
||||
if ($type === "" && file_exists($filename)) {
|
||||
$save = false;
|
||||
}
|
||||
if ($save) {
|
||||
file_put_contents($filename, $contents);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array("routes") as $type) {
|
||||
$name = ucfirst($api['interface']);
|
||||
$filename = str_replace("..", ".", $type . ".go");
|
||||
|
||||
$tpl->load("http_$type.tpl");
|
||||
$tpl->assign("package", reset($apis)['package']);
|
||||
$tpl->assign("apis", $apis);
|
||||
$contents = $tpl->get();
|
||||
|
||||
file_put_contents($filename, $contents);
|
||||
}
|
||||
|
||||
// camel case to snake case
|
||||
function decamel($input) {
|
||||
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
|
||||
$ret = $matches[0];
|
||||
foreach ($ret as &$match) {
|
||||
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
|
||||
}
|
||||
return implode('_', $ret);
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
type SpecFile []*SpecEntry
|
||||
|
||||
type SpecEntry struct {
|
||||
Title string
|
||||
Description string
|
||||
Protocol string
|
||||
Authentication []string
|
||||
Entrypoint string
|
||||
Path string
|
||||
Struct interface{}
|
||||
Parameters map[string]interface{}
|
||||
APIs []*SpecAPI
|
||||
}
|
||||
|
||||
func (s *SpecEntry) toOutFile() OutFile {
|
||||
file := OutFile{
|
||||
APIs: []*OutFileAPI{},
|
||||
}
|
||||
s.applyToOutFile(&file)
|
||||
return file
|
||||
}
|
||||
|
||||
func (s *SpecEntry) applyToOutFile(o *OutFile) {
|
||||
// reset title/interface/path to spec data
|
||||
o.Title = s.Title
|
||||
o.Description = s.Description
|
||||
o.Parameters = s.Parameters
|
||||
o.Interface = strings.ToUpper(s.Entrypoint[0:1]) + s.Entrypoint[1:]
|
||||
o.Path = s.Path
|
||||
if o.Path == "" {
|
||||
o.Path = "/" + s.Entrypoint
|
||||
}
|
||||
o.Struct = s.Struct
|
||||
o.Protocol = s.Protocol
|
||||
o.Authentication = s.Authentication
|
||||
|
||||
namedAPIs := o.NamedAPIs()
|
||||
|
||||
for _, val := range s.APIs {
|
||||
path := val.Path
|
||||
if path == "" {
|
||||
path = "/" + val.Name
|
||||
}
|
||||
// add new API calls
|
||||
call, ok := namedAPIs[val.Name]
|
||||
if !ok {
|
||||
o.APIs = append(o.APIs, &OutFileAPI{
|
||||
Name: val.Name,
|
||||
Method: val.Method,
|
||||
Title: val.Title,
|
||||
Path: path,
|
||||
Parameters: val.Parameters,
|
||||
})
|
||||
} else {
|
||||
// update title/method/path of existing APIs
|
||||
call.Name = val.Name
|
||||
call.Title = val.Title
|
||||
call.Method = val.Method
|
||||
call.Path = path
|
||||
if val.Parameters != nil {
|
||||
call.Parameters = val.Parameters
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type SpecAPI struct {
|
||||
Name string
|
||||
Method string
|
||||
Title string
|
||||
Path string
|
||||
Parameters map[string]interface{}
|
||||
}
|
||||
|
||||
type OutFile struct {
|
||||
Title string
|
||||
Description string `json:",omitempty"`
|
||||
Interface string
|
||||
Struct interface{}
|
||||
Parameters map[string]interface{}
|
||||
Protocol string
|
||||
Authentication []string
|
||||
Path string
|
||||
APIs []*OutFileAPI
|
||||
}
|
||||
|
||||
func (o *OutFile) NamedAPIs() map[string]*OutFileAPI {
|
||||
apis := map[string]*OutFileAPI{}
|
||||
for _, api := range o.APIs {
|
||||
apis[api.Name] = api
|
||||
}
|
||||
return apis
|
||||
}
|
||||
|
||||
type OutFileAPI struct {
|
||||
Name string
|
||||
Method string
|
||||
Title string
|
||||
Description string `json:",omitempty"`
|
||||
Path string
|
||||
Parameters map[string]interface{}
|
||||
}
|
||||
|
||||
func main() {
|
||||
debug := false
|
||||
|
||||
raw, err := ioutil.ReadFile("./spec.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var spec SpecFile
|
||||
json.Unmarshal(raw, &spec)
|
||||
|
||||
os.Mkdir("./spec", 0755)
|
||||
for _, val := range spec {
|
||||
filename := val.Entrypoint + ".json"
|
||||
var file OutFile
|
||||
contents, err := ioutil.ReadFile("./" + filename)
|
||||
if err != nil {
|
||||
file = val.toOutFile()
|
||||
} else {
|
||||
err = json.Unmarshal(contents, &file)
|
||||
if err != nil {
|
||||
log.Fatal("Error parsing ", filename, ": ", err)
|
||||
}
|
||||
val.applyToOutFile(&file)
|
||||
}
|
||||
raw, _ := json.MarshalIndent(file, "", " ")
|
||||
ioutil.WriteFile("./spec/"+filename, raw, 0644)
|
||||
fmt.Println(filename)
|
||||
}
|
||||
|
||||
if debug {
|
||||
spew.Dump(spec)
|
||||
}
|
||||
}
|
||||
+12
-6
@@ -3,15 +3,17 @@ package service
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/crusttech/crust/crm/repository"
|
||||
"github.com/crusttech/crust/internal/config"
|
||||
)
|
||||
|
||||
type (
|
||||
appFlags struct {
|
||||
smtp *config.SMTP
|
||||
http *config.HTTP
|
||||
monitor *config.Monitor
|
||||
db *config.Database
|
||||
smtp *config.SMTP
|
||||
http *config.HTTP
|
||||
monitor *config.Monitor
|
||||
db *config.Database
|
||||
repository *repository.Flags
|
||||
}
|
||||
)
|
||||
|
||||
@@ -19,7 +21,7 @@ var flags *appFlags
|
||||
|
||||
func (c *appFlags) Validate() error {
|
||||
if c == nil {
|
||||
return errors.New("CRM flags are not initialized, need to call Flags()")
|
||||
return errors.New("Flags are not initialized, need to call Flags()")
|
||||
}
|
||||
if err := c.http.Validate(); err != nil {
|
||||
return err
|
||||
@@ -33,6 +35,9 @@ func (c *appFlags) Validate() error {
|
||||
if err := c.db.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.repository.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -41,7 +46,7 @@ func Flags(prefix ...string) {
|
||||
return
|
||||
}
|
||||
if len(prefix) == 0 {
|
||||
panic("crm.Flags() needs prefix on first call")
|
||||
panic("Flags() needs prefix on first call")
|
||||
}
|
||||
|
||||
flags = &appFlags{
|
||||
@@ -49,5 +54,6 @@ func Flags(prefix ...string) {
|
||||
new(config.HTTP).Init(prefix...),
|
||||
new(config.Monitor).Init(prefix...),
|
||||
new(config.Database).Init(prefix...),
|
||||
new(repository.Flags).Init(prefix...),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
_ "github.com/crusttech/crust/internal/config"
|
||||
)
|
||||
|
||||
type (
|
||||
Flags struct {
|
||||
// No config yet
|
||||
}
|
||||
)
|
||||
|
||||
var flags *Flags
|
||||
|
||||
func (f *Flags) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *Flags) Init(prefix ...string) *Flags {
|
||||
if flags != nil {
|
||||
return flags
|
||||
}
|
||||
flags = &Flags{}
|
||||
return flags
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func (r *module) With(ctx context.Context, db *factory.DB) ModuleRepository {
|
||||
}
|
||||
}
|
||||
|
||||
// @todo: update to accepted DeletedAt column semantics from SAM
|
||||
// @todo: update to accepted DeletedAt column semantics from Messaging
|
||||
|
||||
func (r *module) FindByID(id uint64) (mod *types.Module, err error) {
|
||||
mod = &types.Module{}
|
||||
|
||||
@@ -72,7 +72,7 @@ func (r *record) With(ctx context.Context, db *factory.DB) RecordRepository {
|
||||
}
|
||||
}
|
||||
|
||||
// @todo: update to accepted DeletedAt column semantics from SAM
|
||||
// @todo: update to accepted DeletedAt column semantics from Messaging
|
||||
|
||||
func (r *record) FindByID(id uint64) (*types.Record, error) {
|
||||
mod := &types.Record{}
|
||||
|
||||
@@ -159,6 +159,7 @@ func (b recordReportBuilder) Cast(row sqlx.ColScanner) map[string]interface{} {
|
||||
switch cv := v.(type) {
|
||||
case []uint8:
|
||||
out[k] = string(cv)
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestMain(m *testing.M) {
|
||||
// @todo this is a very optimistic initialization, make it more robust
|
||||
godotenv.Load("../../.env")
|
||||
|
||||
prefix := "sam"
|
||||
prefix := "crm"
|
||||
dsn := ""
|
||||
|
||||
p := func(s string) string {
|
||||
|
||||
@@ -114,26 +114,26 @@ func (svc *record) Find(moduleID uint64, filter, sort string, page, perPage int)
|
||||
|
||||
}
|
||||
|
||||
func (svc *record) Create(new *types.Record) (record *types.Record, err error) {
|
||||
func (svc *record) Create(in *types.Record) (record *types.Record, err error) {
|
||||
var module *types.Module
|
||||
|
||||
err = svc.db.Transaction(func() (err error) {
|
||||
if module, err = svc.moduleRepo.FindByID(new.ModuleID); err != nil {
|
||||
if module, err = svc.moduleRepo.FindByID(in.ModuleID); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = svc.sanitizeValues(module, new.Values); err != nil {
|
||||
if err = svc.sanitizeValues(module, in.Values); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
new.OwnedBy = auth.GetIdentityFromContext(svc.ctx).Identity()
|
||||
new.CreatedBy = new.OwnedBy
|
||||
new.CreatedAt = time.Now()
|
||||
if record, err = svc.repository.Create(new); err != nil {
|
||||
in.OwnedBy = auth.GetIdentityFromContext(svc.ctx).Identity()
|
||||
in.CreatedBy = in.OwnedBy
|
||||
in.CreatedAt = time.Now()
|
||||
if record, err = svc.repository.Create(in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = svc.repository.UpdateValues(record.ID, new.Values); err != nil {
|
||||
if err = svc.repository.UpdateValues(record.ID, in.Values); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
jwtVerifier (func(http.Handler) http.Handler)
|
||||
jwtAuthenticator (func(http.Handler) http.Handler)
|
||||
jwtVerifier func(http.Handler) http.Handler
|
||||
jwtAuthenticator func(http.Handler) http.Handler
|
||||
jwtEncoder auth.TokenEncoder
|
||||
)
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ func (*Social) Init(prefix ...string) *Social {
|
||||
}
|
||||
|
||||
social = new(Social)
|
||||
flag.BoolVar(&social.Enabled, "auth-social-enabled", true, "SocialAuth enabled")
|
||||
flag.BoolVar(&social.Enabled, "auth-social-enabled", false, "SocialAuth enabled")
|
||||
|
||||
b("Facebook", &social.FacebookKey, &social.FacebookSecret)
|
||||
b("GPlus", &social.GPlusKey, &social.GPlusSecret)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package mail
|
||||
|
||||
import (
|
||||
"github.com/crusttech/crust/internal/config"
|
||||
)
|
||||
|
||||
var flags *config.SMTP
|
||||
|
||||
func Flags(prefix ...string) {
|
||||
flags = new(config.SMTP).Init(prefix...)
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/crusttech/crust/internal/auth"
|
||||
"github.com/crusttech/crust/internal/payload/outgoing"
|
||||
samTypes "github.com/crusttech/crust/sam/types"
|
||||
messagingTypes "github.com/crusttech/crust/messaging/types"
|
||||
systemTypes "github.com/crusttech/crust/system/types"
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ const (
|
||||
attachmentPreviewURL = "/attachment/%d/preview.%s"
|
||||
)
|
||||
|
||||
func Message(ctx context.Context, msg *samTypes.Message) *outgoing.Message {
|
||||
func Message(ctx context.Context, msg *messagingTypes.Message) *outgoing.Message {
|
||||
var currentUserID = auth.GetIdentityFromContext(ctx).Identity()
|
||||
var canEdit = msg.Type.IsEditable() && msg.UserID == currentUserID
|
||||
var canReply = msg.Type.IsRepliable() && msg.ReplyTo == 0
|
||||
@@ -48,7 +48,7 @@ func Message(ctx context.Context, msg *samTypes.Message) *outgoing.Message {
|
||||
}
|
||||
}
|
||||
|
||||
func Messages(ctx context.Context, msg samTypes.MessageSet) *outgoing.MessageSet {
|
||||
func Messages(ctx context.Context, msg messagingTypes.MessageSet) *outgoing.MessageSet {
|
||||
msgs := make([]*outgoing.Message, len(msg))
|
||||
for k, m := range msg {
|
||||
msgs[k] = Message(ctx, m)
|
||||
@@ -57,7 +57,7 @@ func Messages(ctx context.Context, msg samTypes.MessageSet) *outgoing.MessageSet
|
||||
return &retval
|
||||
}
|
||||
|
||||
func messageReactionSumSet(flags samTypes.MessageFlagSet) outgoing.MessageReactionSumSet {
|
||||
func messageReactionSumSet(flags messagingTypes.MessageFlagSet) outgoing.MessageReactionSumSet {
|
||||
var (
|
||||
rr = make([]*outgoing.MessageReactionSum, 0)
|
||||
rIndex = map[string]int{}
|
||||
@@ -65,7 +65,7 @@ func messageReactionSumSet(flags samTypes.MessageFlagSet) outgoing.MessageReacti
|
||||
i int
|
||||
)
|
||||
|
||||
_ = flags.Walk(func(flag *samTypes.MessageFlag) error {
|
||||
_ = flags.Walk(func(flag *messagingTypes.MessageFlag) error {
|
||||
if flag.IsReaction() {
|
||||
r := &outgoing.MessageReactionSum{Reaction: flag.Flag, UserIDs: []string{}, Count: 0}
|
||||
|
||||
@@ -86,11 +86,11 @@ func messageReactionSumSet(flags samTypes.MessageFlagSet) outgoing.MessageReacti
|
||||
|
||||
// Converts slice of mentions into slice of strings containing all user IDs
|
||||
// These are IDs of users mentioned in the message
|
||||
func messageMentionSet(mm samTypes.MentionSet) outgoing.MessageMentionSet {
|
||||
func messageMentionSet(mm messagingTypes.MentionSet) outgoing.MessageMentionSet {
|
||||
return Uint64stoa(mm.UserIDs())
|
||||
}
|
||||
|
||||
func MessageReaction(f *samTypes.MessageFlag) *outgoing.MessageReaction {
|
||||
func MessageReaction(f *messagingTypes.MessageFlag) *outgoing.MessageReaction {
|
||||
return &outgoing.MessageReaction{
|
||||
UserID: f.UserID,
|
||||
MessageID: f.MessageID,
|
||||
@@ -98,7 +98,7 @@ func MessageReaction(f *samTypes.MessageFlag) *outgoing.MessageReaction {
|
||||
}
|
||||
}
|
||||
|
||||
func MessageReactionRemoved(f *samTypes.MessageFlag) *outgoing.MessageReactionRemoved {
|
||||
func MessageReactionRemoved(f *messagingTypes.MessageFlag) *outgoing.MessageReactionRemoved {
|
||||
return &outgoing.MessageReactionRemoved{
|
||||
UserID: f.UserID,
|
||||
MessageID: f.MessageID,
|
||||
@@ -106,22 +106,22 @@ func MessageReactionRemoved(f *samTypes.MessageFlag) *outgoing.MessageReactionRe
|
||||
}
|
||||
}
|
||||
|
||||
func MessagePin(f *samTypes.MessageFlag) *outgoing.MessagePin {
|
||||
func MessagePin(f *messagingTypes.MessageFlag) *outgoing.MessagePin {
|
||||
return &outgoing.MessagePin{
|
||||
UserID: f.UserID,
|
||||
MessageID: f.MessageID,
|
||||
}
|
||||
}
|
||||
|
||||
func MessagePinRemoved(f *samTypes.MessageFlag) *outgoing.MessagePinRemoved {
|
||||
func MessagePinRemoved(f *messagingTypes.MessageFlag) *outgoing.MessagePinRemoved {
|
||||
return &outgoing.MessagePinRemoved{
|
||||
UserID: f.UserID,
|
||||
MessageID: f.MessageID,
|
||||
}
|
||||
}
|
||||
|
||||
func Channel(ch *samTypes.Channel) *outgoing.Channel {
|
||||
var flag = samTypes.ChannelMembershipFlagNone
|
||||
func Channel(ch *messagingTypes.Channel) *outgoing.Channel {
|
||||
var flag = messagingTypes.ChannelMembershipFlagNone
|
||||
|
||||
if ch.Member != nil {
|
||||
flag = ch.Member.Flag
|
||||
@@ -154,7 +154,7 @@ func Channel(ch *samTypes.Channel) *outgoing.Channel {
|
||||
}
|
||||
}
|
||||
|
||||
func Channels(channels samTypes.ChannelSet) *outgoing.ChannelSet {
|
||||
func Channels(channels messagingTypes.ChannelSet) *outgoing.ChannelSet {
|
||||
cc := make([]*outgoing.Channel, len(channels))
|
||||
for k, c := range channels {
|
||||
cc[k] = Channel(c)
|
||||
@@ -163,7 +163,7 @@ func Channels(channels samTypes.ChannelSet) *outgoing.ChannelSet {
|
||||
return &retval
|
||||
}
|
||||
|
||||
func ChannelMember(m *samTypes.ChannelMember) *outgoing.ChannelMember {
|
||||
func ChannelMember(m *messagingTypes.ChannelMember) *outgoing.ChannelMember {
|
||||
return &outgoing.ChannelMember{
|
||||
User: User(m.User),
|
||||
Type: string(m.Type),
|
||||
@@ -172,7 +172,7 @@ func ChannelMember(m *samTypes.ChannelMember) *outgoing.ChannelMember {
|
||||
}
|
||||
}
|
||||
|
||||
func ChannelMembers(members samTypes.ChannelMemberSet) *outgoing.ChannelMemberSet {
|
||||
func ChannelMembers(members messagingTypes.ChannelMemberSet) *outgoing.ChannelMemberSet {
|
||||
mm := make([]*outgoing.ChannelMember, len(members))
|
||||
for k, c := range members {
|
||||
mm[k] = ChannelMember(c)
|
||||
@@ -181,7 +181,7 @@ func ChannelMembers(members samTypes.ChannelMemberSet) *outgoing.ChannelMemberSe
|
||||
return &retval
|
||||
}
|
||||
|
||||
func Unread(v *samTypes.Unread) *outgoing.Unread {
|
||||
func Unread(v *messagingTypes.Unread) *outgoing.Unread {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -231,7 +231,7 @@ func Users(users []*systemTypes.User) *outgoing.UserSet {
|
||||
return &retval
|
||||
}
|
||||
|
||||
func Attachment(in *samTypes.Attachment) *outgoing.Attachment {
|
||||
func Attachment(in *messagingTypes.Attachment) *outgoing.Attachment {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -259,7 +259,7 @@ func Attachment(in *samTypes.Attachment) *outgoing.Attachment {
|
||||
}
|
||||
}
|
||||
|
||||
func Command(cmd *samTypes.Command) *outgoing.Command {
|
||||
func Command(cmd *messagingTypes.Command) *outgoing.Command {
|
||||
if cmd == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func Command(cmd *samTypes.Command) *outgoing.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func Commands(cc samTypes.CommandSet) *outgoing.CommandSet {
|
||||
func Commands(cc messagingTypes.CommandSet) *outgoing.CommandSet {
|
||||
out := make([]*outgoing.Command, len(cc))
|
||||
for k, m := range cc {
|
||||
out[k] = Command(m)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/titpetric/factory"
|
||||
"github.com/titpetric/statik/fs"
|
||||
|
||||
"github.com/crusttech/crust/sam/db/mysql"
|
||||
"github.com/crusttech/crust/messaging/db/mysql"
|
||||
)
|
||||
|
||||
func statements(contents []byte, err error) ([]string, error) {
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/crusttech/crust/internal/config"
|
||||
"github.com/crusttech/crust/sam/repository"
|
||||
"github.com/crusttech/crust/messaging/repository"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -21,7 +21,7 @@ var flags *appFlags
|
||||
|
||||
func (c *appFlags) Validate() error {
|
||||
if c == nil {
|
||||
return errors.New("SAM flags are not initialized, need to call Flags()")
|
||||
return errors.New("Flags are not initialized, need to call Flags()")
|
||||
}
|
||||
if err := c.http.Validate(); err != nil {
|
||||
return err
|
||||
@@ -46,7 +46,7 @@ func Flags(prefix ...string) {
|
||||
return
|
||||
}
|
||||
if len(prefix) == 0 {
|
||||
panic("sam.Flags() needs prefix on first call")
|
||||
panic("Flags() needs prefix on first call")
|
||||
}
|
||||
|
||||
flags = &appFlags{
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"testing"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
func TestAttachment(t *testing.T) {
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"testing"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
func TestChannel(t *testing.T) {
|
||||
@@ -20,7 +20,7 @@ func (e repositoryError) Error() string {
|
||||
}
|
||||
|
||||
func (e repositoryError) String() string {
|
||||
return "crust.sam.repository." + string(e)
|
||||
return "crust.messaging.repository." + string(e)
|
||||
}
|
||||
|
||||
func (e repositoryError) New() error {
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
func TestEvents(t *testing.T) {
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/namsral/flag"
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
samMigrate "github.com/crusttech/crust/sam/db"
|
||||
messagingMigrate "github.com/crusttech/crust/messaging/db"
|
||||
systemMigrate "github.com/crusttech/crust/system/db"
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestMain(m *testing.M) {
|
||||
// @todo this is a very optimistic initialization, make it more robust
|
||||
godotenv.Load("../../.env")
|
||||
|
||||
prefix := "sam"
|
||||
prefix := "messaging"
|
||||
dsn := ""
|
||||
|
||||
p := func(s string) string {
|
||||
@@ -43,7 +43,7 @@ func TestMain(m *testing.M) {
|
||||
log.Printf("Error running migrations: %+v\n", err)
|
||||
return
|
||||
}
|
||||
if err := samMigrate.Migrate(db); err != nil {
|
||||
if err := messagingMigrate.Migrate(db); err != nil {
|
||||
log.Printf("Error running migrations: %+v\n", err)
|
||||
return
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"testing"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
func TestReaction(t *testing.T) {
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"testing"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
func TestMessage(t *testing.T) {
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -2,10 +2,10 @@ package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/crusttech/crust/sam/rest/handlers"
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/sam/service"
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/rest/handlers"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
"github.com/crusttech/crust/messaging/service"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
"github.com/pkg/errors"
|
||||
"io"
|
||||
"time"
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/crusttech/crust/internal/payload"
|
||||
"github.com/crusttech/crust/internal/payload/outgoing"
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/sam/service"
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
"github.com/crusttech/crust/messaging/service"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/titpetric/factory/resputil"
|
||||
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
)
|
||||
|
||||
// Internal API interface
|
||||
+4
-3
@@ -6,7 +6,7 @@ import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
)
|
||||
|
||||
// HTTP API interface
|
||||
@@ -26,8 +26,9 @@ type Downloadable interface {
|
||||
func NewAttachmentDownloadable(ah AttachmentAPI) *Attachment {
|
||||
serve := func(f interface{}, err error, w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
switch true {
|
||||
case err.Error() == "crust.sam.repository.AttachmentNotFound":
|
||||
switch {
|
||||
// @todo: compare concrete exported error type? Go2 .As() like check?
|
||||
case err.Error() == "crust.messaging.repository.AttachmentNotFound":
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
default:
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/titpetric/factory/resputil"
|
||||
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
)
|
||||
|
||||
// Internal API interface
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/titpetric/factory/resputil"
|
||||
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
)
|
||||
|
||||
// Internal API interface
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/titpetric/factory/resputil"
|
||||
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
)
|
||||
|
||||
// Internal API interface
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/titpetric/factory/resputil"
|
||||
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
)
|
||||
|
||||
// Internal API interface
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
|
||||
"github.com/crusttech/crust/internal/payload"
|
||||
"github.com/crusttech/crust/internal/payload/outgoing"
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/sam/service"
|
||||
"github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
"github.com/crusttech/crust/messaging/service"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
var _ = errors.Wrap
|
||||
@@ -3,9 +3,9 @@ package rest
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/crusttech/crust/sam/rest/request"
|
||||
"github.com/crusttech/crust/sam/service"
|
||||
_ "github.com/crusttech/crust/sam/types"
|
||||
"github.com/crusttech/crust/messaging/rest/request"
|
||||
"github.com/crusttech/crust/messaging/service"
|
||||
_ "github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
type Permissions struct {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user