@messenger-box/platform-server 10.0.3-alpha.2 → 10.0.3-alpha.201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/channels/ack-reactions.d.ts +46 -0
- package/lib/channels/ack-reactions.js +48 -0
- package/lib/channels/ack-reactions.js.map +1 -0
- package/lib/channels/allowlist-match.d.ts +38 -0
- package/lib/channels/allowlist-match.js +67 -0
- package/lib/channels/allowlist-match.js.map +1 -0
- package/lib/channels/channel-config.d.ts +46 -0
- package/lib/channels/channel-config.js +63 -0
- package/lib/channels/channel-config.js.map +1 -0
- package/lib/channels/command-gating.d.ts +47 -0
- package/lib/channels/command-gating.js +52 -0
- package/lib/channels/command-gating.js.map +1 -0
- package/lib/channels/conversation-label.d.ts +23 -0
- package/lib/channels/conversation-label.js +43 -0
- package/lib/channels/conversation-label.js.map +1 -0
- package/lib/channels/index.d.ts +18 -0
- package/lib/channels/mention-gating.d.ts +50 -0
- package/lib/channels/mention-gating.js +72 -0
- package/lib/channels/mention-gating.js.map +1 -0
- package/lib/channels/registry.d.ts +23 -0
- package/lib/channels/registry.js +282 -0
- package/lib/channels/registry.js.map +1 -0
- package/lib/channels/sender-identity.d.ts +11 -0
- package/lib/channels/sender-identity.js +48 -0
- package/lib/channels/sender-identity.js.map +1 -0
- package/lib/channels/session.d.ts +63 -0
- package/lib/channels/session.js +29 -0
- package/lib/channels/session.js.map +1 -0
- package/lib/channels/types.d.ts +147 -0
- package/lib/channels/types.js +28 -0
- package/lib/channels/types.js.map +1 -0
- package/lib/channels/typing.d.ts +62 -0
- package/lib/channels/typing.js +37 -0
- package/lib/channels/typing.js.map +1 -0
- package/lib/channels/typing.test.d.ts +1 -0
- package/lib/config/env-config.d.ts +7 -0
- package/lib/config/env-config.js +21 -1
- package/lib/config/env-config.js.map +1 -1
- package/lib/constants/default-channel-props.d.ts +11 -0
- package/lib/constants/default-channel-props.js +32 -0
- package/lib/constants/default-channel-props.js.map +1 -0
- package/lib/constants/default-notify-props.js.map +1 -1
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/query.constants.js.map +1 -1
- package/lib/containers/containers.js +13 -7
- package/lib/containers/containers.js.map +1 -1
- package/lib/containers/context-services-from-container.d.ts +2 -2
- package/lib/containers/context-services-from-container.js +7 -7
- package/lib/containers/context-services-from-container.js.map +1 -1
- package/lib/gateway/channel-registry.d.ts +10 -0
- package/lib/gateway/gateway-service.d.ts +23 -0
- package/lib/gateway/index.d.ts +4 -0
- package/lib/gateway/message-router.d.ts +20 -0
- package/lib/gateway/types.d.ts +270 -0
- package/lib/graphql/resolvers/channel-capabilities.d.ts +13 -0
- package/lib/graphql/resolvers/channel-capabilities.js +179 -0
- package/lib/graphql/resolvers/channel-capabilities.js.map +1 -0
- package/lib/graphql/resolvers/channel-member.d.ts +3 -3
- package/lib/graphql/resolvers/channel-member.js +30 -5
- package/lib/graphql/resolvers/channel-member.js.map +1 -1
- package/lib/graphql/resolvers/channel.d.ts +3 -3
- package/lib/graphql/resolvers/channel.js +348 -55
- package/lib/graphql/resolvers/channel.js.map +1 -1
- package/lib/graphql/resolvers/chat-configuration.d.ts +59 -0
- package/lib/graphql/resolvers/chat-configuration.js +89 -0
- package/lib/graphql/resolvers/chat-configuration.js.map +1 -0
- package/lib/graphql/resolvers/extended-token-account.d.ts +3 -32
- package/lib/graphql/resolvers/extended-token-account.js +90 -23
- package/lib/graphql/resolvers/extended-token-account.js.map +1 -1
- package/lib/graphql/resolvers/gateway.d.ts +18 -0
- package/lib/graphql/resolvers/index.d.ts +47 -26
- package/lib/graphql/resolvers/index.js +1 -1
- package/lib/graphql/resolvers/index.js.map +1 -1
- package/lib/graphql/resolvers/post-thread.d.ts +2 -3
- package/lib/graphql/resolvers/post-thread.js +294 -132
- package/lib/graphql/resolvers/post-thread.js.map +1 -1
- package/lib/graphql/resolvers/post.d.ts +2 -3
- package/lib/graphql/resolvers/post.js +764 -237
- package/lib/graphql/resolvers/post.js.map +1 -1
- package/lib/graphql/resolvers/reaction.d.ts +3 -3
- package/lib/graphql/resolvers/reaction.js +96 -14
- package/lib/graphql/resolvers/reaction.js.map +1 -1
- package/lib/graphql/resolvers/streaming.d.ts +20 -0
- package/lib/graphql/resolvers/streaming.js +147 -0
- package/lib/graphql/resolvers/streaming.js.map +1 -0
- package/lib/graphql/schema/channel-capabilities.graphql +492 -0
- package/lib/graphql/schema/channel-capabilities.graphql.js +1 -0
- package/lib/graphql/schema/channel-capabilities.graphql.js.map +1 -0
- package/lib/graphql/schema/channel-member.graphql +110 -21
- package/lib/graphql/schema/channel-member.graphql.js +1 -1
- package/lib/graphql/schema/channel.graphql +465 -24
- package/lib/graphql/schema/channel.graphql.js +1 -1
- package/lib/graphql/schema/chat-configuration.graphql +77 -0
- package/lib/graphql/schema/chat-configuration.graphql.js +1 -0
- package/lib/graphql/schema/chat-configuration.graphql.js.map +1 -0
- package/lib/graphql/schema/gateway.graphql +363 -0
- package/lib/graphql/schema/index.js +2 -2
- package/lib/graphql/schema/index.js.map +1 -1
- package/lib/graphql/schema/post-thread.graphql +167 -21
- package/lib/graphql/schema/post-thread.graphql.js +1 -1
- package/lib/graphql/schema/post.graphql +433 -36
- package/lib/graphql/schema/post.graphql.js +1 -1
- package/lib/graphql/schema/preferences.graphql +190 -3
- package/lib/graphql/schema/preferences.graphql.js +1 -1
- package/lib/graphql/schema/reaction.graphql +71 -13
- package/lib/graphql/schema/reaction.graphql.js +1 -1
- package/lib/graphql/schema/services.graphql +18 -0
- package/lib/graphql/schema/streaming.graphql +224 -0
- package/lib/graphql/schema/streaming.graphql.js +1 -0
- package/lib/graphql/schema/streaming.graphql.js.map +1 -0
- package/lib/graphql/schema/users.graphql +76 -13
- package/lib/graphql/schema/users.graphql.js +1 -1
- package/lib/graphql/schema/workflow-service.graphql +82 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces/index.d.ts +0 -2
- package/lib/interfaces/services.d.ts +1 -3
- package/lib/migrations/dbMigrations/AddChannelConfigurationsMigration.d.ts +42 -0
- package/lib/migrations/dbMigrations/AddChannelConfigurationsMigration.js +60 -0
- package/lib/migrations/dbMigrations/AddChannelConfigurationsMigration.js.map +1 -0
- package/lib/migrations/dbMigrations/AddChatConfigurationsMigration.d.ts +21 -0
- package/lib/migrations/dbMigrations/AddChatConfigurationsMigration.js +30 -0
- package/lib/migrations/dbMigrations/AddChatConfigurationsMigration.js.map +1 -0
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.d.ts +17 -0
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js +44 -0
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js.map +1 -0
- package/lib/migrations/dbMigrations/index.d.ts +3 -0
- package/lib/migrations/index.d.ts +1 -0
- package/lib/migrations/mail-template-migration.d.ts +3 -6
- package/lib/migrations/mail-template-migration.js +8 -21
- package/lib/migrations/mail-template-migration.js.map +1 -1
- package/lib/migrations/message-notification-template-migration.d.ts +4 -7
- package/lib/migrations/message-notification-template-migration.js +8 -25
- package/lib/migrations/message-notification-template-migration.js.map +1 -1
- package/lib/module.d.ts +1 -1
- package/lib/module.js +3 -10
- package/lib/module.js.map +1 -1
- package/lib/plugins/ChannelMoleculerService.d.ts +39 -0
- package/lib/plugins/ChannelMoleculerService.js +58 -0
- package/lib/plugins/ChannelMoleculerService.js.map +1 -0
- package/lib/plugins/ExtendedTokenAccountMoleculerService.d.ts +65 -0
- package/lib/plugins/ExtendedTokenAccountMoleculerService.js +88 -0
- package/lib/plugins/ExtendedTokenAccountMoleculerService.js.map +1 -0
- package/lib/plugins/MessengerNotificationMoleculerService.d.ts +52 -0
- package/lib/plugins/MessengerNotificationMoleculerService.js +84 -0
- package/lib/plugins/MessengerNotificationMoleculerService.js.map +1 -0
- package/lib/plugins/PostMoleculerService.d.ts +65 -0
- package/lib/plugins/PostMoleculerService.js +87 -0
- package/lib/plugins/PostMoleculerService.js.map +1 -0
- package/lib/plugins/PostThreadMoleculerService.d.ts +40 -0
- package/lib/plugins/PostThreadMoleculerService.js +59 -0
- package/lib/plugins/PostThreadMoleculerService.js.map +1 -0
- package/lib/plugins/ReactionMoleculerService.d.ts +37 -0
- package/lib/plugins/ReactionMoleculerService.js +56 -0
- package/lib/plugins/ReactionMoleculerService.js.map +1 -0
- package/lib/plugins/index.d.ts +18 -6
- package/lib/preferences/permissions/inbox-permission-contribution.js +58 -97
- package/lib/preferences/permissions/inbox-permission-contribution.js.map +1 -1
- package/lib/preferences/permissions/inbox-roles-permission-overwrite.js +144 -144
- package/lib/preferences/permissions/inbox-roles-permission-overwrite.js.map +1 -1
- package/lib/preferences/settings/channel-settings.d.ts +39 -0
- package/lib/preferences/settings/channel-settings.js +180 -0
- package/lib/preferences/settings/channel-settings.js.map +1 -0
- package/lib/preferences/settings/chat-settings.d.ts +248 -0
- package/lib/preferences/settings/chat-settings.js +1152 -0
- package/lib/preferences/settings/chat-settings.js.map +1 -0
- package/lib/preferences/settings/index.d.ts +3 -0
- package/lib/preferences/settings/messenger-channels-contribution.d.ts +39 -0
- package/lib/preferences/settings/messenger-channels-contribution.js +355 -0
- package/lib/preferences/settings/messenger-channels-contribution.js.map +1 -0
- package/lib/preferences/settings/post-settings.d.ts +16 -0
- package/lib/preferences/settings/post-settings.js +75 -3
- package/lib/preferences/settings/post-settings.js.map +1 -1
- package/lib/services/channel-service.d.ts +215 -34
- package/lib/services/channel-service.js +1058 -273
- package/lib/services/channel-service.js.map +1 -1
- package/lib/services/extended-token-account-service.d.ts +175 -20
- package/lib/services/extended-token-account-service.js +636 -56
- package/lib/services/extended-token-account-service.js.map +1 -1
- package/lib/services/messenger-notification-service.d.ts +177 -17
- package/lib/services/messenger-notification-service.js +975 -421
- package/lib/services/messenger-notification-service.js.map +1 -1
- package/lib/services/post-service.d.ts +245 -18
- package/lib/services/post-service.js +1027 -113
- package/lib/services/post-service.js.map +1 -1
- package/lib/services/post-thread-service.d.ts +153 -6
- package/lib/services/post-thread-service.js +475 -9
- package/lib/services/post-thread-service.js.map +1 -1
- package/lib/services/proxy-services/ChannelProxyService.d.ts +27 -0
- package/lib/services/proxy-services/ChannelProxyService.js +31 -0
- package/lib/services/proxy-services/ChannelProxyService.js.map +1 -0
- package/lib/services/proxy-services/ExtendedTokenAccountProxyService.d.ts +42 -0
- package/lib/services/proxy-services/ExtendedTokenAccountProxyService.js +46 -0
- package/lib/services/proxy-services/ExtendedTokenAccountProxyService.js.map +1 -0
- package/lib/services/proxy-services/MessengerNotificationProxyService.d.ts +44 -0
- package/lib/services/proxy-services/MessengerNotificationProxyService.js +54 -0
- package/lib/services/proxy-services/MessengerNotificationProxyService.js.map +1 -0
- package/lib/services/proxy-services/PostProxyService.d.ts +42 -0
- package/lib/services/proxy-services/PostProxyService.js +46 -0
- package/lib/services/proxy-services/PostProxyService.js.map +1 -0
- package/lib/services/proxy-services/PostThreadProxyService.d.ts +32 -0
- package/lib/services/proxy-services/PostThreadProxyService.js +36 -0
- package/lib/services/proxy-services/PostThreadProxyService.js.map +1 -0
- package/lib/services/proxy-services/ReactionProxyService.d.ts +41 -0
- package/lib/services/proxy-services/ReactionProxyService.js +45 -0
- package/lib/services/proxy-services/ReactionProxyService.js.map +1 -0
- package/lib/services/proxy-services/index.d.ts +17 -5
- package/lib/services/reaction-service.d.ts +124 -4
- package/lib/services/reaction-service.js +413 -3
- package/lib/services/reaction-service.js.map +1 -1
- package/lib/store/models/account-token-store.d.ts +1 -1
- package/lib/store/models/account-token-store.js.map +1 -1
- package/lib/store/models/channel.d.ts +2 -3
- package/lib/store/models/channel.js +216 -70
- package/lib/store/models/channel.js.map +1 -1
- package/lib/store/models/post-thread.d.ts +3 -3
- package/lib/store/models/post-thread.js +96 -14
- package/lib/store/models/post-thread.js.map +1 -1
- package/lib/store/models/post.d.ts +2 -3
- package/lib/store/models/post.js +143 -23
- package/lib/store/models/post.js.map +1 -1
- package/lib/store/models/reaction.d.ts +2 -3
- package/lib/store/models/reaction.js +67 -8
- package/lib/store/models/reaction.js.map +1 -1
- package/lib/store/repositories/__tests__/__fixtures__/team-repository.d.ts +3 -3
- package/lib/store/repositories/channel-repository.d.ts +6 -6
- package/lib/store/repositories/channel-repository.js +5 -2
- package/lib/store/repositories/channel-repository.js.map +1 -1
- package/lib/store/repositories/post-repository.d.ts +6 -6
- package/lib/store/repositories/post-repository.js +5 -2
- package/lib/store/repositories/post-repository.js.map +1 -1
- package/lib/store/repositories/post-thread-repository.d.ts +6 -6
- package/lib/store/repositories/post-thread-repository.js +5 -2
- package/lib/store/repositories/post-thread-repository.js.map +1 -1
- package/lib/store/repositories/reaction-repository.d.ts +6 -6
- package/lib/store/repositories/reaction-repository.js +5 -2
- package/lib/store/repositories/reaction-repository.js.map +1 -1
- package/lib/streaming/block-chunker.d.ts +40 -0
- package/lib/streaming/block-chunker.js +103 -0
- package/lib/streaming/block-chunker.js.map +1 -0
- package/lib/streaming/block-chunker.test.d.ts +1 -0
- package/lib/streaming/index.d.ts +4 -0
- package/lib/streaming/stream-service.d.ts +71 -0
- package/lib/streaming/stream-service.js +325 -0
- package/lib/streaming/stream-service.js.map +1 -0
- package/lib/streaming/stream-service.test.d.ts +16 -0
- package/lib/streaming/streaming-post.integration.test.d.ts +10 -0
- package/lib/streaming/types.d.ts +33 -0
- package/lib/streaming/types.js +37 -0
- package/lib/streaming/types.js.map +1 -0
- package/lib/templates/constants/CONTRIBUTION_POINTS.ts.template +78 -0
- package/lib/templates/constants/SERVER_TYPES.ts.template +1 -4
- package/lib/templates/constants/WorkflowNamespace.ts.template +10 -0
- package/lib/templates/repositories/ChannelRepository.ts.template +3 -3
- package/lib/templates/repositories/PostRepository.ts.template +3 -3
- package/lib/templates/repositories/PostThreadRepository.ts.template +3 -3
- package/lib/templates/repositories/ReactionRepository.ts.template +3 -4
- package/lib/templates/services/ChannelService.ts.template +290 -39
- package/lib/templates/services/ExtendedTokenAccountService.ts.template +107 -3
- package/lib/templates/services/MessengerNotificationService.ts.template +94 -19
- package/lib/templates/services/MessengerStreamService.ts.template +131 -0
- package/lib/templates/services/PostService.ts.template +228 -20
- package/lib/templates/services/PostThreadService.ts.template +151 -6
- package/lib/templates/services/ReactionService.ts.template +129 -3
- package/lib/templates/services/RedisCacheManager.ts.template +22 -0
- package/package.json +10 -6
- package/lib/interfaces/context.d.ts +0 -14
- package/lib/plugins/channel-moleculer-service.d.ts +0 -8
- package/lib/plugins/channel-moleculer-service.js +0 -129
- package/lib/plugins/channel-moleculer-service.js.map +0 -1
- package/lib/plugins/extended-token-account-moleculer-service.d.ts +0 -8
- package/lib/plugins/extended-token-account-moleculer-service.js +0 -47
- package/lib/plugins/extended-token-account-moleculer-service.js.map +0 -1
- package/lib/plugins/messenger-notification-moleculer-service.d.ts +0 -9
- package/lib/plugins/messenger-notification-moleculer-service.js +0 -116
- package/lib/plugins/messenger-notification-moleculer-service.js.map +0 -1
- package/lib/plugins/post-moleculer-service.d.ts +0 -35
- package/lib/plugins/post-moleculer-service.js +0 -393
- package/lib/plugins/post-moleculer-service.js.map +0 -1
- package/lib/plugins/post-thread-moleculer-service.d.ts +0 -8
- package/lib/plugins/post-thread-moleculer-service.js +0 -33
- package/lib/plugins/post-thread-moleculer-service.js.map +0 -1
- package/lib/plugins/reaction-moleculer-service.d.ts +0 -8
- package/lib/plugins/reaction-moleculer-service.js +0 -20
- package/lib/plugins/reaction-moleculer-service.js.map +0 -1
- package/lib/services/proxy-services/channel-microservice.d.ts +0 -44
- package/lib/services/proxy-services/channel-microservice.js +0 -199
- package/lib/services/proxy-services/channel-microservice.js.map +0 -1
- package/lib/services/proxy-services/messenger-notification-microservice.d.ts +0 -16
- package/lib/services/proxy-services/messenger-notification-microservice.js +0 -54
- package/lib/services/proxy-services/messenger-notification-microservice.js.map +0 -1
- package/lib/services/proxy-services/post-microservice.d.ts +0 -22
- package/lib/services/proxy-services/post-microservice.js +0 -64
- package/lib/services/proxy-services/post-microservice.js.map +0 -1
- package/lib/services/proxy-services/post-thread-microservice.d.ts +0 -10
- package/lib/services/proxy-services/post-thread-microservice.js +0 -15
- package/lib/services/proxy-services/post-thread-microservice.js.map +0 -1
- package/lib/services/proxy-services/reaction-microservice.d.ts +0 -9
- package/lib/services/proxy-services/reaction-microservice.js +0 -10
- package/lib/services/proxy-services/reaction-microservice.js.map +0 -1
- package/lib/store/models/common-options.js +0 -20
- package/lib/store/models/common-options.js.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {withFilter}from'graphql-subscriptions';import {RoomType,PostTypeEnum,SortEnum,ConfigCollectionName,Scheme,ClientCacheTypeNames}from'common/server';import {get}from'lodash-es';import {GraphQLError}from'graphql';import {generateResourceUri,DEFAULT_TENANT_ID,buildNodeContext}from'@adminide-stack/core/lib/index.js';// import { IContext } from '../../interfaces';
|
|
2
|
+
// export const postResolvers = ({ pubsub }): IResolvers<IContext> => ({
|
|
3
|
+
// export const postResolvers: (options: IResolverOptions) => IResolvers<IContext> = (options) => ({
|
|
2
4
|
const postResolvers = options => ({
|
|
3
5
|
// Temporary fix, until we have extension support in base module
|
|
4
6
|
FileInfo: {
|
|
@@ -7,125 +9,298 @@ const postResolvers = options => ({
|
|
|
7
9
|
}, args, {
|
|
8
10
|
fileInfoService
|
|
9
11
|
}) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
options.logger.trace('(FileInfo.url) url [%s]', url);
|
|
13
|
+
try {
|
|
14
|
+
if (!url) {
|
|
15
|
+
options.logger.warn('Missing URL in FileInfo');
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const basePath = fileInfoService.awsS3Service.basePath || 'aws';
|
|
19
|
+
if (!url.includes(basePath)) {
|
|
20
|
+
return url;
|
|
21
|
+
}
|
|
22
|
+
return fileInfoService.getResizedImage(url, {
|
|
23
|
+
width: undefined,
|
|
24
|
+
height: undefined
|
|
25
|
+
});
|
|
26
|
+
} catch (error) {
|
|
27
|
+
options.logger.error('Error getting FileInfo URL: %o', error);
|
|
28
|
+
return url; // Fallback to original URL
|
|
13
29
|
}
|
|
14
|
-
return fileInfoService.getResizedImage(url, {
|
|
15
|
-
width: undefined,
|
|
16
|
-
height: undefined
|
|
17
|
-
});
|
|
18
30
|
},
|
|
19
31
|
extension(src) {
|
|
20
|
-
|
|
32
|
+
options.logger.trace('(FileInfo.extension) mimeType [%s]', src?.mimeType);
|
|
33
|
+
try {
|
|
34
|
+
if (!src?.mimeType || typeof src.mimeType !== 'string') {
|
|
35
|
+
options.logger.warn('Missing or invalid mimeType in FileInfo');
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const parts = src.mimeType.split('/');
|
|
39
|
+
return parts.length > 1 ? parts[1] : null;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
options.logger.error('Error getting FileInfo extension: %o', error);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
21
44
|
}
|
|
22
45
|
},
|
|
23
46
|
Post: {
|
|
24
47
|
editedBy(src, args, {
|
|
25
|
-
accountService
|
|
48
|
+
accountService,
|
|
49
|
+
accountUserDataLoader
|
|
26
50
|
}) {
|
|
27
|
-
|
|
51
|
+
options.logger.trace('(Post.editedBy) editedBy [%s]', src?.editedBy);
|
|
52
|
+
try {
|
|
53
|
+
if (!src?.editedBy) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return accountUserDataLoader.load(src.editedBy.toString());
|
|
57
|
+
} catch (error) {
|
|
58
|
+
options.logger.error('Error getting Post editedBy: %o', error);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
28
61
|
},
|
|
29
62
|
deletedBy(src, args, {
|
|
30
|
-
accountService
|
|
63
|
+
accountService,
|
|
64
|
+
accountUserDataLoader
|
|
31
65
|
}) {
|
|
32
|
-
|
|
66
|
+
options.logger.trace('(Post.deletedBy) deletedBy [%s]', src?.deletedBy);
|
|
67
|
+
try {
|
|
68
|
+
if (!src?.deletedBy) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return accountUserDataLoader.load(src.deletedBy.toString());
|
|
72
|
+
} catch (error) {
|
|
73
|
+
options.logger.error('Error getting Post deletedBy: %o', error);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
33
76
|
},
|
|
34
77
|
author(src, args, {
|
|
35
78
|
accountService
|
|
36
79
|
}) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
80
|
+
options.logger.trace('(Post.author) author [%s], editedBy [%s]', src?.author, src?.editedBy);
|
|
81
|
+
try {
|
|
82
|
+
const author = src?.author?.toString();
|
|
83
|
+
if (author) {
|
|
84
|
+
return accountService.findAccountById(author);
|
|
85
|
+
}
|
|
86
|
+
// Fallback to editedBy if author is not available
|
|
87
|
+
if (src?.editedBy) {
|
|
88
|
+
return accountService.findAccountById(src.editedBy.toString());
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
options.logger.error('Error getting Post author: %o', error);
|
|
93
|
+
return null;
|
|
40
94
|
}
|
|
41
|
-
return src?.editedBy ? accountService.findAccountById(src.editedBy.toString()) : null;
|
|
42
95
|
},
|
|
43
96
|
channel(src, args, {
|
|
44
97
|
channelService
|
|
45
98
|
}) {
|
|
46
|
-
|
|
99
|
+
options.logger.trace('(Post.channel) channel [%s]', src?.channel);
|
|
100
|
+
try {
|
|
101
|
+
if (!src?.channel) {
|
|
102
|
+
options.logger.warn('Missing channel in Post');
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return channelService.get(src.channel.toString());
|
|
106
|
+
} catch (error) {
|
|
107
|
+
options.logger.error('Error getting Post channel: %o', error);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
47
110
|
},
|
|
48
111
|
props(src, _, {
|
|
49
112
|
userContext
|
|
50
113
|
}) {
|
|
51
|
-
|
|
114
|
+
options.logger.trace('(Post.props) accountId [%s]', userContext?.accountId);
|
|
115
|
+
try {
|
|
116
|
+
if (!userContext?.accountId || !src?.props) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return src.props[`[${userContext.accountId}]`] || null;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
options.logger.error('Error getting Post props: %o', error);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
52
124
|
},
|
|
53
125
|
isRead(src, _, {
|
|
54
126
|
userContext
|
|
55
127
|
}) {
|
|
56
|
-
|
|
128
|
+
options.logger.trace('(Post.isRead) accountId [%s]', userContext?.accountId);
|
|
129
|
+
try {
|
|
130
|
+
if (!userContext?.accountId || !src?.props) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return get(src.props[`[${userContext.accountId}]`], 'messenger.posts.isRead', false);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
options.logger.error('Error getting Post isRead: %o', error);
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
57
138
|
},
|
|
58
139
|
isDelivered(src, _, {
|
|
59
140
|
userContext
|
|
60
141
|
}) {
|
|
61
|
-
|
|
142
|
+
options.logger.trace('(Post.isDelivered) accountId [%s]', userContext?.accountId);
|
|
143
|
+
try {
|
|
144
|
+
if (!userContext?.accountId || !src?.props) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
return get(src.props[`[${userContext.accountId}]`], 'messenger.posts.isDelivered', false);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
options.logger.error('Error getting Post isDelivered: %o', error);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
62
152
|
},
|
|
63
|
-
propsConfiguration(src, args, {
|
|
64
|
-
configurationService
|
|
153
|
+
async propsConfiguration(src, args, {
|
|
154
|
+
configurationService,
|
|
155
|
+
userContext
|
|
65
156
|
}) {
|
|
66
|
-
|
|
67
|
-
_id: src.id
|
|
68
|
-
}, 'props');
|
|
69
|
-
let data = '{}';
|
|
157
|
+
options.logger.trace('(Post.propsConfiguration) postId [%s], orgName [%s]', src?.id);
|
|
70
158
|
try {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
159
|
+
// if (!src?.id || !userContext?.orgName) {
|
|
160
|
+
if (!src?.id) {
|
|
161
|
+
options.logger.warn('Missing required data for propsConfiguration');
|
|
162
|
+
throw new Error('Missing post ID or organization name');
|
|
163
|
+
}
|
|
164
|
+
// const { orgName } = userContext;
|
|
165
|
+
// options.logger.debug('Processing propsConfiguration for orgName: %s', orgName);
|
|
166
|
+
const resource = generateResourceUri(ConfigCollectionName.Post, {
|
|
167
|
+
_id: src.id
|
|
168
|
+
}, 'props', DEFAULT_TENANT_ID, {
|
|
169
|
+
scheme: Scheme.CDECODE_RESOURCE
|
|
170
|
+
});
|
|
171
|
+
let data = '{}';
|
|
172
|
+
try {
|
|
173
|
+
data = JSON.stringify(src.props || {});
|
|
174
|
+
} catch (err) {
|
|
175
|
+
options.logger.warn('Error serializing props data: %o', err);
|
|
176
|
+
data = '{}';
|
|
177
|
+
}
|
|
178
|
+
const nodeContext = buildNodeContext(userContext);
|
|
179
|
+
const machineModel = await configurationService.parser(resource.toString(), data, nodeContext, null, false);
|
|
180
|
+
if (machineModel instanceof Error) {
|
|
181
|
+
options.logger.error('Error parsing configuration: %o', machineModel);
|
|
182
|
+
throw machineModel;
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
resource,
|
|
186
|
+
contents: machineModel.contents,
|
|
187
|
+
overrides: machineModel.overrides,
|
|
188
|
+
keys: machineModel.keys,
|
|
189
|
+
__typename: ClientCacheTypeNames.MachineConfiguration
|
|
190
|
+
};
|
|
191
|
+
} catch (error) {
|
|
192
|
+
options.logger.error('Error getting Post propsConfiguration: %o', error);
|
|
193
|
+
throw error;
|
|
74
194
|
}
|
|
75
|
-
const machineModel = configurationService.parser(resource.toString(), data);
|
|
76
|
-
return {
|
|
77
|
-
resource,
|
|
78
|
-
contents: machineModel.contents,
|
|
79
|
-
overrides: machineModel.overrides,
|
|
80
|
-
keys: machineModel.keys,
|
|
81
|
-
__typename: ClientCacheTypeNames.MachineConfiguration
|
|
82
|
-
};
|
|
83
195
|
},
|
|
84
196
|
async files(src, args, {
|
|
85
197
|
fileInfoService
|
|
86
198
|
}) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
199
|
+
options.logger.trace('(Post.files) postId [%s], args [%j]', src?.id, args);
|
|
200
|
+
try {
|
|
201
|
+
if (!src?.id) {
|
|
202
|
+
options.logger.warn('Missing post ID for files');
|
|
203
|
+
return {
|
|
204
|
+
data: [],
|
|
205
|
+
totalCount: 0
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (!fileInfoService) {
|
|
209
|
+
options.logger.warn('FileInfoService not available');
|
|
210
|
+
return {
|
|
211
|
+
data: [],
|
|
212
|
+
totalCount: 0
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const {
|
|
216
|
+
data,
|
|
217
|
+
totalCount
|
|
218
|
+
} = await fileInfoService.getAllWithCount({
|
|
219
|
+
...args,
|
|
220
|
+
criteria: {
|
|
221
|
+
...args.criteria,
|
|
222
|
+
refType: 'Post',
|
|
223
|
+
ref: src.id
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
const processedData = data.map(({
|
|
100
227
|
url,
|
|
101
228
|
...rest
|
|
102
229
|
}) => ({
|
|
103
230
|
...rest,
|
|
104
231
|
url: fileInfoService.getThumbnailImage(url)
|
|
105
|
-
}))
|
|
106
|
-
|
|
107
|
-
|
|
232
|
+
}));
|
|
233
|
+
options.logger.debug('Retrieved %d files for post %s', processedData.length, src.id);
|
|
234
|
+
return {
|
|
235
|
+
data: processedData,
|
|
236
|
+
totalCount
|
|
237
|
+
};
|
|
238
|
+
} catch (error) {
|
|
239
|
+
options.logger.error('Error getting Post files: %o', error);
|
|
240
|
+
return {
|
|
241
|
+
data: [],
|
|
242
|
+
totalCount: 0
|
|
243
|
+
};
|
|
244
|
+
}
|
|
108
245
|
},
|
|
109
246
|
async replies(src, args, {
|
|
110
247
|
postService
|
|
111
248
|
}) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
249
|
+
options.logger.trace('(Post.replies) postId [%s], channelId [%s]', src?.id, src?.channel);
|
|
250
|
+
console.log('args...', args);
|
|
251
|
+
try {
|
|
252
|
+
if (!src?.id || !src?.channel) {
|
|
253
|
+
options.logger.warn('Missing post ID or channel for replies');
|
|
254
|
+
return {
|
|
255
|
+
data: [],
|
|
256
|
+
totalCount: 0
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
if (!postService) {
|
|
260
|
+
options.logger.warn('PostService not available');
|
|
261
|
+
return {
|
|
262
|
+
data: [],
|
|
263
|
+
totalCount: 0
|
|
264
|
+
};
|
|
123
265
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
266
|
+
const totalRepliesCount = await postService?.count({
|
|
267
|
+
channel: src.channel.toString(),
|
|
268
|
+
parentId: src.id.toString()
|
|
269
|
+
});
|
|
270
|
+
const {
|
|
271
|
+
data,
|
|
272
|
+
totalCount
|
|
273
|
+
} = (await postService?.getAllWithCount({
|
|
274
|
+
criteria: {
|
|
275
|
+
channel: src.channel.toString(),
|
|
276
|
+
parentId: src.id.toString()
|
|
277
|
+
},
|
|
278
|
+
sort: {
|
|
279
|
+
key: 'createdAt',
|
|
280
|
+
value: SortEnum.Desc
|
|
281
|
+
},
|
|
282
|
+
limit: totalRepliesCount || 50
|
|
283
|
+
})) ?? {
|
|
284
|
+
data: [],
|
|
285
|
+
totalCount: 0
|
|
286
|
+
};
|
|
287
|
+
options.logger.debug('Retrieved %d replies for post %s', totalCount, src.id);
|
|
288
|
+
// Set default type to Simple if not specified
|
|
289
|
+
const processedData = data.map(post => ({
|
|
290
|
+
...post,
|
|
291
|
+
type: (post.type === 'message' ? PostTypeEnum.Message : post.type) || PostTypeEnum.Simple
|
|
292
|
+
}));
|
|
293
|
+
return {
|
|
294
|
+
totalCount,
|
|
295
|
+
data: processedData
|
|
296
|
+
};
|
|
297
|
+
} catch (error) {
|
|
298
|
+
options.logger.error('Error getting Post replies: %o', error);
|
|
299
|
+
return {
|
|
300
|
+
data: [],
|
|
301
|
+
totalCount: 0
|
|
302
|
+
};
|
|
303
|
+
}
|
|
129
304
|
}
|
|
130
305
|
},
|
|
131
306
|
Query: {
|
|
@@ -134,31 +309,79 @@ const postResolvers = options => ({
|
|
|
134
309
|
parentId,
|
|
135
310
|
limit,
|
|
136
311
|
skip,
|
|
137
|
-
sort
|
|
312
|
+
sort,
|
|
313
|
+
props
|
|
138
314
|
}, {
|
|
139
315
|
postService,
|
|
316
|
+
channelService,
|
|
140
317
|
userContext
|
|
141
318
|
}) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
319
|
+
options.logger.trace('(Query.messages) channelId [%s], parentId [%s], limit [%d], skip [%d]', channelId, parentId, limit, skip);
|
|
320
|
+
try {
|
|
321
|
+
// if (projectId && !channelId) {
|
|
322
|
+
// const { data: channels } = (await channelService.getAllWithCount({
|
|
323
|
+
// criteria: {
|
|
324
|
+
// projectId: projectId?.toString?.(),
|
|
325
|
+
// type: RoomType.Aiassistant,
|
|
326
|
+
// },
|
|
327
|
+
// limit: 1,
|
|
328
|
+
// })) as unknown as { data: IChannel[]; totalCount: number };
|
|
329
|
+
// const channel = channels?.[0];
|
|
330
|
+
// channelId = channel?.id as string;
|
|
331
|
+
// }
|
|
332
|
+
if (!channelId && !props) {
|
|
333
|
+
options.logger.debug('No channelId provided in messages query — returning empty result');
|
|
334
|
+
return {
|
|
335
|
+
totalCount: 0,
|
|
336
|
+
data: []
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
if (!userContext?.accountId) {
|
|
340
|
+
options.logger.warn('Missing user context in messages query');
|
|
341
|
+
throw new Error('User authentication required');
|
|
342
|
+
}
|
|
343
|
+
if (!postService) {
|
|
344
|
+
options.logger.warn('PostService not available');
|
|
345
|
+
throw new Error('Post service unavailable');
|
|
346
|
+
}
|
|
347
|
+
const sortBy = sort || {
|
|
348
|
+
key: 'createdAt',
|
|
349
|
+
value: SortEnum.Desc
|
|
350
|
+
};
|
|
351
|
+
const channel = channelId || undefined;
|
|
352
|
+
// const projectId = props?.projectId ? `"props.projectId":"${props?.projectId}"` : undefined;
|
|
353
|
+
// console.log("server projectId",projectId)
|
|
354
|
+
const criteria = props ? {
|
|
355
|
+
channel,
|
|
356
|
+
parentId,
|
|
357
|
+
'props.projectId': props?.projectId || undefined
|
|
358
|
+
} : {
|
|
359
|
+
channel,
|
|
152
360
|
parentId
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
361
|
+
};
|
|
362
|
+
const {
|
|
363
|
+
data,
|
|
364
|
+
totalCount
|
|
365
|
+
} = await postService.getAllWithCount({
|
|
366
|
+
criteria,
|
|
367
|
+
limit,
|
|
368
|
+
skip,
|
|
369
|
+
sort: sortBy
|
|
370
|
+
});
|
|
371
|
+
options.logger.debug('Retrieved %d messages for channel %s', totalCount, channelId);
|
|
372
|
+
// Set default type to Simple if not specified
|
|
373
|
+
const processedData = data.map(post => ({
|
|
374
|
+
...post,
|
|
375
|
+
type: (post.type === 'message' ? PostTypeEnum.Message : post.type) || PostTypeEnum.Simple
|
|
376
|
+
}));
|
|
377
|
+
return {
|
|
378
|
+
totalCount,
|
|
379
|
+
data: processedData
|
|
380
|
+
};
|
|
381
|
+
} catch (error) {
|
|
382
|
+
options.logger.error('Error in messages query: %o', error);
|
|
383
|
+
throw error;
|
|
384
|
+
}
|
|
162
385
|
},
|
|
163
386
|
async publicMessages(src, {
|
|
164
387
|
channelId
|
|
@@ -166,23 +389,43 @@ const postResolvers = options => ({
|
|
|
166
389
|
postService,
|
|
167
390
|
userContext
|
|
168
391
|
}) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
channel: channelId,
|
|
175
|
-
type: PostTypeEnum.Public
|
|
176
|
-
},
|
|
177
|
-
sort: {
|
|
178
|
-
key: 'createdAt',
|
|
179
|
-
value: SortEnum.Desc
|
|
392
|
+
options.logger.trace('(Query.publicMessages) channelId [%s]', channelId);
|
|
393
|
+
try {
|
|
394
|
+
if (!channelId) {
|
|
395
|
+
options.logger.warn('Missing channelId in publicMessages query');
|
|
396
|
+
throw new Error('Channel ID is required');
|
|
180
397
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
398
|
+
if (!postService) {
|
|
399
|
+
options.logger.warn('PostService not available');
|
|
400
|
+
throw new Error('Post service unavailable');
|
|
401
|
+
}
|
|
402
|
+
const {
|
|
403
|
+
data,
|
|
404
|
+
totalCount
|
|
405
|
+
} = await postService.getAllWithCount({
|
|
406
|
+
criteria: {
|
|
407
|
+
channel: channelId,
|
|
408
|
+
type: PostTypeEnum.Public
|
|
409
|
+
},
|
|
410
|
+
sort: {
|
|
411
|
+
key: 'createdAt',
|
|
412
|
+
value: SortEnum.Desc
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
options.logger.debug('Retrieved %d public messages for channel %s', totalCount, channelId);
|
|
416
|
+
// Set default type to Simple if not specified
|
|
417
|
+
const processedData = data.map(post => ({
|
|
418
|
+
...post,
|
|
419
|
+
type: post.type || PostTypeEnum.Simple
|
|
420
|
+
}));
|
|
421
|
+
return {
|
|
422
|
+
totalCount,
|
|
423
|
+
data: processedData
|
|
424
|
+
};
|
|
425
|
+
} catch (error) {
|
|
426
|
+
options.logger.error('Error in publicMessages query: %o', error);
|
|
427
|
+
throw error;
|
|
428
|
+
}
|
|
186
429
|
}
|
|
187
430
|
},
|
|
188
431
|
Mutation: {
|
|
@@ -191,14 +434,29 @@ const postResolvers = options => ({
|
|
|
191
434
|
}, {
|
|
192
435
|
postService
|
|
193
436
|
}) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
messageId
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
437
|
+
options.logger.trace('(Mutation.deleteMessage) messageId [%j]', messageId);
|
|
438
|
+
try {
|
|
439
|
+
if (!messageId?.channelId || !messageId?.messageId) {
|
|
440
|
+
options.logger.warn('Missing required messageId parameters');
|
|
441
|
+
throw new Error('Channel ID and Message ID are required');
|
|
442
|
+
}
|
|
443
|
+
if (!postService) {
|
|
444
|
+
options.logger.warn('PostService not available');
|
|
445
|
+
throw new Error('Post service unavailable');
|
|
446
|
+
}
|
|
447
|
+
const {
|
|
448
|
+
channelId,
|
|
449
|
+
messageId: id
|
|
450
|
+
} = messageId;
|
|
451
|
+
options.logger.debug('Deleting message %s from channel %s', id, channelId);
|
|
452
|
+
return postService.delete({
|
|
453
|
+
channel: channelId,
|
|
454
|
+
id
|
|
455
|
+
});
|
|
456
|
+
} catch (error) {
|
|
457
|
+
options.logger.error('Error deleting message: %o', error);
|
|
458
|
+
throw error;
|
|
459
|
+
}
|
|
202
460
|
},
|
|
203
461
|
editMessage(src, {
|
|
204
462
|
messageId,
|
|
@@ -207,12 +465,45 @@ const postResolvers = options => ({
|
|
|
207
465
|
postService,
|
|
208
466
|
userContext
|
|
209
467
|
}) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
468
|
+
options.logger.trace('(Mutation.editMessage) messageId [%j], content length [%d]', messageId, messageInput?.content?.length || 0);
|
|
469
|
+
try {
|
|
470
|
+
if (!messageId?.messageId || !messageId?.channelId) {
|
|
471
|
+
options.logger.warn('Missing required messageId parameters');
|
|
472
|
+
throw new Error('Message ID and Channel ID are required');
|
|
473
|
+
}
|
|
474
|
+
if (!messageInput?.content) {
|
|
475
|
+
options.logger.warn('Missing message content');
|
|
476
|
+
throw new Error('Message content is required');
|
|
477
|
+
}
|
|
478
|
+
if (!userContext?.accountId) {
|
|
479
|
+
options.logger.warn('Missing user context');
|
|
480
|
+
throw new Error('User authentication required');
|
|
481
|
+
}
|
|
482
|
+
if (!postService) {
|
|
483
|
+
options.logger.warn('PostService not available');
|
|
484
|
+
throw new Error('Post service unavailable');
|
|
485
|
+
}
|
|
486
|
+
options.logger.debug('Editing message %s in channel %s', messageId.messageId, messageId.channelId);
|
|
487
|
+
const {
|
|
488
|
+
content,
|
|
489
|
+
files,
|
|
490
|
+
extraProps
|
|
491
|
+
} = messageInput;
|
|
492
|
+
return postService.update(messageId.messageId, {
|
|
493
|
+
message: content,
|
|
494
|
+
editedBy: userContext.accountId,
|
|
495
|
+
channel: messageId.channelId,
|
|
496
|
+
files,
|
|
497
|
+
...(extraProps && {
|
|
498
|
+
props: {
|
|
499
|
+
extraProps
|
|
500
|
+
}
|
|
501
|
+
})
|
|
502
|
+
});
|
|
503
|
+
} catch (error) {
|
|
504
|
+
options.logger.error('Error editing message: %o', error);
|
|
505
|
+
throw error;
|
|
506
|
+
}
|
|
216
507
|
},
|
|
217
508
|
async sendMessage(src, {
|
|
218
509
|
channelId,
|
|
@@ -222,49 +513,69 @@ const postResolvers = options => ({
|
|
|
222
513
|
postService,
|
|
223
514
|
userContext
|
|
224
515
|
}) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
516
|
+
options.logger.trace('(Mutation.sendMessage) channelId [%s], postId [%s], content length [%d]', channelId, postId, messageInput?.content?.length || 0);
|
|
517
|
+
try {
|
|
518
|
+
if (!channelId) {
|
|
519
|
+
options.logger.warn('Missing channelId');
|
|
520
|
+
throw new Error('Channel ID is required');
|
|
521
|
+
}
|
|
522
|
+
if (!messageInput?.content) {
|
|
523
|
+
options.logger.warn('Missing message content');
|
|
524
|
+
throw new Error('Message content is required');
|
|
525
|
+
}
|
|
526
|
+
if (!userContext?.accountId) {
|
|
527
|
+
options.logger.warn('Missing user context');
|
|
528
|
+
throw new Error('User authentication required');
|
|
529
|
+
}
|
|
530
|
+
if (!postService) {
|
|
531
|
+
options.logger.warn('PostService not available');
|
|
532
|
+
throw new Error('Post service unavailable');
|
|
533
|
+
}
|
|
534
|
+
const {
|
|
535
|
+
content,
|
|
242
536
|
files,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
537
|
+
createdBy,
|
|
538
|
+
notificationParams,
|
|
539
|
+
type,
|
|
540
|
+
extraProps
|
|
541
|
+
} = messageInput;
|
|
542
|
+
const {
|
|
543
|
+
accountId
|
|
544
|
+
} = userContext;
|
|
545
|
+
const postData = {
|
|
249
546
|
channel: channelId,
|
|
250
547
|
message: content,
|
|
251
548
|
editedBy: createdBy || accountId,
|
|
252
549
|
author: createdBy || accountId,
|
|
253
550
|
files,
|
|
254
|
-
props: notificationParams ? {
|
|
255
|
-
notificationParams
|
|
256
|
-
|
|
257
|
-
|
|
551
|
+
props: notificationParams || extraProps ? {
|
|
552
|
+
...(notificationParams && {
|
|
553
|
+
notificationParams
|
|
554
|
+
}),
|
|
555
|
+
...(extraProps && {
|
|
556
|
+
...extraProps
|
|
557
|
+
})
|
|
558
|
+
} : undefined,
|
|
559
|
+
type: type || PostTypeEnum.Simple
|
|
560
|
+
};
|
|
561
|
+
let post;
|
|
562
|
+
if (postId) {
|
|
563
|
+
options.logger.debug('Creating message with specific ID %s', postId);
|
|
564
|
+
post = await postService.create({
|
|
565
|
+
_id: postId,
|
|
566
|
+
...postData
|
|
567
|
+
});
|
|
568
|
+
} else {
|
|
569
|
+
options.logger.debug('Creating new message in channel %s', channelId);
|
|
570
|
+
post = await postService.create(postData);
|
|
571
|
+
}
|
|
572
|
+
options.logger.debug('Message created successfully with ID %s', post?.id || post?._id);
|
|
573
|
+
//options.pubsub.publish(`POST_CREATED.${channelId}`, post);
|
|
574
|
+
return post;
|
|
575
|
+
} catch (error) {
|
|
576
|
+
options.logger.error('Error sending message: %o', error);
|
|
577
|
+
throw error;
|
|
258
578
|
}
|
|
259
|
-
// const post = await postService.create({
|
|
260
|
-
// channel: channelId as any,
|
|
261
|
-
// message: content,
|
|
262
|
-
// editedBy: accountId as any,
|
|
263
|
-
// author: accountId as any,
|
|
264
|
-
// files,
|
|
265
|
-
// });
|
|
266
|
-
// options.pubsub.publish(`POST_CREATED.${channelId}`, post);
|
|
267
|
-
return post;
|
|
268
579
|
},
|
|
269
580
|
async sendPublicMessage(src, {
|
|
270
581
|
channelId,
|
|
@@ -275,46 +586,77 @@ const postResolvers = options => ({
|
|
|
275
586
|
channelService,
|
|
276
587
|
userContext
|
|
277
588
|
}) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
589
|
+
options.logger.trace('(Mutation.sendPublicMessage) channelId [%s], postId [%s]', channelId, postId);
|
|
590
|
+
try {
|
|
591
|
+
if (!channelId) {
|
|
592
|
+
options.logger.warn('Missing channelId');
|
|
593
|
+
throw new Error('Channel ID is required');
|
|
594
|
+
}
|
|
595
|
+
if (!messageInput?.content) {
|
|
596
|
+
options.logger.warn('Missing message content');
|
|
597
|
+
throw new Error('Message content is required');
|
|
598
|
+
}
|
|
599
|
+
if (!userContext?.accountId) {
|
|
600
|
+
options.logger.warn('Missing user context');
|
|
601
|
+
throw new Error('User authentication required');
|
|
602
|
+
}
|
|
603
|
+
if (!postService || !channelService) {
|
|
604
|
+
options.logger.warn('Required services not available');
|
|
605
|
+
throw new Error('Required services unavailable');
|
|
606
|
+
}
|
|
607
|
+
const {
|
|
608
|
+
content,
|
|
609
|
+
files,
|
|
610
|
+
createdBy,
|
|
611
|
+
extraProps
|
|
612
|
+
} = messageInput;
|
|
613
|
+
const {
|
|
614
|
+
accountId
|
|
615
|
+
} = userContext;
|
|
616
|
+
let post = null;
|
|
617
|
+
const channelExists = await channelService.get(channelId);
|
|
618
|
+
if (!channelExists) {
|
|
619
|
+
options.logger.debug('Creating public channel %s', channelId);
|
|
620
|
+
const channel = await channelService.savePublicChannel({
|
|
621
|
+
_id: channelId,
|
|
622
|
+
type: RoomType.Public,
|
|
623
|
+
title: `public-channel-${channelId}`
|
|
303
624
|
});
|
|
625
|
+
if (!channel) {
|
|
626
|
+
options.logger.error('Failed to create public channel %s', channelId);
|
|
627
|
+
throw new Error('Failed to create public channel');
|
|
628
|
+
}
|
|
304
629
|
}
|
|
305
|
-
|
|
306
|
-
post = await postService.createWithoutSubscription({
|
|
307
|
-
_id: postId || undefined,
|
|
630
|
+
const postData = {
|
|
308
631
|
channel: channelId,
|
|
309
632
|
message: content,
|
|
310
633
|
editedBy: createdBy || accountId,
|
|
311
634
|
author: createdBy || accountId,
|
|
312
635
|
files,
|
|
313
|
-
type: PostTypeEnum.Public
|
|
314
|
-
|
|
636
|
+
type: PostTypeEnum.Public,
|
|
637
|
+
...(extraProps && {
|
|
638
|
+
props: {
|
|
639
|
+
extraProps
|
|
640
|
+
}
|
|
641
|
+
})
|
|
642
|
+
};
|
|
643
|
+
if (postId) {
|
|
644
|
+
post = await postService.createWithoutSubscription({
|
|
645
|
+
_id: postId,
|
|
646
|
+
...postData
|
|
647
|
+
});
|
|
648
|
+
} else {
|
|
649
|
+
post = await postService.createWithoutSubscription(postData);
|
|
650
|
+
}
|
|
651
|
+
if (post) {
|
|
652
|
+
options.logger.debug('Publishing public post created event for channel %s', channelId);
|
|
653
|
+
options.pubsub.publish(`PUBLIC_POST_CREATED.${channelId}`, post);
|
|
654
|
+
}
|
|
655
|
+
return post;
|
|
656
|
+
} catch (error) {
|
|
657
|
+
options.logger.error('Error sending public message: %o', error);
|
|
658
|
+
throw error;
|
|
315
659
|
}
|
|
316
|
-
if (post) options.pubsub.publish(`PUBLIC_POST_CREATED.${channelId}`, post);
|
|
317
|
-
return post;
|
|
318
660
|
},
|
|
319
661
|
async sendExpoNotificationOnPost(_, {
|
|
320
662
|
postId,
|
|
@@ -324,9 +666,29 @@ const postResolvers = options => ({
|
|
|
324
666
|
postService,
|
|
325
667
|
userContext
|
|
326
668
|
}) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
669
|
+
options.logger.trace('(Mutation.sendExpoNotificationOnPost) postId [%s]', postId);
|
|
670
|
+
try {
|
|
671
|
+
if (!postId) {
|
|
672
|
+
options.logger.warn('Missing postId');
|
|
673
|
+
throw new Error('Post ID is required');
|
|
674
|
+
}
|
|
675
|
+
if (!messengerNotificationService || !postService) {
|
|
676
|
+
options.logger.warn('Required services not available');
|
|
677
|
+
throw new Error('Required services unavailable');
|
|
678
|
+
}
|
|
679
|
+
const post = await postService.get(postId.toString());
|
|
680
|
+
if (!post) {
|
|
681
|
+
options.logger.warn('Post not found: %s', postId);
|
|
682
|
+
throw new Error('Post not found');
|
|
683
|
+
}
|
|
684
|
+
options.logger.debug('Sending expo notification for post %s', postId);
|
|
685
|
+
const result = await messengerNotificationService.sendExpoNotificationOnPost(post, notificationData);
|
|
686
|
+
options.logger.debug('Expo notification sent successfully for post %s', postId);
|
|
687
|
+
return result;
|
|
688
|
+
} catch (error) {
|
|
689
|
+
options.logger.error('Error sending expo notification: %o', error);
|
|
690
|
+
throw error;
|
|
691
|
+
}
|
|
330
692
|
},
|
|
331
693
|
createMessageFileUploadLink(_, {
|
|
332
694
|
postId,
|
|
@@ -335,7 +697,25 @@ const postResolvers = options => ({
|
|
|
335
697
|
postService,
|
|
336
698
|
userContext
|
|
337
699
|
}) {
|
|
338
|
-
|
|
700
|
+
options.logger.trace('(Mutation.createMessageFileUploadLink) postId [%s], filename [%s]', postId, filename);
|
|
701
|
+
try {
|
|
702
|
+
if (!postId || !filename) {
|
|
703
|
+
options.logger.warn('Missing postId or filename');
|
|
704
|
+
throw new Error('Post ID and filename are required');
|
|
705
|
+
}
|
|
706
|
+
if (!userContext?.accountId) {
|
|
707
|
+
options.logger.warn('Missing user context');
|
|
708
|
+
throw new Error('User authentication required');
|
|
709
|
+
}
|
|
710
|
+
if (!postService) {
|
|
711
|
+
options.logger.warn('PostService not available');
|
|
712
|
+
throw new Error('Post service unavailable');
|
|
713
|
+
}
|
|
714
|
+
return postService.createFileUploadLink(postId, filename, userContext.accountId);
|
|
715
|
+
} catch (error) {
|
|
716
|
+
options.logger.error('Error creating file upload link: %o', error);
|
|
717
|
+
throw error;
|
|
718
|
+
}
|
|
339
719
|
},
|
|
340
720
|
attachUploadedFileToMessage(_, {
|
|
341
721
|
postId,
|
|
@@ -344,7 +724,25 @@ const postResolvers = options => ({
|
|
|
344
724
|
postService,
|
|
345
725
|
userContext
|
|
346
726
|
}) {
|
|
347
|
-
|
|
727
|
+
options.logger.trace('(Mutation.attachUploadedFileToMessage) postId [%s], filename [%s]', postId, file?.name);
|
|
728
|
+
try {
|
|
729
|
+
if (!postId || !file) {
|
|
730
|
+
options.logger.warn('Missing postId or file');
|
|
731
|
+
throw new Error('Post ID and file are required');
|
|
732
|
+
}
|
|
733
|
+
if (!userContext?.accountId) {
|
|
734
|
+
options.logger.warn('Missing user context');
|
|
735
|
+
throw new Error('User authentication required');
|
|
736
|
+
}
|
|
737
|
+
if (!postService) {
|
|
738
|
+
options.logger.warn('PostService not available');
|
|
739
|
+
throw new Error('Post service unavailable');
|
|
740
|
+
}
|
|
741
|
+
return postService.attachUploadedFile(postId, file, userContext.accountId);
|
|
742
|
+
} catch (error) {
|
|
743
|
+
options.logger.error('Error attaching uploaded file: %o', error);
|
|
744
|
+
throw error;
|
|
745
|
+
}
|
|
348
746
|
},
|
|
349
747
|
async createMessageFilesUploadLink(_, {
|
|
350
748
|
postId,
|
|
@@ -353,7 +751,25 @@ const postResolvers = options => ({
|
|
|
353
751
|
postService,
|
|
354
752
|
userContext
|
|
355
753
|
}) {
|
|
356
|
-
|
|
754
|
+
options.logger.trace('(Mutation.createMessageFilesUploadLink) postId [%s], fileCount [%d]', postId, filenames?.length || 0);
|
|
755
|
+
try {
|
|
756
|
+
if (!postId || !filenames || !Array.isArray(filenames) || filenames.length === 0) {
|
|
757
|
+
options.logger.warn('Missing postId or filenames');
|
|
758
|
+
throw new Error('Post ID and filenames array are required');
|
|
759
|
+
}
|
|
760
|
+
if (!userContext?.accountId) {
|
|
761
|
+
options.logger.warn('Missing user context');
|
|
762
|
+
throw new Error('User authentication required');
|
|
763
|
+
}
|
|
764
|
+
if (!postService) {
|
|
765
|
+
options.logger.warn('PostService not available');
|
|
766
|
+
throw new Error('Post service unavailable');
|
|
767
|
+
}
|
|
768
|
+
return postService.createFilesUploadLink(postId, filenames, userContext.accountId);
|
|
769
|
+
} catch (error) {
|
|
770
|
+
options.logger.error('Error creating files upload links: %o', error);
|
|
771
|
+
throw error;
|
|
772
|
+
}
|
|
357
773
|
},
|
|
358
774
|
async attachUploadedFilesToMessage(_, {
|
|
359
775
|
postId,
|
|
@@ -362,14 +778,46 @@ const postResolvers = options => ({
|
|
|
362
778
|
postService,
|
|
363
779
|
userContext
|
|
364
780
|
}) {
|
|
365
|
-
|
|
781
|
+
options.logger.trace('(Mutation.attachUploadedFilesToMessage) postId [%s], fileCount [%d]', postId, files?.length || 0);
|
|
782
|
+
try {
|
|
783
|
+
if (!postId || !files || !Array.isArray(files) || files.length === 0) {
|
|
784
|
+
options.logger.warn('Missing postId or files');
|
|
785
|
+
throw new Error('Post ID and files array are required');
|
|
786
|
+
}
|
|
787
|
+
if (!userContext?.accountId) {
|
|
788
|
+
options.logger.warn('Missing user context');
|
|
789
|
+
throw new Error('User authentication required');
|
|
790
|
+
}
|
|
791
|
+
if (!postService) {
|
|
792
|
+
options.logger.warn('PostService not available');
|
|
793
|
+
throw new Error('Post service unavailable');
|
|
794
|
+
}
|
|
795
|
+
return postService.attachUploadedFiles(postId, files, userContext.accountId);
|
|
796
|
+
} catch (error) {
|
|
797
|
+
options.logger.error('Error attaching uploaded files: %o', error);
|
|
798
|
+
throw error;
|
|
799
|
+
}
|
|
366
800
|
},
|
|
367
801
|
deleteMessageFile(_, {
|
|
368
802
|
url
|
|
369
803
|
}, {
|
|
370
804
|
postService
|
|
371
805
|
}) {
|
|
372
|
-
|
|
806
|
+
options.logger.trace('(Mutation.deleteMessageFile) url [%s]', url);
|
|
807
|
+
try {
|
|
808
|
+
if (!url) {
|
|
809
|
+
options.logger.warn('Missing URL');
|
|
810
|
+
throw new Error('File URL is required');
|
|
811
|
+
}
|
|
812
|
+
if (!postService) {
|
|
813
|
+
options.logger.warn('PostService not available');
|
|
814
|
+
throw new Error('Post service unavailable');
|
|
815
|
+
}
|
|
816
|
+
return postService.deleteFile(url);
|
|
817
|
+
} catch (error) {
|
|
818
|
+
options.logger.error('Error deleting message file: %o', error);
|
|
819
|
+
throw error;
|
|
820
|
+
}
|
|
373
821
|
},
|
|
374
822
|
async readMessage(src, {
|
|
375
823
|
messageId
|
|
@@ -378,11 +826,30 @@ const postResolvers = options => ({
|
|
|
378
826
|
userContext,
|
|
379
827
|
channelService
|
|
380
828
|
}) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
829
|
+
options.logger.trace('(Mutation.readMessage) messageId [%j], accountId [%s]', messageId, userContext?.accountId);
|
|
830
|
+
try {
|
|
831
|
+
if (!messageId?.channelId || !messageId?.messageId) {
|
|
832
|
+
options.logger.warn('Missing messageId parameters');
|
|
833
|
+
throw new GraphQLError('Message ID and Channel ID are required');
|
|
834
|
+
}
|
|
835
|
+
if (!userContext?.accountId) {
|
|
836
|
+
options.logger.warn('Missing user context');
|
|
837
|
+
throw new GraphQLError('User authentication required');
|
|
838
|
+
}
|
|
839
|
+
if (!postService || !channelService) {
|
|
840
|
+
options.logger.warn('Required services not available');
|
|
841
|
+
throw new GraphQLError('Required services unavailable');
|
|
842
|
+
}
|
|
843
|
+
const member = await channelService.isMember(messageId.channelId, userContext.accountId);
|
|
844
|
+
if (!member) {
|
|
845
|
+
options.logger.warn('User %s is not a member of channel %s', userContext.accountId, messageId.channelId);
|
|
846
|
+
throw new GraphQLError('Message does not belong to user');
|
|
847
|
+
}
|
|
848
|
+
return postService.readMessage(messageId, userContext.accountId);
|
|
849
|
+
} catch (error) {
|
|
850
|
+
options.logger.error('Error reading message: %o', error);
|
|
851
|
+
throw error;
|
|
384
852
|
}
|
|
385
|
-
return postService.readMessage(messageId, userContext.accountId);
|
|
386
853
|
},
|
|
387
854
|
async deliverMessage(src, {
|
|
388
855
|
messageId
|
|
@@ -391,70 +858,130 @@ const postResolvers = options => ({
|
|
|
391
858
|
userContext,
|
|
392
859
|
channelService
|
|
393
860
|
}) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
861
|
+
options.logger.trace('(Mutation.deliverMessage) messageId [%j], accountId [%s]', messageId, userContext?.accountId);
|
|
862
|
+
try {
|
|
863
|
+
if (!messageId?.channelId || !messageId?.messageId) {
|
|
864
|
+
options.logger.warn('Missing messageId parameters');
|
|
865
|
+
throw new GraphQLError('Message ID and Channel ID are required');
|
|
866
|
+
}
|
|
867
|
+
if (!userContext?.accountId) {
|
|
868
|
+
options.logger.warn('Missing user context');
|
|
869
|
+
throw new GraphQLError('User authentication required');
|
|
870
|
+
}
|
|
871
|
+
if (!postService || !channelService) {
|
|
872
|
+
options.logger.warn('Required services not available');
|
|
873
|
+
throw new GraphQLError('Required services unavailable');
|
|
874
|
+
}
|
|
875
|
+
const member = await channelService.isMember(messageId.channelId, userContext.accountId);
|
|
876
|
+
if (!member) {
|
|
877
|
+
options.logger.warn('User %s is not a member of channel %s', userContext.accountId, messageId.channelId);
|
|
878
|
+
throw new GraphQLError('Message does not belong to user');
|
|
879
|
+
}
|
|
880
|
+
return postService.deliverMessage(messageId, userContext.accountId);
|
|
881
|
+
} catch (error) {
|
|
882
|
+
options.logger.error('Error delivering message: %o', error);
|
|
883
|
+
throw error;
|
|
397
884
|
}
|
|
398
|
-
return postService.deliverMessage(messageId, userContext.accountId);
|
|
399
885
|
},
|
|
400
|
-
// uploadFile(src, { files, postId }, { fileInfoService, userContext }) {
|
|
401
|
-
// const res = [];
|
|
402
|
-
// files.map((file) =>
|
|
403
|
-
// res.push(
|
|
404
|
-
// fileInfoService.create({
|
|
405
|
-
// refType: FileRefType.Post as never,
|
|
406
|
-
// file,
|
|
407
|
-
// createdBy: userContext.accountId,
|
|
408
|
-
// ref: postId,
|
|
409
|
-
// }),
|
|
410
|
-
// ),
|
|
411
|
-
// );
|
|
412
|
-
// return res;
|
|
413
|
-
// },
|
|
414
886
|
async TestchatMessage(src, {
|
|
415
887
|
channelId
|
|
416
888
|
}, context) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
889
|
+
options.logger.trace('(Mutation.TestchatMessage) channelId [%s]', channelId);
|
|
890
|
+
try {
|
|
891
|
+
if (!channelId) {
|
|
892
|
+
options.logger.warn('Missing channelId');
|
|
893
|
+
throw new Error('Channel ID is required');
|
|
894
|
+
}
|
|
895
|
+
const testData = {
|
|
422
896
|
channelId,
|
|
423
897
|
orgName: 'upadhyaytarun'
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
898
|
+
};
|
|
899
|
+
options.logger.debug('Publishing test chat message for channel %s', channelId);
|
|
900
|
+
options.pubsub.publish(`CHAT_CREATED.${channelId}`, {
|
|
901
|
+
chatMessageTest: testData
|
|
902
|
+
});
|
|
903
|
+
return testData;
|
|
904
|
+
} catch (error) {
|
|
905
|
+
options.logger.error('Error in TestchatMessage: %o', error);
|
|
906
|
+
throw error;
|
|
907
|
+
}
|
|
430
908
|
}
|
|
431
909
|
},
|
|
432
910
|
Subscription: {
|
|
433
911
|
chatMessageAdded: {
|
|
434
|
-
// More on pubsub below
|
|
435
912
|
subscribe: (_, {
|
|
436
913
|
channelId,
|
|
437
914
|
directTo
|
|
438
915
|
}) => {
|
|
439
|
-
|
|
916
|
+
options.logger.trace('(Subscription.chatMessageAdded) channelId [%s], directTo [%s]', channelId, directTo);
|
|
917
|
+
try {
|
|
918
|
+
if (!channelId) {
|
|
919
|
+
throw new Error('Channel ID is required for subscription');
|
|
920
|
+
}
|
|
921
|
+
return options.pubsub.asyncIterator([`POST_CREATED.${channelId}`]);
|
|
922
|
+
} catch (error) {
|
|
923
|
+
options.logger.error('Error subscribing to chatMessageAdded: %o', error);
|
|
924
|
+
throw error;
|
|
925
|
+
}
|
|
440
926
|
},
|
|
441
|
-
resolve: payload =>
|
|
927
|
+
resolve: payload => {
|
|
928
|
+
options.logger.trace('(Subscription.chatMessageAdded.resolve) payload received');
|
|
929
|
+
return payload;
|
|
930
|
+
}
|
|
442
931
|
},
|
|
443
932
|
chatMessageTest: {
|
|
444
|
-
// More on pubsub below
|
|
445
933
|
subscribe: (_, {
|
|
446
934
|
channelId,
|
|
447
935
|
directTo
|
|
448
936
|
}) => {
|
|
449
|
-
|
|
937
|
+
options.logger.trace('(Subscription.chatMessageTest) channelId [%s], directTo [%s]', channelId, directTo);
|
|
938
|
+
try {
|
|
939
|
+
if (!channelId) {
|
|
940
|
+
throw new Error('Channel ID is required for subscription');
|
|
941
|
+
}
|
|
942
|
+
return options.pubsub.asyncIterator([`CHAT_CREATED.${channelId}`]);
|
|
943
|
+
} catch (error) {
|
|
944
|
+
options.logger.error('Error subscribing to chatMessageTest: %o', error);
|
|
945
|
+
throw error;
|
|
946
|
+
}
|
|
450
947
|
},
|
|
451
|
-
resolve: payload =>
|
|
948
|
+
resolve: payload => {
|
|
949
|
+
options.logger.trace('(Subscription.chatMessageTest.resolve) payload received');
|
|
950
|
+
return payload;
|
|
951
|
+
}
|
|
452
952
|
},
|
|
453
953
|
publicPostAdded: {
|
|
454
954
|
subscribe: (_, {
|
|
455
955
|
channelId
|
|
456
|
-
}) =>
|
|
457
|
-
|
|
956
|
+
}) => {
|
|
957
|
+
options.logger.trace('(Subscription.publicPostAdded) channelId [%s]', channelId);
|
|
958
|
+
try {
|
|
959
|
+
if (!channelId) {
|
|
960
|
+
throw new Error('Channel ID is required for subscription');
|
|
961
|
+
}
|
|
962
|
+
return options.pubsub.asyncIterator([`PUBLIC_POST_CREATED.${channelId}`]);
|
|
963
|
+
} catch (error) {
|
|
964
|
+
options.logger.error('Error subscribing to publicPostAdded: %o', error);
|
|
965
|
+
throw error;
|
|
966
|
+
}
|
|
967
|
+
},
|
|
968
|
+
resolve: payload => {
|
|
969
|
+
options.logger.trace('(Subscription.publicPostAdded.resolve) payload received');
|
|
970
|
+
return payload;
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
fileUpdated: {
|
|
974
|
+
subscribe: withFilter((_, __, context) => options.pubsub.asyncIterator(['FILE_UPDATED']), (payload, variables) => payload.fileUpdated.projectId === variables.projectId),
|
|
975
|
+
resolve: (payload, _args, context) => {
|
|
976
|
+
try {
|
|
977
|
+
if (!context.userContext) context.userContext = {};
|
|
978
|
+
if (!context.req) context.req = {};
|
|
979
|
+
return payload.fileUpdated;
|
|
980
|
+
} catch (error) {
|
|
981
|
+
options.logger.error('File update subscription resolve error: %o', error);
|
|
982
|
+
return payload.fileUpdated;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
458
985
|
}
|
|
459
986
|
}
|
|
460
987
|
});export{postResolvers};//# sourceMappingURL=post.js.map
|