From 06f75376bcd82f73c57cf33da89983b004ef6c3b Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:09:52 +0100 Subject: [PATCH 01/15] upd(sam): rename to messaging --- api/{sam => messaging}/message/index.md | 0 api/{sam => messaging}/spec.json | 0 api/{sam => messaging}/spec/attachment.json | 0 api/{sam => messaging}/spec/channel.json | 0 api/{sam => messaging}/spec/message.json | 0 api/{sam => messaging}/spec/permissions.json | 0 api/{sam => messaging}/spec/search.json | 0 api/{sam => messaging}/websocket/websocket.md | 0 codegen/{sam => messaging}/docs/index.php | 0 codegen/{sam => messaging}/rest/handlers/index.php | 0 codegen/{sam => messaging}/rest/index.php | 0 codegen/{sam => messaging}/rest/request/index.php | 0 docs/{sam => messaging}/README.md | 0 {sam => messaging}/db/migrate.go | 0 {sam => messaging}/db/migrate_test.go | 0 {sam => messaging}/db/mysql/statik.go | 0 {sam => messaging}/db/schema/mysql/20180704080000.base.up.sql | 0 .../db/schema/mysql/20181009080000.altering_types.up.sql | 0 .../db/schema/mysql/20181013080000.channel_views.up.sql | 0 {sam => messaging}/db/schema/mysql/20181013080000.replies.up.sql | 0 .../db/schema/mysql/20181101080000.pins_and_reactions.up.sql | 0 {sam => messaging}/db/schema/mysql/20181107080000.mentions.up.sql | 0 {sam => messaging}/db/schema/mysql/20181115080000.unreads.up.sql | 0 .../db/schema/mysql/20181124173028.remove_events_tables.up.sql | 0 .../db/schema/mysql/20181205153145.messages-to-utf8mb4.up.sql | 0 .../db/schema/mysql/20190122191150.membership-flags.up.sql | 0 {sam => messaging}/db/schema/mysql/migrations.sql | 0 {sam => messaging}/db/schema/mysql/new.sh | 0 {sam => messaging}/db/types.go | 0 {sam => messaging}/flags.go | 0 {sam => messaging}/repository/attachment.go | 0 {sam => messaging}/repository/attachment_test.go | 0 {sam => messaging}/repository/channel.go | 0 {sam => messaging}/repository/channel_member.go | 0 {sam => messaging}/repository/channel_test.go | 0 {sam => messaging}/repository/error.go | 0 {sam => messaging}/repository/events.go | 0 {sam => messaging}/repository/events_test.go | 0 {sam => messaging}/repository/flags.go | 0 {sam => messaging}/repository/main_test.go | 0 {sam => messaging}/repository/mention.go | 0 {sam => messaging}/repository/message.go | 0 {sam => messaging}/repository/message_flag.go | 0 {sam => messaging}/repository/message_flag_test.go | 0 {sam => messaging}/repository/message_test.go | 0 {sam => messaging}/repository/pubsub.go | 0 {sam => messaging}/repository/pubsub_memory.go | 0 {sam => messaging}/repository/pubsub_memory_test.go | 0 {sam => messaging}/repository/pubsub_redis.go | 0 {sam => messaging}/repository/repository.go | 0 {sam => messaging}/repository/repository_test.go | 0 {sam => messaging}/repository/unread.go | 0 {sam => messaging}/repository/util.go | 0 {sam => messaging}/rest/attachment.go | 0 {sam => messaging}/rest/channel.go | 0 {sam => messaging}/rest/handlers/attachment.go | 0 {sam => messaging}/rest/handlers/attachment_custom.go | 0 {sam => messaging}/rest/handlers/channel.go | 0 {sam => messaging}/rest/handlers/message.go | 0 {sam => messaging}/rest/handlers/permissions.go | 0 {sam => messaging}/rest/handlers/search.go | 0 {sam => messaging}/rest/message.go | 0 {sam => messaging}/rest/permissions.go | 0 {sam => messaging}/rest/request/attachment.go | 0 {sam => messaging}/rest/request/channel.go | 0 {sam => messaging}/rest/request/message.go | 0 {sam => messaging}/rest/request/misc.go | 0 {sam => messaging}/rest/request/permissions.go | 0 {sam => messaging}/rest/request/search.go | 0 {sam => messaging}/rest/request/util.go | 0 {sam => messaging}/rest/request/util_test.go | 0 {sam => messaging}/rest/router.go | 0 {sam => messaging}/rest/search.go | 0 {sam => messaging}/routes.go | 0 {sam => messaging}/service/attachment.go | 0 {sam => messaging}/service/attachment_mock_test.go | 0 {sam => messaging}/service/channel.go | 0 {sam => messaging}/service/channel_mock_test.go | 0 {sam => messaging}/service/channel_test.go | 0 {sam => messaging}/service/error.go | 0 {sam => messaging}/service/events.go | 0 {sam => messaging}/service/main_test.go | 0 {sam => messaging}/service/message.go | 0 {sam => messaging}/service/message_mock_test.go | 0 {sam => messaging}/service/message_test.go | 0 {sam => messaging}/service/permissions.go | 0 {sam => messaging}/service/pubsub.go | 0 {sam => messaging}/service/service.go | 0 {sam => messaging}/start.go | 0 {sam => messaging}/types/attachment.gen.go | 0 {sam => messaging}/types/attachment.go | 0 {sam => messaging}/types/channel.gen.go | 0 {sam => messaging}/types/channel.go | 0 {sam => messaging}/types/channel.perms.gen.go | 0 {sam => messaging}/types/channel_member.gen.go | 0 {sam => messaging}/types/channel_member.go | 0 {sam => messaging}/types/command.gen.go | 0 {sam => messaging}/types/command.go | 0 {sam => messaging}/types/event_queue.go | 0 {sam => messaging}/types/main_test.go | 0 {sam => messaging}/types/mention.gen.go | 0 {sam => messaging}/types/mention.go | 0 {sam => messaging}/types/mention_test.go | 0 {sam => messaging}/types/message.gen.go | 0 {sam => messaging}/types/message.go | 0 {sam => messaging}/types/message_flag.gen.go | 0 {sam => messaging}/types/message_flag.go | 0 {sam => messaging}/types/organisation.go | 0 {sam => messaging}/types/organisation.perms.gen.go | 0 {sam => messaging}/types/permissions.go | 0 {sam => messaging}/types/permissions/1-organisation.json | 0 {sam => messaging}/types/permissions/2-team.json | 0 {sam => messaging}/types/permissions/3-channel.json | 0 {sam => messaging}/types/sets.go | 0 {sam => messaging}/types/team.go | 0 {sam => messaging}/types/team.perms.gen.go | 0 {sam => messaging}/types/unread.gen.go | 0 {sam => messaging}/types/unread.go | 0 {sam => messaging}/websocket/encoder.go | 0 {sam => messaging}/websocket/event_queue.go | 0 {sam => messaging}/websocket/router.go | 0 {sam => messaging}/websocket/session.go | 0 {sam => messaging}/websocket/session_incoming.go | 0 {sam => messaging}/websocket/session_incoming_channel.go | 0 {sam => messaging}/websocket/session_incoming_command.go | 0 {sam => messaging}/websocket/session_incoming_message.go | 0 {sam => messaging}/websocket/session_incoming_user.go | 0 {sam => messaging}/websocket/session_outgoing.go | 0 {sam => messaging}/websocket/session_store.go | 0 {sam => messaging}/websocket/session_subscriptions.go | 0 {sam => messaging}/websocket/websocket.go | 0 131 files changed, 0 insertions(+), 0 deletions(-) rename api/{sam => messaging}/message/index.md (100%) rename api/{sam => messaging}/spec.json (100%) rename api/{sam => messaging}/spec/attachment.json (100%) rename api/{sam => messaging}/spec/channel.json (100%) rename api/{sam => messaging}/spec/message.json (100%) rename api/{sam => messaging}/spec/permissions.json (100%) rename api/{sam => messaging}/spec/search.json (100%) rename api/{sam => messaging}/websocket/websocket.md (100%) rename codegen/{sam => messaging}/docs/index.php (100%) rename codegen/{sam => messaging}/rest/handlers/index.php (100%) rename codegen/{sam => messaging}/rest/index.php (100%) rename codegen/{sam => messaging}/rest/request/index.php (100%) rename docs/{sam => messaging}/README.md (100%) rename {sam => messaging}/db/migrate.go (100%) rename {sam => messaging}/db/migrate_test.go (100%) rename {sam => messaging}/db/mysql/statik.go (100%) rename {sam => messaging}/db/schema/mysql/20180704080000.base.up.sql (100%) rename {sam => messaging}/db/schema/mysql/20181009080000.altering_types.up.sql (100%) rename {sam => messaging}/db/schema/mysql/20181013080000.channel_views.up.sql (100%) rename {sam => messaging}/db/schema/mysql/20181013080000.replies.up.sql (100%) rename {sam => messaging}/db/schema/mysql/20181101080000.pins_and_reactions.up.sql (100%) rename {sam => messaging}/db/schema/mysql/20181107080000.mentions.up.sql (100%) rename {sam => messaging}/db/schema/mysql/20181115080000.unreads.up.sql (100%) rename {sam => messaging}/db/schema/mysql/20181124173028.remove_events_tables.up.sql (100%) rename {sam => messaging}/db/schema/mysql/20181205153145.messages-to-utf8mb4.up.sql (100%) rename {sam => messaging}/db/schema/mysql/20190122191150.membership-flags.up.sql (100%) rename {sam => messaging}/db/schema/mysql/migrations.sql (100%) rename {sam => messaging}/db/schema/mysql/new.sh (100%) rename {sam => messaging}/db/types.go (100%) rename {sam => messaging}/flags.go (100%) rename {sam => messaging}/repository/attachment.go (100%) rename {sam => messaging}/repository/attachment_test.go (100%) rename {sam => messaging}/repository/channel.go (100%) rename {sam => messaging}/repository/channel_member.go (100%) rename {sam => messaging}/repository/channel_test.go (100%) rename {sam => messaging}/repository/error.go (100%) rename {sam => messaging}/repository/events.go (100%) rename {sam => messaging}/repository/events_test.go (100%) rename {sam => messaging}/repository/flags.go (100%) rename {sam => messaging}/repository/main_test.go (100%) rename {sam => messaging}/repository/mention.go (100%) rename {sam => messaging}/repository/message.go (100%) rename {sam => messaging}/repository/message_flag.go (100%) rename {sam => messaging}/repository/message_flag_test.go (100%) rename {sam => messaging}/repository/message_test.go (100%) rename {sam => messaging}/repository/pubsub.go (100%) rename {sam => messaging}/repository/pubsub_memory.go (100%) rename {sam => messaging}/repository/pubsub_memory_test.go (100%) rename {sam => messaging}/repository/pubsub_redis.go (100%) rename {sam => messaging}/repository/repository.go (100%) rename {sam => messaging}/repository/repository_test.go (100%) rename {sam => messaging}/repository/unread.go (100%) rename {sam => messaging}/repository/util.go (100%) rename {sam => messaging}/rest/attachment.go (100%) rename {sam => messaging}/rest/channel.go (100%) rename {sam => messaging}/rest/handlers/attachment.go (100%) rename {sam => messaging}/rest/handlers/attachment_custom.go (100%) rename {sam => messaging}/rest/handlers/channel.go (100%) rename {sam => messaging}/rest/handlers/message.go (100%) rename {sam => messaging}/rest/handlers/permissions.go (100%) rename {sam => messaging}/rest/handlers/search.go (100%) rename {sam => messaging}/rest/message.go (100%) rename {sam => messaging}/rest/permissions.go (100%) rename {sam => messaging}/rest/request/attachment.go (100%) rename {sam => messaging}/rest/request/channel.go (100%) rename {sam => messaging}/rest/request/message.go (100%) rename {sam => messaging}/rest/request/misc.go (100%) rename {sam => messaging}/rest/request/permissions.go (100%) rename {sam => messaging}/rest/request/search.go (100%) rename {sam => messaging}/rest/request/util.go (100%) rename {sam => messaging}/rest/request/util_test.go (100%) rename {sam => messaging}/rest/router.go (100%) rename {sam => messaging}/rest/search.go (100%) rename {sam => messaging}/routes.go (100%) rename {sam => messaging}/service/attachment.go (100%) rename {sam => messaging}/service/attachment_mock_test.go (100%) rename {sam => messaging}/service/channel.go (100%) rename {sam => messaging}/service/channel_mock_test.go (100%) rename {sam => messaging}/service/channel_test.go (100%) rename {sam => messaging}/service/error.go (100%) rename {sam => messaging}/service/events.go (100%) rename {sam => messaging}/service/main_test.go (100%) rename {sam => messaging}/service/message.go (100%) rename {sam => messaging}/service/message_mock_test.go (100%) rename {sam => messaging}/service/message_test.go (100%) rename {sam => messaging}/service/permissions.go (100%) rename {sam => messaging}/service/pubsub.go (100%) rename {sam => messaging}/service/service.go (100%) rename {sam => messaging}/start.go (100%) rename {sam => messaging}/types/attachment.gen.go (100%) rename {sam => messaging}/types/attachment.go (100%) rename {sam => messaging}/types/channel.gen.go (100%) rename {sam => messaging}/types/channel.go (100%) rename {sam => messaging}/types/channel.perms.gen.go (100%) rename {sam => messaging}/types/channel_member.gen.go (100%) rename {sam => messaging}/types/channel_member.go (100%) rename {sam => messaging}/types/command.gen.go (100%) rename {sam => messaging}/types/command.go (100%) rename {sam => messaging}/types/event_queue.go (100%) rename {sam => messaging}/types/main_test.go (100%) rename {sam => messaging}/types/mention.gen.go (100%) rename {sam => messaging}/types/mention.go (100%) rename {sam => messaging}/types/mention_test.go (100%) rename {sam => messaging}/types/message.gen.go (100%) rename {sam => messaging}/types/message.go (100%) rename {sam => messaging}/types/message_flag.gen.go (100%) rename {sam => messaging}/types/message_flag.go (100%) rename {sam => messaging}/types/organisation.go (100%) rename {sam => messaging}/types/organisation.perms.gen.go (100%) rename {sam => messaging}/types/permissions.go (100%) rename {sam => messaging}/types/permissions/1-organisation.json (100%) rename {sam => messaging}/types/permissions/2-team.json (100%) rename {sam => messaging}/types/permissions/3-channel.json (100%) rename {sam => messaging}/types/sets.go (100%) rename {sam => messaging}/types/team.go (100%) rename {sam => messaging}/types/team.perms.gen.go (100%) rename {sam => messaging}/types/unread.gen.go (100%) rename {sam => messaging}/types/unread.go (100%) rename {sam => messaging}/websocket/encoder.go (100%) rename {sam => messaging}/websocket/event_queue.go (100%) rename {sam => messaging}/websocket/router.go (100%) rename {sam => messaging}/websocket/session.go (100%) rename {sam => messaging}/websocket/session_incoming.go (100%) rename {sam => messaging}/websocket/session_incoming_channel.go (100%) rename {sam => messaging}/websocket/session_incoming_command.go (100%) rename {sam => messaging}/websocket/session_incoming_message.go (100%) rename {sam => messaging}/websocket/session_incoming_user.go (100%) rename {sam => messaging}/websocket/session_outgoing.go (100%) rename {sam => messaging}/websocket/session_store.go (100%) rename {sam => messaging}/websocket/session_subscriptions.go (100%) rename {sam => messaging}/websocket/websocket.go (100%) diff --git a/api/sam/message/index.md b/api/messaging/message/index.md similarity index 100% rename from api/sam/message/index.md rename to api/messaging/message/index.md diff --git a/api/sam/spec.json b/api/messaging/spec.json similarity index 100% rename from api/sam/spec.json rename to api/messaging/spec.json diff --git a/api/sam/spec/attachment.json b/api/messaging/spec/attachment.json similarity index 100% rename from api/sam/spec/attachment.json rename to api/messaging/spec/attachment.json diff --git a/api/sam/spec/channel.json b/api/messaging/spec/channel.json similarity index 100% rename from api/sam/spec/channel.json rename to api/messaging/spec/channel.json diff --git a/api/sam/spec/message.json b/api/messaging/spec/message.json similarity index 100% rename from api/sam/spec/message.json rename to api/messaging/spec/message.json diff --git a/api/sam/spec/permissions.json b/api/messaging/spec/permissions.json similarity index 100% rename from api/sam/spec/permissions.json rename to api/messaging/spec/permissions.json diff --git a/api/sam/spec/search.json b/api/messaging/spec/search.json similarity index 100% rename from api/sam/spec/search.json rename to api/messaging/spec/search.json diff --git a/api/sam/websocket/websocket.md b/api/messaging/websocket/websocket.md similarity index 100% rename from api/sam/websocket/websocket.md rename to api/messaging/websocket/websocket.md diff --git a/codegen/sam/docs/index.php b/codegen/messaging/docs/index.php similarity index 100% rename from codegen/sam/docs/index.php rename to codegen/messaging/docs/index.php diff --git a/codegen/sam/rest/handlers/index.php b/codegen/messaging/rest/handlers/index.php similarity index 100% rename from codegen/sam/rest/handlers/index.php rename to codegen/messaging/rest/handlers/index.php diff --git a/codegen/sam/rest/index.php b/codegen/messaging/rest/index.php similarity index 100% rename from codegen/sam/rest/index.php rename to codegen/messaging/rest/index.php diff --git a/codegen/sam/rest/request/index.php b/codegen/messaging/rest/request/index.php similarity index 100% rename from codegen/sam/rest/request/index.php rename to codegen/messaging/rest/request/index.php diff --git a/docs/sam/README.md b/docs/messaging/README.md similarity index 100% rename from docs/sam/README.md rename to docs/messaging/README.md diff --git a/sam/db/migrate.go b/messaging/db/migrate.go similarity index 100% rename from sam/db/migrate.go rename to messaging/db/migrate.go diff --git a/sam/db/migrate_test.go b/messaging/db/migrate_test.go similarity index 100% rename from sam/db/migrate_test.go rename to messaging/db/migrate_test.go diff --git a/sam/db/mysql/statik.go b/messaging/db/mysql/statik.go similarity index 100% rename from sam/db/mysql/statik.go rename to messaging/db/mysql/statik.go diff --git a/sam/db/schema/mysql/20180704080000.base.up.sql b/messaging/db/schema/mysql/20180704080000.base.up.sql similarity index 100% rename from sam/db/schema/mysql/20180704080000.base.up.sql rename to messaging/db/schema/mysql/20180704080000.base.up.sql diff --git a/sam/db/schema/mysql/20181009080000.altering_types.up.sql b/messaging/db/schema/mysql/20181009080000.altering_types.up.sql similarity index 100% rename from sam/db/schema/mysql/20181009080000.altering_types.up.sql rename to messaging/db/schema/mysql/20181009080000.altering_types.up.sql diff --git a/sam/db/schema/mysql/20181013080000.channel_views.up.sql b/messaging/db/schema/mysql/20181013080000.channel_views.up.sql similarity index 100% rename from sam/db/schema/mysql/20181013080000.channel_views.up.sql rename to messaging/db/schema/mysql/20181013080000.channel_views.up.sql diff --git a/sam/db/schema/mysql/20181013080000.replies.up.sql b/messaging/db/schema/mysql/20181013080000.replies.up.sql similarity index 100% rename from sam/db/schema/mysql/20181013080000.replies.up.sql rename to messaging/db/schema/mysql/20181013080000.replies.up.sql diff --git a/sam/db/schema/mysql/20181101080000.pins_and_reactions.up.sql b/messaging/db/schema/mysql/20181101080000.pins_and_reactions.up.sql similarity index 100% rename from sam/db/schema/mysql/20181101080000.pins_and_reactions.up.sql rename to messaging/db/schema/mysql/20181101080000.pins_and_reactions.up.sql diff --git a/sam/db/schema/mysql/20181107080000.mentions.up.sql b/messaging/db/schema/mysql/20181107080000.mentions.up.sql similarity index 100% rename from sam/db/schema/mysql/20181107080000.mentions.up.sql rename to messaging/db/schema/mysql/20181107080000.mentions.up.sql diff --git a/sam/db/schema/mysql/20181115080000.unreads.up.sql b/messaging/db/schema/mysql/20181115080000.unreads.up.sql similarity index 100% rename from sam/db/schema/mysql/20181115080000.unreads.up.sql rename to messaging/db/schema/mysql/20181115080000.unreads.up.sql diff --git a/sam/db/schema/mysql/20181124173028.remove_events_tables.up.sql b/messaging/db/schema/mysql/20181124173028.remove_events_tables.up.sql similarity index 100% rename from sam/db/schema/mysql/20181124173028.remove_events_tables.up.sql rename to messaging/db/schema/mysql/20181124173028.remove_events_tables.up.sql diff --git a/sam/db/schema/mysql/20181205153145.messages-to-utf8mb4.up.sql b/messaging/db/schema/mysql/20181205153145.messages-to-utf8mb4.up.sql similarity index 100% rename from sam/db/schema/mysql/20181205153145.messages-to-utf8mb4.up.sql rename to messaging/db/schema/mysql/20181205153145.messages-to-utf8mb4.up.sql diff --git a/sam/db/schema/mysql/20190122191150.membership-flags.up.sql b/messaging/db/schema/mysql/20190122191150.membership-flags.up.sql similarity index 100% rename from sam/db/schema/mysql/20190122191150.membership-flags.up.sql rename to messaging/db/schema/mysql/20190122191150.membership-flags.up.sql diff --git a/sam/db/schema/mysql/migrations.sql b/messaging/db/schema/mysql/migrations.sql similarity index 100% rename from sam/db/schema/mysql/migrations.sql rename to messaging/db/schema/mysql/migrations.sql diff --git a/sam/db/schema/mysql/new.sh b/messaging/db/schema/mysql/new.sh similarity index 100% rename from sam/db/schema/mysql/new.sh rename to messaging/db/schema/mysql/new.sh diff --git a/sam/db/types.go b/messaging/db/types.go similarity index 100% rename from sam/db/types.go rename to messaging/db/types.go diff --git a/sam/flags.go b/messaging/flags.go similarity index 100% rename from sam/flags.go rename to messaging/flags.go diff --git a/sam/repository/attachment.go b/messaging/repository/attachment.go similarity index 100% rename from sam/repository/attachment.go rename to messaging/repository/attachment.go diff --git a/sam/repository/attachment_test.go b/messaging/repository/attachment_test.go similarity index 100% rename from sam/repository/attachment_test.go rename to messaging/repository/attachment_test.go diff --git a/sam/repository/channel.go b/messaging/repository/channel.go similarity index 100% rename from sam/repository/channel.go rename to messaging/repository/channel.go diff --git a/sam/repository/channel_member.go b/messaging/repository/channel_member.go similarity index 100% rename from sam/repository/channel_member.go rename to messaging/repository/channel_member.go diff --git a/sam/repository/channel_test.go b/messaging/repository/channel_test.go similarity index 100% rename from sam/repository/channel_test.go rename to messaging/repository/channel_test.go diff --git a/sam/repository/error.go b/messaging/repository/error.go similarity index 100% rename from sam/repository/error.go rename to messaging/repository/error.go diff --git a/sam/repository/events.go b/messaging/repository/events.go similarity index 100% rename from sam/repository/events.go rename to messaging/repository/events.go diff --git a/sam/repository/events_test.go b/messaging/repository/events_test.go similarity index 100% rename from sam/repository/events_test.go rename to messaging/repository/events_test.go diff --git a/sam/repository/flags.go b/messaging/repository/flags.go similarity index 100% rename from sam/repository/flags.go rename to messaging/repository/flags.go diff --git a/sam/repository/main_test.go b/messaging/repository/main_test.go similarity index 100% rename from sam/repository/main_test.go rename to messaging/repository/main_test.go diff --git a/sam/repository/mention.go b/messaging/repository/mention.go similarity index 100% rename from sam/repository/mention.go rename to messaging/repository/mention.go diff --git a/sam/repository/message.go b/messaging/repository/message.go similarity index 100% rename from sam/repository/message.go rename to messaging/repository/message.go diff --git a/sam/repository/message_flag.go b/messaging/repository/message_flag.go similarity index 100% rename from sam/repository/message_flag.go rename to messaging/repository/message_flag.go diff --git a/sam/repository/message_flag_test.go b/messaging/repository/message_flag_test.go similarity index 100% rename from sam/repository/message_flag_test.go rename to messaging/repository/message_flag_test.go diff --git a/sam/repository/message_test.go b/messaging/repository/message_test.go similarity index 100% rename from sam/repository/message_test.go rename to messaging/repository/message_test.go diff --git a/sam/repository/pubsub.go b/messaging/repository/pubsub.go similarity index 100% rename from sam/repository/pubsub.go rename to messaging/repository/pubsub.go diff --git a/sam/repository/pubsub_memory.go b/messaging/repository/pubsub_memory.go similarity index 100% rename from sam/repository/pubsub_memory.go rename to messaging/repository/pubsub_memory.go diff --git a/sam/repository/pubsub_memory_test.go b/messaging/repository/pubsub_memory_test.go similarity index 100% rename from sam/repository/pubsub_memory_test.go rename to messaging/repository/pubsub_memory_test.go diff --git a/sam/repository/pubsub_redis.go b/messaging/repository/pubsub_redis.go similarity index 100% rename from sam/repository/pubsub_redis.go rename to messaging/repository/pubsub_redis.go diff --git a/sam/repository/repository.go b/messaging/repository/repository.go similarity index 100% rename from sam/repository/repository.go rename to messaging/repository/repository.go diff --git a/sam/repository/repository_test.go b/messaging/repository/repository_test.go similarity index 100% rename from sam/repository/repository_test.go rename to messaging/repository/repository_test.go diff --git a/sam/repository/unread.go b/messaging/repository/unread.go similarity index 100% rename from sam/repository/unread.go rename to messaging/repository/unread.go diff --git a/sam/repository/util.go b/messaging/repository/util.go similarity index 100% rename from sam/repository/util.go rename to messaging/repository/util.go diff --git a/sam/rest/attachment.go b/messaging/rest/attachment.go similarity index 100% rename from sam/rest/attachment.go rename to messaging/rest/attachment.go diff --git a/sam/rest/channel.go b/messaging/rest/channel.go similarity index 100% rename from sam/rest/channel.go rename to messaging/rest/channel.go diff --git a/sam/rest/handlers/attachment.go b/messaging/rest/handlers/attachment.go similarity index 100% rename from sam/rest/handlers/attachment.go rename to messaging/rest/handlers/attachment.go diff --git a/sam/rest/handlers/attachment_custom.go b/messaging/rest/handlers/attachment_custom.go similarity index 100% rename from sam/rest/handlers/attachment_custom.go rename to messaging/rest/handlers/attachment_custom.go diff --git a/sam/rest/handlers/channel.go b/messaging/rest/handlers/channel.go similarity index 100% rename from sam/rest/handlers/channel.go rename to messaging/rest/handlers/channel.go diff --git a/sam/rest/handlers/message.go b/messaging/rest/handlers/message.go similarity index 100% rename from sam/rest/handlers/message.go rename to messaging/rest/handlers/message.go diff --git a/sam/rest/handlers/permissions.go b/messaging/rest/handlers/permissions.go similarity index 100% rename from sam/rest/handlers/permissions.go rename to messaging/rest/handlers/permissions.go diff --git a/sam/rest/handlers/search.go b/messaging/rest/handlers/search.go similarity index 100% rename from sam/rest/handlers/search.go rename to messaging/rest/handlers/search.go diff --git a/sam/rest/message.go b/messaging/rest/message.go similarity index 100% rename from sam/rest/message.go rename to messaging/rest/message.go diff --git a/sam/rest/permissions.go b/messaging/rest/permissions.go similarity index 100% rename from sam/rest/permissions.go rename to messaging/rest/permissions.go diff --git a/sam/rest/request/attachment.go b/messaging/rest/request/attachment.go similarity index 100% rename from sam/rest/request/attachment.go rename to messaging/rest/request/attachment.go diff --git a/sam/rest/request/channel.go b/messaging/rest/request/channel.go similarity index 100% rename from sam/rest/request/channel.go rename to messaging/rest/request/channel.go diff --git a/sam/rest/request/message.go b/messaging/rest/request/message.go similarity index 100% rename from sam/rest/request/message.go rename to messaging/rest/request/message.go diff --git a/sam/rest/request/misc.go b/messaging/rest/request/misc.go similarity index 100% rename from sam/rest/request/misc.go rename to messaging/rest/request/misc.go diff --git a/sam/rest/request/permissions.go b/messaging/rest/request/permissions.go similarity index 100% rename from sam/rest/request/permissions.go rename to messaging/rest/request/permissions.go diff --git a/sam/rest/request/search.go b/messaging/rest/request/search.go similarity index 100% rename from sam/rest/request/search.go rename to messaging/rest/request/search.go diff --git a/sam/rest/request/util.go b/messaging/rest/request/util.go similarity index 100% rename from sam/rest/request/util.go rename to messaging/rest/request/util.go diff --git a/sam/rest/request/util_test.go b/messaging/rest/request/util_test.go similarity index 100% rename from sam/rest/request/util_test.go rename to messaging/rest/request/util_test.go diff --git a/sam/rest/router.go b/messaging/rest/router.go similarity index 100% rename from sam/rest/router.go rename to messaging/rest/router.go diff --git a/sam/rest/search.go b/messaging/rest/search.go similarity index 100% rename from sam/rest/search.go rename to messaging/rest/search.go diff --git a/sam/routes.go b/messaging/routes.go similarity index 100% rename from sam/routes.go rename to messaging/routes.go diff --git a/sam/service/attachment.go b/messaging/service/attachment.go similarity index 100% rename from sam/service/attachment.go rename to messaging/service/attachment.go diff --git a/sam/service/attachment_mock_test.go b/messaging/service/attachment_mock_test.go similarity index 100% rename from sam/service/attachment_mock_test.go rename to messaging/service/attachment_mock_test.go diff --git a/sam/service/channel.go b/messaging/service/channel.go similarity index 100% rename from sam/service/channel.go rename to messaging/service/channel.go diff --git a/sam/service/channel_mock_test.go b/messaging/service/channel_mock_test.go similarity index 100% rename from sam/service/channel_mock_test.go rename to messaging/service/channel_mock_test.go diff --git a/sam/service/channel_test.go b/messaging/service/channel_test.go similarity index 100% rename from sam/service/channel_test.go rename to messaging/service/channel_test.go diff --git a/sam/service/error.go b/messaging/service/error.go similarity index 100% rename from sam/service/error.go rename to messaging/service/error.go diff --git a/sam/service/events.go b/messaging/service/events.go similarity index 100% rename from sam/service/events.go rename to messaging/service/events.go diff --git a/sam/service/main_test.go b/messaging/service/main_test.go similarity index 100% rename from sam/service/main_test.go rename to messaging/service/main_test.go diff --git a/sam/service/message.go b/messaging/service/message.go similarity index 100% rename from sam/service/message.go rename to messaging/service/message.go diff --git a/sam/service/message_mock_test.go b/messaging/service/message_mock_test.go similarity index 100% rename from sam/service/message_mock_test.go rename to messaging/service/message_mock_test.go diff --git a/sam/service/message_test.go b/messaging/service/message_test.go similarity index 100% rename from sam/service/message_test.go rename to messaging/service/message_test.go diff --git a/sam/service/permissions.go b/messaging/service/permissions.go similarity index 100% rename from sam/service/permissions.go rename to messaging/service/permissions.go diff --git a/sam/service/pubsub.go b/messaging/service/pubsub.go similarity index 100% rename from sam/service/pubsub.go rename to messaging/service/pubsub.go diff --git a/sam/service/service.go b/messaging/service/service.go similarity index 100% rename from sam/service/service.go rename to messaging/service/service.go diff --git a/sam/start.go b/messaging/start.go similarity index 100% rename from sam/start.go rename to messaging/start.go diff --git a/sam/types/attachment.gen.go b/messaging/types/attachment.gen.go similarity index 100% rename from sam/types/attachment.gen.go rename to messaging/types/attachment.gen.go diff --git a/sam/types/attachment.go b/messaging/types/attachment.go similarity index 100% rename from sam/types/attachment.go rename to messaging/types/attachment.go diff --git a/sam/types/channel.gen.go b/messaging/types/channel.gen.go similarity index 100% rename from sam/types/channel.gen.go rename to messaging/types/channel.gen.go diff --git a/sam/types/channel.go b/messaging/types/channel.go similarity index 100% rename from sam/types/channel.go rename to messaging/types/channel.go diff --git a/sam/types/channel.perms.gen.go b/messaging/types/channel.perms.gen.go similarity index 100% rename from sam/types/channel.perms.gen.go rename to messaging/types/channel.perms.gen.go diff --git a/sam/types/channel_member.gen.go b/messaging/types/channel_member.gen.go similarity index 100% rename from sam/types/channel_member.gen.go rename to messaging/types/channel_member.gen.go diff --git a/sam/types/channel_member.go b/messaging/types/channel_member.go similarity index 100% rename from sam/types/channel_member.go rename to messaging/types/channel_member.go diff --git a/sam/types/command.gen.go b/messaging/types/command.gen.go similarity index 100% rename from sam/types/command.gen.go rename to messaging/types/command.gen.go diff --git a/sam/types/command.go b/messaging/types/command.go similarity index 100% rename from sam/types/command.go rename to messaging/types/command.go diff --git a/sam/types/event_queue.go b/messaging/types/event_queue.go similarity index 100% rename from sam/types/event_queue.go rename to messaging/types/event_queue.go diff --git a/sam/types/main_test.go b/messaging/types/main_test.go similarity index 100% rename from sam/types/main_test.go rename to messaging/types/main_test.go diff --git a/sam/types/mention.gen.go b/messaging/types/mention.gen.go similarity index 100% rename from sam/types/mention.gen.go rename to messaging/types/mention.gen.go diff --git a/sam/types/mention.go b/messaging/types/mention.go similarity index 100% rename from sam/types/mention.go rename to messaging/types/mention.go diff --git a/sam/types/mention_test.go b/messaging/types/mention_test.go similarity index 100% rename from sam/types/mention_test.go rename to messaging/types/mention_test.go diff --git a/sam/types/message.gen.go b/messaging/types/message.gen.go similarity index 100% rename from sam/types/message.gen.go rename to messaging/types/message.gen.go diff --git a/sam/types/message.go b/messaging/types/message.go similarity index 100% rename from sam/types/message.go rename to messaging/types/message.go diff --git a/sam/types/message_flag.gen.go b/messaging/types/message_flag.gen.go similarity index 100% rename from sam/types/message_flag.gen.go rename to messaging/types/message_flag.gen.go diff --git a/sam/types/message_flag.go b/messaging/types/message_flag.go similarity index 100% rename from sam/types/message_flag.go rename to messaging/types/message_flag.go diff --git a/sam/types/organisation.go b/messaging/types/organisation.go similarity index 100% rename from sam/types/organisation.go rename to messaging/types/organisation.go diff --git a/sam/types/organisation.perms.gen.go b/messaging/types/organisation.perms.gen.go similarity index 100% rename from sam/types/organisation.perms.gen.go rename to messaging/types/organisation.perms.gen.go diff --git a/sam/types/permissions.go b/messaging/types/permissions.go similarity index 100% rename from sam/types/permissions.go rename to messaging/types/permissions.go diff --git a/sam/types/permissions/1-organisation.json b/messaging/types/permissions/1-organisation.json similarity index 100% rename from sam/types/permissions/1-organisation.json rename to messaging/types/permissions/1-organisation.json diff --git a/sam/types/permissions/2-team.json b/messaging/types/permissions/2-team.json similarity index 100% rename from sam/types/permissions/2-team.json rename to messaging/types/permissions/2-team.json diff --git a/sam/types/permissions/3-channel.json b/messaging/types/permissions/3-channel.json similarity index 100% rename from sam/types/permissions/3-channel.json rename to messaging/types/permissions/3-channel.json diff --git a/sam/types/sets.go b/messaging/types/sets.go similarity index 100% rename from sam/types/sets.go rename to messaging/types/sets.go diff --git a/sam/types/team.go b/messaging/types/team.go similarity index 100% rename from sam/types/team.go rename to messaging/types/team.go diff --git a/sam/types/team.perms.gen.go b/messaging/types/team.perms.gen.go similarity index 100% rename from sam/types/team.perms.gen.go rename to messaging/types/team.perms.gen.go diff --git a/sam/types/unread.gen.go b/messaging/types/unread.gen.go similarity index 100% rename from sam/types/unread.gen.go rename to messaging/types/unread.gen.go diff --git a/sam/types/unread.go b/messaging/types/unread.go similarity index 100% rename from sam/types/unread.go rename to messaging/types/unread.go diff --git a/sam/websocket/encoder.go b/messaging/websocket/encoder.go similarity index 100% rename from sam/websocket/encoder.go rename to messaging/websocket/encoder.go diff --git a/sam/websocket/event_queue.go b/messaging/websocket/event_queue.go similarity index 100% rename from sam/websocket/event_queue.go rename to messaging/websocket/event_queue.go diff --git a/sam/websocket/router.go b/messaging/websocket/router.go similarity index 100% rename from sam/websocket/router.go rename to messaging/websocket/router.go diff --git a/sam/websocket/session.go b/messaging/websocket/session.go similarity index 100% rename from sam/websocket/session.go rename to messaging/websocket/session.go diff --git a/sam/websocket/session_incoming.go b/messaging/websocket/session_incoming.go similarity index 100% rename from sam/websocket/session_incoming.go rename to messaging/websocket/session_incoming.go diff --git a/sam/websocket/session_incoming_channel.go b/messaging/websocket/session_incoming_channel.go similarity index 100% rename from sam/websocket/session_incoming_channel.go rename to messaging/websocket/session_incoming_channel.go diff --git a/sam/websocket/session_incoming_command.go b/messaging/websocket/session_incoming_command.go similarity index 100% rename from sam/websocket/session_incoming_command.go rename to messaging/websocket/session_incoming_command.go diff --git a/sam/websocket/session_incoming_message.go b/messaging/websocket/session_incoming_message.go similarity index 100% rename from sam/websocket/session_incoming_message.go rename to messaging/websocket/session_incoming_message.go diff --git a/sam/websocket/session_incoming_user.go b/messaging/websocket/session_incoming_user.go similarity index 100% rename from sam/websocket/session_incoming_user.go rename to messaging/websocket/session_incoming_user.go diff --git a/sam/websocket/session_outgoing.go b/messaging/websocket/session_outgoing.go similarity index 100% rename from sam/websocket/session_outgoing.go rename to messaging/websocket/session_outgoing.go diff --git a/sam/websocket/session_store.go b/messaging/websocket/session_store.go similarity index 100% rename from sam/websocket/session_store.go rename to messaging/websocket/session_store.go diff --git a/sam/websocket/session_subscriptions.go b/messaging/websocket/session_subscriptions.go similarity index 100% rename from sam/websocket/session_subscriptions.go rename to messaging/websocket/session_subscriptions.go diff --git a/sam/websocket/websocket.go b/messaging/websocket/websocket.go similarity index 100% rename from sam/websocket/websocket.go rename to messaging/websocket/websocket.go From e6434e502bded703b1c363b0c31a8d8d466021cd Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:10:07 +0100 Subject: [PATCH 02/15] upd(messaging): remove package names from spec --- api/crm/spec.json | 4 ---- api/crm/spec/chart.json | 1 - api/crm/spec/module.json | 1 - api/crm/spec/notification.json | 1 - api/crm/spec/page.json | 1 - api/crm/spec/trigger.json | 1 - api/messaging/spec.json | 4 ---- api/messaging/spec/attachment.json | 1 - api/messaging/spec/channel.json | 1 - api/messaging/spec/message.json | 1 - api/messaging/spec/permissions.json | 1 - api/messaging/spec/search.json | 1 - api/system/spec.json | 4 ---- api/system/spec/auth.json | 1 - api/system/spec/organisation.json | 1 - api/system/spec/team.json | 1 - api/system/spec/user.json | 1 - 17 files changed, 26 deletions(-) diff --git a/api/crm/spec.json b/api/crm/spec.json index c19653426..14580a812 100644 --- a/api/crm/spec.json +++ b/api/crm/spec.json @@ -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": [], diff --git a/api/crm/spec/chart.json b/api/crm/spec/chart.json index 0917f3650..bf1cb21fb 100644 --- a/api/crm/spec/chart.json +++ b/api/crm/spec/chart.json @@ -1,6 +1,5 @@ { "Title": "Charts", - "Package": "", "Interface": "Chart", "Struct": [ { diff --git a/api/crm/spec/module.json b/api/crm/spec/module.json index 4016f9a6a..e10925d11 100644 --- a/api/crm/spec/module.json +++ b/api/crm/spec/module.json @@ -1,7 +1,6 @@ { "Title": "Modules", "Description": "CRM module definitions", - "Package": "crm", "Interface": "Module", "Struct": [ { diff --git a/api/crm/spec/notification.json b/api/crm/spec/notification.json index d25ee339b..c1eed0a98 100644 --- a/api/crm/spec/notification.json +++ b/api/crm/spec/notification.json @@ -1,7 +1,6 @@ { "Title": "Notifications", "Description": "CRM Notifications", - "Package": "crm", "Interface": "Notification", "Struct": [ { diff --git a/api/crm/spec/page.json b/api/crm/spec/page.json index 83a71b8e7..d8486a517 100644 --- a/api/crm/spec/page.json +++ b/api/crm/spec/page.json @@ -1,7 +1,6 @@ { "Title": "Pages", "Description": "CRM module pages", - "Package": "crm", "Interface": "Page", "Struct": [ { diff --git a/api/crm/spec/trigger.json b/api/crm/spec/trigger.json index 47c014dba..5d497cc60 100644 --- a/api/crm/spec/trigger.json +++ b/api/crm/spec/trigger.json @@ -1,7 +1,6 @@ { "Title": "Triggers", "Description": "CRM Triggers", - "Package": "crm", "Interface": "Trigger", "Struct": null, "Parameters": null, diff --git a/api/messaging/spec.json b/api/messaging/spec.json index ff278b59a..eb5ef8a39 100644 --- a/api/messaging/spec.json +++ b/api/messaging/spec.json @@ -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": [ diff --git a/api/messaging/spec/attachment.json b/api/messaging/spec/attachment.json index eed54b339..a20f0eca0 100644 --- a/api/messaging/spec/attachment.json +++ b/api/messaging/spec/attachment.json @@ -1,6 +1,5 @@ { "Title": "Attachments", - "Package": "sam", "Interface": "Attachment", "Struct": null, "Parameters": { diff --git a/api/messaging/spec/channel.json b/api/messaging/spec/channel.json index 7bbea5aa2..66998d9bd 100644 --- a/api/messaging/spec/channel.json +++ b/api/messaging/spec/channel.json @@ -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, diff --git a/api/messaging/spec/message.json b/api/messaging/spec/message.json index 2c90d4fde..84ec828b3 100644 --- a/api/messaging/spec/message.json +++ b/api/messaging/spec/message.json @@ -1,6 +1,5 @@ { "Title": "Messages", - "Package": "sam", "Interface": "Message", "Struct": null, "Parameters": { diff --git a/api/messaging/spec/permissions.json b/api/messaging/spec/permissions.json index 80cd69fc4..1441524de 100644 --- a/api/messaging/spec/permissions.json +++ b/api/messaging/spec/permissions.json @@ -1,6 +1,5 @@ { "Title": "Permissions", - "Package": "sam", "Interface": "Permissions", "Struct": [ { diff --git a/api/messaging/spec/search.json b/api/messaging/spec/search.json index 3fc6b69a9..fa0285970 100644 --- a/api/messaging/spec/search.json +++ b/api/messaging/spec/search.json @@ -1,6 +1,5 @@ { "Title": "Search entry point", - "Package": "", "Interface": "Search", "Struct": null, "Parameters": { diff --git a/api/system/spec.json b/api/system/spec.json index a73c4f4dd..cbe4a2301 100644 --- a/api/system/spec.json +++ b/api/system/spec.json @@ -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": [ diff --git a/api/system/spec/auth.json b/api/system/spec/auth.json index 5011fcb51..af8c321a6 100644 --- a/api/system/spec/auth.json +++ b/api/system/spec/auth.json @@ -1,6 +1,5 @@ { "Title": "Authentication", - "Package": "auth", "Interface": "Auth", "Struct": null, "Parameters": null, diff --git a/api/system/spec/organisation.json b/api/system/spec/organisation.json index 8fec986f0..399ee27e3 100644 --- a/api/system/spec/organisation.json +++ b/api/system/spec/organisation.json @@ -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, diff --git a/api/system/spec/team.json b/api/system/spec/team.json index d8dcf05e8..5cbb4b330 100644 --- a/api/system/spec/team.json +++ b/api/system/spec/team.json @@ -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, diff --git a/api/system/spec/user.json b/api/system/spec/user.json index 3d710e78c..196fc7e2c 100644 --- a/api/system/spec/user.json +++ b/api/system/spec/user.json @@ -1,6 +1,5 @@ { "Title": "Users", - "Package": "sam", "Interface": "User", "Struct": [ { From ba5413b5832fa3c64b1bed115b003db324f53ee3 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:11:52 +0100 Subject: [PATCH 03/15] upd(messaging): update codegen, add spec to codegen --- codegen.sh | 60 +++++++++------- codegen/codegen_old.php | 94 ------------------------- codegen/v2/spec.go | 151 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+), 120 deletions(-) delete mode 100755 codegen/codegen_old.php create mode 100644 codegen/v2/spec.go diff --git a/codegen.sh b/codegen.sh index 93cdc5632..8b70f3e16 100755 --- a/codegen.sh +++ b/codegen.sh @@ -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 diff --git a/codegen/codegen_old.php b/codegen/codegen_old.php deleted file mode 100755 index c74663b27..000000000 --- a/codegen/codegen_old.php +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env php -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); -} diff --git a/codegen/v2/spec.go b/codegen/v2/spec.go new file mode 100644 index 000000000..c471c5a63 --- /dev/null +++ b/codegen/v2/spec.go @@ -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) + } +} From 556776a70b1c300d8dd2750b622a8f5751dee18e Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:12:23 +0100 Subject: [PATCH 04/15] upd(Makefile): rename sam/ to messaging/ --- Makefile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 8c9a34146..3279f529b 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ -.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 ######################################################################################################################## @@ -28,7 +28,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 @@ -74,22 +74,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 +149,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 From e9609287a989c74367459056968cfa194c786221 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:15:08 +0100 Subject: [PATCH 05/15] upd(messaging): update import paths --- cmd/messaging/main.go | 2 +- cmd/system-cli/users.go | 2 +- internal/payload/outgoing.go | 2 +- messaging/db/migrate.go | 2 +- messaging/flags.go | 2 +- messaging/repository/attachment.go | 2 +- messaging/repository/attachment_test.go | 2 +- messaging/repository/channel.go | 2 +- messaging/repository/channel_member.go | 2 +- messaging/repository/channel_test.go | 2 +- messaging/repository/events.go | 2 +- messaging/repository/events_test.go | 2 +- messaging/repository/main_test.go | 2 +- messaging/repository/mention.go | 2 +- messaging/repository/message.go | 2 +- messaging/repository/message_flag.go | 2 +- messaging/repository/message_flag_test.go | 2 +- messaging/repository/message_test.go | 2 +- messaging/repository/unread.go | 2 +- messaging/rest/attachment.go | 8 ++++---- messaging/rest/channel.go | 6 +++--- messaging/rest/handlers/attachment.go | 2 +- messaging/rest/handlers/attachment_custom.go | 2 +- messaging/rest/handlers/channel.go | 2 +- messaging/rest/handlers/message.go | 2 +- messaging/rest/handlers/permissions.go | 2 +- messaging/rest/handlers/search.go | 2 +- messaging/rest/message.go | 6 +++--- messaging/rest/permissions.go | 6 +++--- messaging/rest/router.go | 2 +- messaging/rest/search.go | 6 +++--- messaging/routes.go | 4 ++-- messaging/service/attachment.go | 4 ++-- messaging/service/attachment_mock_test.go | 2 +- messaging/service/channel.go | 4 ++-- messaging/service/channel_mock_test.go | 2 +- messaging/service/channel_test.go | 2 +- messaging/service/events.go | 4 ++-- messaging/service/message.go | 4 ++-- messaging/service/message_mock_test.go | 2 +- messaging/service/message_test.go | 2 +- messaging/service/permissions.go | 2 +- messaging/service/pubsub.go | 2 +- messaging/start.go | 4 ++-- messaging/types/channel.perms.gen.go | 2 +- messaging/types/organisation.perms.gen.go | 2 +- messaging/types/team.perms.gen.go | 2 +- messaging/websocket/event_queue.go | 4 ++-- messaging/websocket/router.go | 2 +- messaging/websocket/session.go | 6 +++--- messaging/websocket/session_incoming_channel.go | 2 +- messaging/websocket/session_incoming_command.go | 2 +- messaging/websocket/session_incoming_message.go | 2 +- messaging/websocket/session_outgoing.go | 4 ++-- messaging/websocket/websocket.go | 2 +- 55 files changed, 76 insertions(+), 76 deletions(-) diff --git a/cmd/messaging/main.go b/cmd/messaging/main.go index c65b8a1fb..abd463e76 100644 --- a/cmd/messaging/main.go +++ b/cmd/messaging/main.go @@ -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" diff --git a/cmd/system-cli/users.go b/cmd/system-cli/users.go index c59a16bb9..91625eedc 100644 --- a/cmd/system-cli/users.go +++ b/cmd/system-cli/users.go @@ -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" ) diff --git a/internal/payload/outgoing.go b/internal/payload/outgoing.go index a84312cd5..6bd15fce9 100644 --- a/internal/payload/outgoing.go +++ b/internal/payload/outgoing.go @@ -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" + samTypes "github.com/crusttech/crust/messaging/types" systemTypes "github.com/crusttech/crust/system/types" ) diff --git a/messaging/db/migrate.go b/messaging/db/migrate.go index d4a33d303..b9bb0f373 100644 --- a/messaging/db/migrate.go +++ b/messaging/db/migrate.go @@ -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) { diff --git a/messaging/flags.go b/messaging/flags.go index 6d213de5d..6c857207f 100644 --- a/messaging/flags.go +++ b/messaging/flags.go @@ -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 ( diff --git a/messaging/repository/attachment.go b/messaging/repository/attachment.go index c312229f2..1bd089cbd 100644 --- a/messaging/repository/attachment.go +++ b/messaging/repository/attachment.go @@ -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 ( diff --git a/messaging/repository/attachment_test.go b/messaging/repository/attachment_test.go index 5c5790414..1203a9652 100644 --- a/messaging/repository/attachment_test.go +++ b/messaging/repository/attachment_test.go @@ -7,7 +7,7 @@ import ( "testing" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) func TestAttachment(t *testing.T) { diff --git a/messaging/repository/channel.go b/messaging/repository/channel.go index cdc1fe58f..48daa4aac 100644 --- a/messaging/repository/channel.go +++ b/messaging/repository/channel.go @@ -8,7 +8,7 @@ import ( "github.com/titpetric/factory" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) type ( diff --git a/messaging/repository/channel_member.go b/messaging/repository/channel_member.go index cb97935b1..6eeb1a2ce 100644 --- a/messaging/repository/channel_member.go +++ b/messaging/repository/channel_member.go @@ -6,7 +6,7 @@ import ( "github.com/titpetric/factory" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) type ( diff --git a/messaging/repository/channel_test.go b/messaging/repository/channel_test.go index ff1b6ed9b..c84a11d12 100644 --- a/messaging/repository/channel_test.go +++ b/messaging/repository/channel_test.go @@ -7,7 +7,7 @@ import ( "testing" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) func TestChannel(t *testing.T) { diff --git a/messaging/repository/events.go b/messaging/repository/events.go index ad944e4cb..bd91ef398 100644 --- a/messaging/repository/events.go +++ b/messaging/repository/events.go @@ -5,7 +5,7 @@ import ( "github.com/titpetric/factory" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) /* diff --git a/messaging/repository/events_test.go b/messaging/repository/events_test.go index d162cff2f..d1bb53510 100644 --- a/messaging/repository/events_test.go +++ b/messaging/repository/events_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) func TestEvents(t *testing.T) { diff --git a/messaging/repository/main_test.go b/messaging/repository/main_test.go index c803c8b58..ed417b9f7 100644 --- a/messaging/repository/main_test.go +++ b/messaging/repository/main_test.go @@ -11,7 +11,7 @@ import ( "github.com/namsral/flag" "github.com/titpetric/factory" - samMigrate "github.com/crusttech/crust/sam/db" + samMigrate "github.com/crusttech/crust/messaging/db" systemMigrate "github.com/crusttech/crust/system/db" ) diff --git a/messaging/repository/mention.go b/messaging/repository/mention.go index 30fcd534b..d84e24f8e 100644 --- a/messaging/repository/mention.go +++ b/messaging/repository/mention.go @@ -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 ( diff --git a/messaging/repository/message.go b/messaging/repository/message.go index 6914811fa..2288d211f 100644 --- a/messaging/repository/message.go +++ b/messaging/repository/message.go @@ -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 ( diff --git a/messaging/repository/message_flag.go b/messaging/repository/message_flag.go index 3552a2bd3..2fbd8acb2 100644 --- a/messaging/repository/message_flag.go +++ b/messaging/repository/message_flag.go @@ -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 ( diff --git a/messaging/repository/message_flag_test.go b/messaging/repository/message_flag_test.go index 2dd1a621a..d5a17508f 100644 --- a/messaging/repository/message_flag_test.go +++ b/messaging/repository/message_flag_test.go @@ -7,7 +7,7 @@ import ( "testing" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) func TestReaction(t *testing.T) { diff --git a/messaging/repository/message_test.go b/messaging/repository/message_test.go index 5cdae5a44..4f199ba09 100644 --- a/messaging/repository/message_test.go +++ b/messaging/repository/message_test.go @@ -7,7 +7,7 @@ import ( "testing" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) func TestMessage(t *testing.T) { diff --git a/messaging/repository/unread.go b/messaging/repository/unread.go index 714119dbb..59f4b4707 100644 --- a/messaging/repository/unread.go +++ b/messaging/repository/unread.go @@ -5,7 +5,7 @@ import ( "github.com/titpetric/factory" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) type ( diff --git a/messaging/rest/attachment.go b/messaging/rest/attachment.go index f05a52730..ae6db7918 100644 --- a/messaging/rest/attachment.go +++ b/messaging/rest/attachment.go @@ -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" diff --git a/messaging/rest/channel.go b/messaging/rest/channel.go index 3f0ea5bc3..426ddb893 100644 --- a/messaging/rest/channel.go +++ b/messaging/rest/channel.go @@ -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" ) diff --git a/messaging/rest/handlers/attachment.go b/messaging/rest/handlers/attachment.go index c4d3296b6..aee0618eb 100644 --- a/messaging/rest/handlers/attachment.go +++ b/messaging/rest/handlers/attachment.go @@ -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 diff --git a/messaging/rest/handlers/attachment_custom.go b/messaging/rest/handlers/attachment_custom.go index 6d176c810..0c967d344 100644 --- a/messaging/rest/handlers/attachment_custom.go +++ b/messaging/rest/handlers/attachment_custom.go @@ -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 diff --git a/messaging/rest/handlers/channel.go b/messaging/rest/handlers/channel.go index 3364cf30d..7a0bf9903 100644 --- a/messaging/rest/handlers/channel.go +++ b/messaging/rest/handlers/channel.go @@ -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 diff --git a/messaging/rest/handlers/message.go b/messaging/rest/handlers/message.go index 7292a0d20..ca061deb4 100644 --- a/messaging/rest/handlers/message.go +++ b/messaging/rest/handlers/message.go @@ -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 diff --git a/messaging/rest/handlers/permissions.go b/messaging/rest/handlers/permissions.go index f714bb8fd..c5ee128b5 100644 --- a/messaging/rest/handlers/permissions.go +++ b/messaging/rest/handlers/permissions.go @@ -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 diff --git a/messaging/rest/handlers/search.go b/messaging/rest/handlers/search.go index 19347018f..c32d46055 100644 --- a/messaging/rest/handlers/search.go +++ b/messaging/rest/handlers/search.go @@ -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 diff --git a/messaging/rest/message.go b/messaging/rest/message.go index 99b17939f..24da6f5fe 100644 --- a/messaging/rest/message.go +++ b/messaging/rest/message.go @@ -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 diff --git a/messaging/rest/permissions.go b/messaging/rest/permissions.go index ad2b007b4..160f95376 100644 --- a/messaging/rest/permissions.go +++ b/messaging/rest/permissions.go @@ -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 { diff --git a/messaging/rest/router.go b/messaging/rest/router.go index effed7bd1..10953ef28 100644 --- a/messaging/rest/router.go +++ b/messaging/rest/router.go @@ -4,7 +4,7 @@ import ( "github.com/go-chi/chi" "github.com/crusttech/crust/internal/auth" - "github.com/crusttech/crust/sam/rest/handlers" + "github.com/crusttech/crust/messaging/rest/handlers" ) func MountRoutes() func(chi.Router) { diff --git a/messaging/rest/search.go b/messaging/rest/search.go index 84d5fa9f9..6866c8fb7 100644 --- a/messaging/rest/search.go +++ b/messaging/rest/search.go @@ -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" ) diff --git a/messaging/routes.go b/messaging/routes.go index 282a19c45..42b8286fa 100644 --- a/messaging/routes.go +++ b/messaging/routes.go @@ -16,8 +16,8 @@ import ( "github.com/crusttech/crust/internal/config" "github.com/crusttech/crust/internal/metrics" "github.com/crusttech/crust/internal/version" - "github.com/crusttech/crust/sam/rest" - "github.com/crusttech/crust/sam/websocket" + "github.com/crusttech/crust/messaging/rest" + "github.com/crusttech/crust/messaging/websocket" ) func Routes(ctx context.Context) *chi.Mux { diff --git a/messaging/service/attachment.go b/messaging/service/attachment.go index 40543bf12..3c5175599 100644 --- a/messaging/service/attachment.go +++ b/messaging/service/attachment.go @@ -17,8 +17,8 @@ import ( "github.com/titpetric/factory" "github.com/crusttech/crust/internal/store" - "github.com/crusttech/crust/sam/repository" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/repository" + "github.com/crusttech/crust/messaging/types" systemService "github.com/crusttech/crust/system/service" ) diff --git a/messaging/service/attachment_mock_test.go b/messaging/service/attachment_mock_test.go index 65e6e8492..1c3c28015 100644 --- a/messaging/service/attachment_mock_test.go +++ b/messaging/service/attachment_mock_test.go @@ -6,7 +6,7 @@ package service import ( context "context" - types "github.com/crusttech/crust/sam/types" + types "github.com/crusttech/crust/messaging/types" gomock "github.com/golang/mock/gomock" io "io" reflect "reflect" diff --git a/messaging/service/channel.go b/messaging/service/channel.go index 09ea93674..2720ff2f8 100644 --- a/messaging/service/channel.go +++ b/messaging/service/channel.go @@ -8,8 +8,8 @@ import ( "github.com/pkg/errors" "github.com/crusttech/crust/internal/auth" - "github.com/crusttech/crust/sam/repository" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/repository" + "github.com/crusttech/crust/messaging/types" systemService "github.com/crusttech/crust/system/service" ) diff --git a/messaging/service/channel_mock_test.go b/messaging/service/channel_mock_test.go index 8433f8654..6370cf5f8 100644 --- a/messaging/service/channel_mock_test.go +++ b/messaging/service/channel_mock_test.go @@ -6,7 +6,7 @@ package service import ( context "context" - types "github.com/crusttech/crust/sam/types" + types "github.com/crusttech/crust/messaging/types" gomock "github.com/golang/mock/gomock" reflect "reflect" ) diff --git a/messaging/service/channel_test.go b/messaging/service/channel_test.go index 11f7ac213..e0747f077 100644 --- a/messaging/service/channel_test.go +++ b/messaging/service/channel_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/crusttech/crust/internal/auth" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" systemTypes "github.com/crusttech/crust/system/types" ) diff --git a/messaging/service/events.go b/messaging/service/events.go index c0395c7bb..3687cdc47 100644 --- a/messaging/service/events.go +++ b/messaging/service/events.go @@ -5,8 +5,8 @@ import ( "github.com/crusttech/crust/internal/payload" "github.com/crusttech/crust/internal/payload/outgoing" - "github.com/crusttech/crust/sam/repository" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/repository" + "github.com/crusttech/crust/messaging/types" ) type ( diff --git a/messaging/service/message.go b/messaging/service/message.go index 4bb9c8ab5..f1ee3c3f0 100644 --- a/messaging/service/message.go +++ b/messaging/service/message.go @@ -8,8 +8,8 @@ import ( "github.com/pkg/errors" "github.com/crusttech/crust/internal/payload" - "github.com/crusttech/crust/sam/repository" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/repository" + "github.com/crusttech/crust/messaging/types" systemService "github.com/crusttech/crust/system/service" systemTypes "github.com/crusttech/crust/system/types" ) diff --git a/messaging/service/message_mock_test.go b/messaging/service/message_mock_test.go index 8a5d09a07..96dbdc446 100644 --- a/messaging/service/message_mock_test.go +++ b/messaging/service/message_mock_test.go @@ -6,7 +6,7 @@ package service import ( context "context" - types "github.com/crusttech/crust/sam/types" + types "github.com/crusttech/crust/messaging/types" gomock "github.com/golang/mock/gomock" reflect "reflect" ) diff --git a/messaging/service/message_test.go b/messaging/service/message_test.go index 7b3e48321..40996110c 100644 --- a/messaging/service/message_test.go +++ b/messaging/service/message_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/crusttech/crust/internal/auth" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" systemTypes "github.com/crusttech/crust/system/types" ) diff --git a/messaging/service/permissions.go b/messaging/service/permissions.go index e80c2a903..580e987e7 100644 --- a/messaging/service/permissions.go +++ b/messaging/service/permissions.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" "github.com/crusttech/crust/internal/rules" - "github.com/crusttech/crust/sam/repository" + "github.com/crusttech/crust/messaging/repository" ) type ( diff --git a/messaging/service/pubsub.go b/messaging/service/pubsub.go index 59c21438e..02d1f20e2 100644 --- a/messaging/service/pubsub.go +++ b/messaging/service/pubsub.go @@ -1,7 +1,7 @@ package service import ( - "github.com/crusttech/crust/sam/repository" + "github.com/crusttech/crust/messaging/repository" ) type pubSub struct { diff --git a/messaging/start.go b/messaging/start.go index 249bf486e..61c3bbb1b 100644 --- a/messaging/start.go +++ b/messaging/start.go @@ -13,14 +13,14 @@ import ( "github.com/titpetric/factory/resputil" "github.com/crusttech/crust/internal/db" - migrate "github.com/crusttech/crust/sam/db" + migrate "github.com/crusttech/crust/messaging/db" systemService "github.com/crusttech/crust/system/service" "github.com/crusttech/crust/internal/auth" "github.com/crusttech/crust/internal/mail" "github.com/crusttech/crust/internal/metrics" "github.com/crusttech/crust/internal/version" - "github.com/crusttech/crust/sam/service" + "github.com/crusttech/crust/messaging/service" ) var ( diff --git a/messaging/types/channel.perms.gen.go b/messaging/types/channel.perms.gen.go index 2fa2fb50a..ae4fd870a 100644 --- a/messaging/types/channel.perms.gen.go +++ b/messaging/types/channel.perms.gen.go @@ -2,7 +2,7 @@ package types import "github.com/crusttech/crust/internal/rules" -/* File is generated from sam/types/permissions/3-channel.json with permissions.go */ +/* File is generated from messaging/types/permissions/3-channel.json with permissions.go */ func (c *Channel) Permissions() []rules.OperationGroup { return []rules.OperationGroup{ diff --git a/messaging/types/organisation.perms.gen.go b/messaging/types/organisation.perms.gen.go index 67c9d7591..1e9139dff 100644 --- a/messaging/types/organisation.perms.gen.go +++ b/messaging/types/organisation.perms.gen.go @@ -2,7 +2,7 @@ package types import "github.com/crusttech/crust/internal/rules" -/* File is generated from sam/types/permissions/1-organisation.json with permissions.go */ +/* File is generated from messaging/types/permissions/1-organisation.json with permissions.go */ func (c *Organisation) Permissions() []rules.OperationGroup { return []rules.OperationGroup{ diff --git a/messaging/types/team.perms.gen.go b/messaging/types/team.perms.gen.go index ca6a0efa9..3cca62b97 100644 --- a/messaging/types/team.perms.gen.go +++ b/messaging/types/team.perms.gen.go @@ -2,7 +2,7 @@ package types import "github.com/crusttech/crust/internal/rules" -/* File is generated from sam/types/permissions/2-team.json with permissions.go */ +/* File is generated from messaging/types/permissions/2-team.json with permissions.go */ func (c *Team) Permissions() []rules.OperationGroup { return []rules.OperationGroup{ diff --git a/messaging/websocket/event_queue.go b/messaging/websocket/event_queue.go index 6a62d6ae8..ce87a76f2 100644 --- a/messaging/websocket/event_queue.go +++ b/messaging/websocket/event_queue.go @@ -8,8 +8,8 @@ import ( "github.com/crusttech/crust/internal/payload" "github.com/crusttech/crust/internal/payload/outgoing" - "github.com/crusttech/crust/sam/repository" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/repository" + "github.com/crusttech/crust/messaging/types" ) type ( diff --git a/messaging/websocket/router.go b/messaging/websocket/router.go index 938838167..9645e2c99 100644 --- a/messaging/websocket/router.go +++ b/messaging/websocket/router.go @@ -6,7 +6,7 @@ import ( "github.com/go-chi/chi" - "github.com/crusttech/crust/sam/repository" + "github.com/crusttech/crust/messaging/repository" ) func MountRoutes(ctx context.Context, config *repository.Flags) func(chi.Router) { diff --git a/messaging/websocket/session.go b/messaging/websocket/session.go index 3cadc8d03..32cbd18a7 100644 --- a/messaging/websocket/session.go +++ b/messaging/websocket/session.go @@ -12,9 +12,9 @@ import ( "github.com/crusttech/crust/internal/auth" "github.com/crusttech/crust/internal/payload" "github.com/crusttech/crust/internal/payload/outgoing" - "github.com/crusttech/crust/sam/repository" - samService "github.com/crusttech/crust/sam/service" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/repository" + samService "github.com/crusttech/crust/messaging/service" + "github.com/crusttech/crust/messaging/types" systemService "github.com/crusttech/crust/system/service" systemTypes "github.com/crusttech/crust/system/types" ) diff --git a/messaging/websocket/session_incoming_channel.go b/messaging/websocket/session_incoming_channel.go index 5400ef370..cf877bc84 100644 --- a/messaging/websocket/session_incoming_channel.go +++ b/messaging/websocket/session_incoming_channel.go @@ -7,7 +7,7 @@ import ( "github.com/crusttech/crust/internal/payload" "github.com/crusttech/crust/internal/payload/incoming" "github.com/crusttech/crust/internal/payload/outgoing" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) func (s *Session) channelJoin(ctx context.Context, p *incoming.ChannelJoin) error { diff --git a/messaging/websocket/session_incoming_command.go b/messaging/websocket/session_incoming_command.go index 24b487af0..6cf9388df 100644 --- a/messaging/websocket/session_incoming_command.go +++ b/messaging/websocket/session_incoming_command.go @@ -10,7 +10,7 @@ import ( "github.com/crusttech/crust/internal/payload" "github.com/crusttech/crust/internal/payload/incoming" "github.com/crusttech/crust/internal/payload/outgoing" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) func (s *Session) execCommand(ctx context.Context, c *incoming.ExecCommand) error { diff --git a/messaging/websocket/session_incoming_message.go b/messaging/websocket/session_incoming_message.go index d9f5ffe7d..23fbbb9d9 100644 --- a/messaging/websocket/session_incoming_message.go +++ b/messaging/websocket/session_incoming_message.go @@ -5,7 +5,7 @@ import ( "github.com/crusttech/crust/internal/payload" "github.com/crusttech/crust/internal/payload/incoming" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/types" ) func (s *Session) messageCreate(ctx context.Context, p *incoming.MessageCreate) error { diff --git a/messaging/websocket/session_outgoing.go b/messaging/websocket/session_outgoing.go index 566ab5a17..196494000 100644 --- a/messaging/websocket/session_outgoing.go +++ b/messaging/websocket/session_outgoing.go @@ -4,8 +4,8 @@ import ( "log" "time" - "github.com/crusttech/crust/sam/repository" - "github.com/crusttech/crust/sam/types" + "github.com/crusttech/crust/messaging/repository" + "github.com/crusttech/crust/messaging/types" ) // Sends message to subscribers diff --git a/messaging/websocket/websocket.go b/messaging/websocket/websocket.go index 6ac725dbe..3b721aebb 100644 --- a/messaging/websocket/websocket.go +++ b/messaging/websocket/websocket.go @@ -9,7 +9,7 @@ import ( "github.com/titpetric/factory/resputil" "github.com/crusttech/crust/internal/auth" - "github.com/crusttech/crust/sam/repository" + "github.com/crusttech/crust/messaging/repository" systemService "github.com/crusttech/crust/system/service" ) From 3ff2e035efa4dcdaa73c1eb9c5d01e2f722281bf Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:25:16 +0100 Subject: [PATCH 06/15] upd(all): update cmd, add internal/mail to all --- cmd/crm/main.go | 19 +++++++++++++++---- cmd/messaging/main.go | 20 ++++++++++++++++---- cmd/system/main.go | 10 +++++----- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/cmd/crm/main.go b/cmd/crm/main.go index c7c18241a..d32f26eac 100644 --- a/cmd/crm/main.go +++ b/cmd/crm/main.go @@ -5,9 +5,9 @@ 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/mail" "github.com/crusttech/crust/internal/rbac" ) @@ -19,9 +19,20 @@ func main() { 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) + } } } diff --git a/cmd/messaging/main.go b/cmd/messaging/main.go index abd463e76..7b794ca4c 100644 --- a/cmd/messaging/main.go +++ b/cmd/messaging/main.go @@ -7,20 +7,32 @@ import ( service "github.com/crusttech/crust/messaging" "github.com/crusttech/crust/internal/auth" + "github.com/crusttech/crust/internal/mail" "github.com/crusttech/crust/internal/rbac" ) func main() { - flags("messaging", service.Flags, auth.Flags, rbac.Flags) + flags("messaging", service.Flags, auth.Flags, rbac.Flags, mail.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 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) + } } } diff --git a/cmd/system/main.go b/cmd/system/main.go index d9edf7cd8..b5bbcdd65 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -4,21 +4,22 @@ 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/mail" "github.com/crusttech/crust/internal/rbac" ) func main() { - flags("system", service.Flags, auth.Flags, rbac.Flags) + flags("system", service.Flags, auth.Flags, rbac.Flags, mail.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 system: %+v", err) + log.Fatalf("Error initializing: %+v", err) } var command string @@ -31,8 +32,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) } } - } From b8267f4a64fdeb3fee3ee633dd8ce19c84b0cb15 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:29:33 +0100 Subject: [PATCH 07/15] fix(crm): fix test prefix, s/sam/messaging --- crm/repository/module.go | 2 +- crm/repository/record.go | 2 +- crm/service/main_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crm/repository/module.go b/crm/repository/module.go index de7807e0d..007832f09 100644 --- a/crm/repository/module.go +++ b/crm/repository/module.go @@ -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{} diff --git a/crm/repository/record.go b/crm/repository/record.go index 86e089218..4723b8314 100644 --- a/crm/repository/record.go +++ b/crm/repository/record.go @@ -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{} diff --git a/crm/service/main_test.go b/crm/service/main_test.go index 577fa2abd..db3ec59f4 100644 --- a/crm/service/main_test.go +++ b/crm/service/main_test.go @@ -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 { From 94c6f4c94e845555d24ffd69dc50fda4f2667f71 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:29:55 +0100 Subject: [PATCH 08/15] upd(internal): s/sam/messaging for payload/outgoing --- internal/payload/outgoing.go | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/payload/outgoing.go b/internal/payload/outgoing.go index 6bd15fce9..ada08ba93 100644 --- a/internal/payload/outgoing.go +++ b/internal/payload/outgoing.go @@ -7,7 +7,7 @@ import ( "github.com/crusttech/crust/internal/auth" "github.com/crusttech/crust/internal/payload/outgoing" - samTypes "github.com/crusttech/crust/messaging/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) From 440d3514eddfff0c634c0f4e49bda9aca2e09f3b Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:41:04 +0100 Subject: [PATCH 09/15] upd(messaging): serviceError update --- system/service/error.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/service/error.go b/system/service/error.go index f2180634b..bae0374e6 100644 --- a/system/service/error.go +++ b/system/service/error.go @@ -5,5 +5,5 @@ type ( ) func (e serviceError) Error() string { - return "crust.sam.service." + string(e) + return "crust.messaging.service." + string(e) } From f10c3cfbe774910d4314a40e734edc6977fde78f Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:51:15 +0100 Subject: [PATCH 10/15] upd(all): s/sam/messaging, del: build-proto.sh --- build-proto.sh | 1 - cmd/crm/main.go | 3 +-- cmd/messaging/main.go | 3 +-- cmd/system/main.go | 3 +-- internal/mail/flags.go | 11 ----------- messaging/flags.go | 4 ++-- messaging/repository/error.go | 2 +- messaging/repository/main_test.go | 6 +++--- messaging/rest/handlers/attachment_custom.go | 3 ++- messaging/routes.go | 2 +- messaging/service/error.go | 2 +- messaging/websocket/session.go | 10 +++++----- system/flags.go | 4 ++-- 13 files changed, 20 insertions(+), 34 deletions(-) delete mode 100755 build-proto.sh delete mode 100644 internal/mail/flags.go diff --git a/build-proto.sh b/build-proto.sh deleted file mode 100755 index 122db4471..000000000 --- a/build-proto.sh +++ /dev/null @@ -1 +0,0 @@ -protoc --go_out=plugins=grpc:. -I. sam/chat/*.proto diff --git a/cmd/crm/main.go b/cmd/crm/main.go index d32f26eac..a377938c3 100644 --- a/cmd/crm/main.go +++ b/cmd/crm/main.go @@ -7,12 +7,11 @@ import ( service "github.com/crusttech/crust/crm" "github.com/crusttech/crust/internal/auth" - "github.com/crusttech/crust/internal/mail" "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) diff --git a/cmd/messaging/main.go b/cmd/messaging/main.go index 7b794ca4c..f0c876957 100644 --- a/cmd/messaging/main.go +++ b/cmd/messaging/main.go @@ -7,12 +7,11 @@ import ( service "github.com/crusttech/crust/messaging" "github.com/crusttech/crust/internal/auth" - "github.com/crusttech/crust/internal/mail" "github.com/crusttech/crust/internal/rbac" ) func main() { - flags("messaging", service.Flags, auth.Flags, rbac.Flags, mail.Flags) + flags("messaging", service.Flags, auth.Flags, rbac.Flags) // log to stdout not stderr log.SetOutput(os.Stdout) diff --git a/cmd/system/main.go b/cmd/system/main.go index b5bbcdd65..6f4d430a6 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -7,12 +7,11 @@ import ( service "github.com/crusttech/crust/system" "github.com/crusttech/crust/internal/auth" - "github.com/crusttech/crust/internal/mail" "github.com/crusttech/crust/internal/rbac" ) func main() { - flags("system", service.Flags, auth.Flags, rbac.Flags, mail.Flags) + flags("system", service.Flags, auth.Flags, rbac.Flags) // log to stdout not stderr log.SetOutput(os.Stdout) diff --git a/internal/mail/flags.go b/internal/mail/flags.go deleted file mode 100644 index 88e3b6581..000000000 --- a/internal/mail/flags.go +++ /dev/null @@ -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...) -} diff --git a/messaging/flags.go b/messaging/flags.go index 6c857207f..99c6a5c31 100644 --- a/messaging/flags.go +++ b/messaging/flags.go @@ -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{ diff --git a/messaging/repository/error.go b/messaging/repository/error.go index e64314122..86aaf5099 100644 --- a/messaging/repository/error.go +++ b/messaging/repository/error.go @@ -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 { diff --git a/messaging/repository/main_test.go b/messaging/repository/main_test.go index ed417b9f7..aa7fed35e 100644 --- a/messaging/repository/main_test.go +++ b/messaging/repository/main_test.go @@ -11,7 +11,7 @@ import ( "github.com/namsral/flag" "github.com/titpetric/factory" - samMigrate "github.com/crusttech/crust/messaging/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 } diff --git a/messaging/rest/handlers/attachment_custom.go b/messaging/rest/handlers/attachment_custom.go index 0c967d344..1b43af780 100644 --- a/messaging/rest/handlers/attachment_custom.go +++ b/messaging/rest/handlers/attachment_custom.go @@ -27,7 +27,8 @@ 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": + // @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) diff --git a/messaging/routes.go b/messaging/routes.go index 42b8286fa..3982ed728 100644 --- a/messaging/routes.go +++ b/messaging/routes.go @@ -42,7 +42,7 @@ func mountRoutes(r chi.Router, opts *config.HTTP, mounts ...func(r chi.Router)) r.Use(middleware.Logger) } if opts.Metrics { - r.Use(metrics.Middleware("sam")) + r.Use(metrics.Middleware("messaging")) } for _, mount := range mounts { diff --git a/messaging/service/error.go b/messaging/service/error.go index f2180634b..bae0374e6 100644 --- a/messaging/service/error.go +++ b/messaging/service/error.go @@ -5,5 +5,5 @@ type ( ) func (e serviceError) Error() string { - return "crust.sam.service." + string(e) + return "crust.messaging.service." + string(e) } diff --git a/messaging/websocket/session.go b/messaging/websocket/session.go index 32cbd18a7..f610a5fc4 100644 --- a/messaging/websocket/session.go +++ b/messaging/websocket/session.go @@ -13,7 +13,7 @@ import ( "github.com/crusttech/crust/internal/payload" "github.com/crusttech/crust/internal/payload/outgoing" "github.com/crusttech/crust/messaging/repository" - samService "github.com/crusttech/crust/messaging/service" + messagingService "github.com/crusttech/crust/messaging/service" "github.com/crusttech/crust/messaging/types" systemService "github.com/crusttech/crust/system/service" systemTypes "github.com/crusttech/crust/system/types" @@ -40,8 +40,8 @@ type ( svc struct { user systemService.UserService - ch samService.ChannelService - msg samService.MessageService + ch messagingService.ChannelService + msg messagingService.MessageService } } ) @@ -57,8 +57,8 @@ func (Session) New(ctx context.Context, config *repository.Flags, conn *websocke } s.svc.user = systemService.DefaultUser - s.svc.ch = samService.DefaultChannel - s.svc.msg = samService.DefaultMessage + s.svc.ch = messagingService.DefaultChannel + s.svc.msg = messagingService.DefaultMessage return s } diff --git a/system/flags.go b/system/flags.go index 474fc2721..2281232c0 100644 --- a/system/flags.go +++ b/system/flags.go @@ -21,7 +21,7 @@ var flags *appFlags func (c *appFlags) Validate() error { if c == nil { - return errors.New("AUTH flags are not initialized, need to call Flags() or FullFlags()") + return errors.New("Flags are not initialized, need to call Flags() or FullFlags()") } if err := c.http.Validate(); err != nil { return err @@ -46,7 +46,7 @@ func Flags(prefix ...string) { return } if len(prefix) == 0 { - panic("auth.Flags() needs prefix on first call") + panic("Flags() needs prefix on first call") } flags = &appFlags{ new(config.SMTP).Init(prefix...), From 044eeecec03caf7fb065ef774b096726923b0528 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 15:51:40 +0100 Subject: [PATCH 11/15] upd(all): regenerate mocks --- messaging/service/attachment_mock_test.go | 2 +- messaging/service/channel_mock_test.go | 15 ++- messaging/service/message_mock_test.go | 14 +-- system/repository/mocks/credentials.go | 2 +- system/repository/mocks/user.go | 19 ++- system/service/organisation_mock_test.go | 135 ++++++++++++++++++++++ system/service/user_mock_test.go | 17 +++ 7 files changed, 193 insertions(+), 11 deletions(-) create mode 100644 system/service/organisation_mock_test.go diff --git a/messaging/service/attachment_mock_test.go b/messaging/service/attachment_mock_test.go index 1c3c28015..2035b4dd5 100644 --- a/messaging/service/attachment_mock_test.go +++ b/messaging/service/attachment_mock_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: sam/service/attachment.go +// Source: messaging/service/attachment.go // Package service is a generated GoMock package. package service diff --git a/messaging/service/channel_mock_test.go b/messaging/service/channel_mock_test.go index 6370cf5f8..283551fab 100644 --- a/messaging/service/channel_mock_test.go +++ b/messaging/service/channel_mock_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: sam/service/channel.go +// Source: messaging/service/channel.go // Package service is a generated GoMock package. package service @@ -164,6 +164,19 @@ func (mr *MockChannelServiceMockRecorder) DeleteMember(channelID interface{}, me return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMember", reflect.TypeOf((*MockChannelService)(nil).DeleteMember), varargs...) } +// SetFlag mocks base method +func (m *MockChannelService) SetFlag(ID uint64, flag types.ChannelMembershipFlag) (*types.Channel, error) { + ret := m.ctrl.Call(m, "SetFlag", ID, flag) + ret0, _ := ret[0].(*types.Channel) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetFlag indicates an expected call of SetFlag +func (mr *MockChannelServiceMockRecorder) SetFlag(ID, flag interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetFlag", reflect.TypeOf((*MockChannelService)(nil).SetFlag), ID, flag) +} + // Archive mocks base method func (m *MockChannelService) Archive(ID uint64) (*types.Channel, error) { ret := m.ctrl.Call(m, "Archive", ID) diff --git a/messaging/service/message_mock_test.go b/messaging/service/message_mock_test.go index 96dbdc446..68a541b06 100644 --- a/messaging/service/message_mock_test.go +++ b/messaging/service/message_mock_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: sam/service/message.go +// Source: messaging/service/message.go // Package service is a generated GoMock package. package service @@ -122,17 +122,17 @@ func (mr *MockMessageServiceMockRecorder) RemoveReaction(messageID, reaction int return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveReaction", reflect.TypeOf((*MockMessageService)(nil).RemoveReaction), messageID, reaction) } -// MarkAsUnread mocks base method -func (m *MockMessageService) MarkAsUnread(messageID uint64) (uint32, error) { - ret := m.ctrl.Call(m, "MarkAsUnread", messageID) +// MarkAsRead mocks base method +func (m *MockMessageService) MarkAsRead(channelID, threadID, lastReadMessageID uint64) (uint32, error) { + ret := m.ctrl.Call(m, "MarkAsRead", channelID, threadID, lastReadMessageID) ret0, _ := ret[0].(uint32) ret1, _ := ret[1].(error) return ret0, ret1 } -// MarkAsUnread indicates an expected call of MarkAsUnread -func (mr *MockMessageServiceMockRecorder) MarkAsUnread(messageID interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkAsUnread", reflect.TypeOf((*MockMessageService)(nil).MarkAsUnread), messageID) +// MarkAsRead indicates an expected call of MarkAsRead +func (mr *MockMessageServiceMockRecorder) MarkAsRead(channelID, threadID, lastReadMessageID interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkAsRead", reflect.TypeOf((*MockMessageService)(nil).MarkAsRead), channelID, threadID, lastReadMessageID) } // Pin mocks base method diff --git a/system/repository/mocks/credentials.go b/system/repository/mocks/credentials.go index d8ba3095a..fcdc9e16b 100644 --- a/system/repository/mocks/credentials.go +++ b/system/repository/mocks/credentials.go @@ -5,8 +5,8 @@ package repository import ( + repository "app/system/repository" context "context" - repository "github.com/crusttech/crust/system/repository" types "github.com/crusttech/crust/system/types" gomock "github.com/golang/mock/gomock" factory "github.com/titpetric/factory" diff --git a/system/repository/mocks/user.go b/system/repository/mocks/user.go index 14c4ff639..0df8d3900 100644 --- a/system/repository/mocks/user.go +++ b/system/repository/mocks/user.go @@ -5,8 +5,8 @@ package repository import ( + repository "app/system/repository" context "context" - repository "github.com/crusttech/crust/system/repository" types "github.com/crusttech/crust/system/types" gomock "github.com/golang/mock/gomock" factory "github.com/titpetric/factory" @@ -87,6 +87,23 @@ func (mr *MockUserRepositoryMockRecorder) FindByID(id interface{}) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByID", reflect.TypeOf((*MockUserRepository)(nil).FindByID), id) } +// FindByIDs mocks base method +func (m *MockUserRepository) FindByIDs(id ...uint64) (types.UserSet, error) { + varargs := []interface{}{} + for _, a := range id { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FindByIDs", varargs...) + ret0, _ := ret[0].(types.UserSet) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FindByIDs indicates an expected call of FindByIDs +func (mr *MockUserRepositoryMockRecorder) FindByIDs(id ...interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByIDs", reflect.TypeOf((*MockUserRepository)(nil).FindByIDs), id...) +} + // FindBySatosaID mocks base method func (m *MockUserRepository) FindBySatosaID(id string) (*types.User, error) { ret := m.ctrl.Call(m, "FindBySatosaID", id) diff --git a/system/service/organisation_mock_test.go b/system/service/organisation_mock_test.go new file mode 100644 index 000000000..30b9e233c --- /dev/null +++ b/system/service/organisation_mock_test.go @@ -0,0 +1,135 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: system/service/organisation.go + +// Package service is a generated GoMock package. +package service + +import ( + context "context" + types "github.com/crusttech/crust/system/types" + gomock "github.com/golang/mock/gomock" + reflect "reflect" +) + +// MockOrganisationService is a mock of OrganisationService interface +type MockOrganisationService struct { + ctrl *gomock.Controller + recorder *MockOrganisationServiceMockRecorder +} + +// MockOrganisationServiceMockRecorder is the mock recorder for MockOrganisationService +type MockOrganisationServiceMockRecorder struct { + mock *MockOrganisationService +} + +// NewMockOrganisationService creates a new mock instance +func NewMockOrganisationService(ctrl *gomock.Controller) *MockOrganisationService { + mock := &MockOrganisationService{ctrl: ctrl} + mock.recorder = &MockOrganisationServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockOrganisationService) EXPECT() *MockOrganisationServiceMockRecorder { + return m.recorder +} + +// With mocks base method +func (m *MockOrganisationService) With(ctx context.Context) OrganisationService { + ret := m.ctrl.Call(m, "With", ctx) + ret0, _ := ret[0].(OrganisationService) + return ret0 +} + +// With indicates an expected call of With +func (mr *MockOrganisationServiceMockRecorder) With(ctx interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "With", reflect.TypeOf((*MockOrganisationService)(nil).With), ctx) +} + +// FindByID mocks base method +func (m *MockOrganisationService) FindByID(organisationID uint64) (*types.Organisation, error) { + ret := m.ctrl.Call(m, "FindByID", organisationID) + ret0, _ := ret[0].(*types.Organisation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FindByID indicates an expected call of FindByID +func (mr *MockOrganisationServiceMockRecorder) FindByID(organisationID interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByID", reflect.TypeOf((*MockOrganisationService)(nil).FindByID), organisationID) +} + +// Find mocks base method +func (m *MockOrganisationService) Find(filter *types.OrganisationFilter) ([]*types.Organisation, error) { + ret := m.ctrl.Call(m, "Find", filter) + ret0, _ := ret[0].([]*types.Organisation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Find indicates an expected call of Find +func (mr *MockOrganisationServiceMockRecorder) Find(filter interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockOrganisationService)(nil).Find), filter) +} + +// Create mocks base method +func (m *MockOrganisationService) Create(organisation *types.Organisation) (*types.Organisation, error) { + ret := m.ctrl.Call(m, "Create", organisation) + ret0, _ := ret[0].(*types.Organisation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Create indicates an expected call of Create +func (mr *MockOrganisationServiceMockRecorder) Create(organisation interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockOrganisationService)(nil).Create), organisation) +} + +// Update mocks base method +func (m *MockOrganisationService) Update(organisation *types.Organisation) (*types.Organisation, error) { + ret := m.ctrl.Call(m, "Update", organisation) + ret0, _ := ret[0].(*types.Organisation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Update indicates an expected call of Update +func (mr *MockOrganisationServiceMockRecorder) Update(organisation interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockOrganisationService)(nil).Update), organisation) +} + +// Archive mocks base method +func (m *MockOrganisationService) Archive(ID uint64) error { + ret := m.ctrl.Call(m, "Archive", ID) + ret0, _ := ret[0].(error) + return ret0 +} + +// Archive indicates an expected call of Archive +func (mr *MockOrganisationServiceMockRecorder) Archive(ID interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Archive", reflect.TypeOf((*MockOrganisationService)(nil).Archive), ID) +} + +// Unarchive mocks base method +func (m *MockOrganisationService) Unarchive(ID uint64) error { + ret := m.ctrl.Call(m, "Unarchive", ID) + ret0, _ := ret[0].(error) + return ret0 +} + +// Unarchive indicates an expected call of Unarchive +func (mr *MockOrganisationServiceMockRecorder) Unarchive(ID interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unarchive", reflect.TypeOf((*MockOrganisationService)(nil).Unarchive), ID) +} + +// Delete mocks base method +func (m *MockOrganisationService) Delete(ID uint64) error { + ret := m.ctrl.Call(m, "Delete", ID) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete +func (mr *MockOrganisationServiceMockRecorder) Delete(ID interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockOrganisationService)(nil).Delete), ID) +} diff --git a/system/service/user_mock_test.go b/system/service/user_mock_test.go index 1d198cff7..3eec57784 100644 --- a/system/service/user_mock_test.go +++ b/system/service/user_mock_test.go @@ -85,6 +85,23 @@ func (mr *MockUserServiceMockRecorder) FindByID(id interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByID", reflect.TypeOf((*MockUserService)(nil).FindByID), id) } +// FindByIDs mocks base method +func (m *MockUserService) FindByIDs(id ...uint64) (types.UserSet, error) { + varargs := []interface{}{} + for _, a := range id { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FindByIDs", varargs...) + ret0, _ := ret[0].(types.UserSet) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FindByIDs indicates an expected call of FindByIDs +func (mr *MockUserServiceMockRecorder) FindByIDs(id ...interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByIDs", reflect.TypeOf((*MockUserService)(nil).FindByIDs), id...) +} + // Find mocks base method func (m *MockUserService) Find(filter *types.UserFilter) (types.UserSet, error) { ret := m.ctrl.Call(m, "Find", filter) From e56ede6035a3b79885bcb61fb5c630be0f42c746 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 16:13:15 +0100 Subject: [PATCH 12/15] fix(crm): prevent variable shadowing for new --- crm/service/record.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crm/service/record.go b/crm/service/record.go index 9edaaab6a..eb6dc16db 100644 --- a/crm/service/record.go +++ b/crm/service/record.go @@ -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 } From 952f590b2fca594e75bdab6e338cc2424290c919 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 16:13:38 +0100 Subject: [PATCH 13/15] upd(Makefile): remove unused dependencies --- Makefile | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 3279f529b..c625189db 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,6 @@ 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 @@ -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: @@ -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) From 86c19a743d5d468dd8b6161e0b7bcdb3b59d3ab6 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 16:14:02 +0100 Subject: [PATCH 14/15] upd(all): flags cleanup --- crm/flags.go | 18 ++++++++++++------ crm/repository/flags.go | 25 +++++++++++++++++++++++++ system/flags.go | 5 ++++- 3 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 crm/repository/flags.go diff --git a/crm/flags.go b/crm/flags.go index c6b14f2f0..706f8b4c8 100644 --- a/crm/flags.go +++ b/crm/flags.go @@ -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...), } } diff --git a/crm/repository/flags.go b/crm/repository/flags.go new file mode 100644 index 000000000..f170e784b --- /dev/null +++ b/crm/repository/flags.go @@ -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 +} diff --git a/system/flags.go b/system/flags.go index 2281232c0..57298982c 100644 --- a/system/flags.go +++ b/system/flags.go @@ -21,7 +21,7 @@ var flags *appFlags func (c *appFlags) Validate() error { if c == nil { - return errors.New("Flags are not initialized, need to call Flags() or FullFlags()") + return errors.New("Flags are not initialized, need to call Flags()") } if err := c.http.Validate(); err != nil { return err @@ -38,6 +38,9 @@ func (c *appFlags) Validate() error { if err := c.oidc.Validate(); err != nil { return err } + if err := c.social.Validate(); err != nil { + return err + } return nil } From 087196f571f9d16703e7a4c4f6b3a0b314050d43 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 5 Feb 2019 16:14:28 +0100 Subject: [PATCH 15/15] clean(all): gocritic warnings cleanup --- cmd/system-cli/main.go | 1 + crm/repository/record_report_builder.go | 1 + crm/start.go | 4 ++-- internal/config/social.go | 2 +- messaging/rest/handlers/attachment_custom.go | 2 +- messaging/service/events.go | 2 +- messaging/start.go | 4 ++-- system/repository/user.go | 1 + system/start.go | 4 ++-- 9 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/system-cli/main.go b/cmd/system-cli/main.go index 93f58d965..cec052b8b 100644 --- a/cmd/system-cli/main.go +++ b/cmd/system-cli/main.go @@ -44,5 +44,6 @@ func cliRouter(commands ...string) { switch commands[0] { case "users": cliExecUsers(commands[1:]...) + default: } } diff --git a/crm/repository/record_report_builder.go b/crm/repository/record_report_builder.go index 7ccf421b4..43e152490 100644 --- a/crm/repository/record_report_builder.go +++ b/crm/repository/record_report_builder.go @@ -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: } } diff --git a/crm/start.go b/crm/start.go index 78518dc57..2bfbae2bf 100644 --- a/crm/start.go +++ b/crm/start.go @@ -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 ) diff --git a/internal/config/social.go b/internal/config/social.go index ebe3a227d..bfc9be52d 100644 --- a/internal/config/social.go +++ b/internal/config/social.go @@ -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) diff --git a/messaging/rest/handlers/attachment_custom.go b/messaging/rest/handlers/attachment_custom.go index 1b43af780..61aec7ab5 100644 --- a/messaging/rest/handlers/attachment_custom.go +++ b/messaging/rest/handlers/attachment_custom.go @@ -26,7 +26,7 @@ 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 { + switch { // @todo: compare concrete exported error type? Go2 .As() like check? case err.Error() == "crust.messaging.repository.AttachmentNotFound": w.WriteHeader(http.StatusNotFound) diff --git a/messaging/service/events.go b/messaging/service/events.go index 3687cdc47..aa0c70cc1 100644 --- a/messaging/service/events.go +++ b/messaging/service/events.go @@ -47,7 +47,7 @@ func (svc *event) Message(m *types.Message) error { func (svc *event) MessageFlag(f *types.MessageFlag) error { var p outgoing.MessageEncoder - switch true { + switch { case f.IsBookmark(): // Leaving this here so it is obvious. return nil diff --git a/messaging/start.go b/messaging/start.go index 61c3bbb1b..9c8956939 100644 --- a/messaging/start.go +++ b/messaging/start.go @@ -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 ) diff --git a/system/repository/user.go b/system/repository/user.go index 933995da0..ec3a6da66 100644 --- a/system/repository/user.go +++ b/system/repository/user.go @@ -186,6 +186,7 @@ func (r *user) prepare(user *types.User, fields ...string) (err error) { } user.Teams = teams } + default: } } return diff --git a/system/start.go b/system/start.go index 72f5428dc..3ea6c8202 100644 --- a/system/start.go +++ b/system/start.go @@ -23,8 +23,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 )