Mark tg messages (#6333)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-08-14 20:13:26 +04:00 committed by GitHub
parent 25b890940e
commit 7a18f73d12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 59 additions and 5 deletions

19
.vscode/launch.json vendored
View File

@ -415,6 +415,25 @@
"cwd": "${workspaceRoot}/services/ai-bot/pod-ai-bot", "cwd": "${workspaceRoot}/services/ai-bot/pod-ai-bot",
"protocol": "inspector", "protocol": "inspector",
"outputCapture": "std" "outputCapture": "std"
},
{
"name": "Debug telegram bot",
"type": "node",
"request": "launch",
"args": ["src/index.ts"],
"env": {
"PORT": "4020",
"BOT_TOKEN": "token",
"MONGO_URL": "mongodb://localhost:27017",
"MONGO_DB": "telegram-bot",
"SECRET": "secret",
"ACCOUNTS_URL": "http://localhost:3000",
"SERVICE_ID": "telegram-bot-service"
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeVersion": "20",
"sourceMaps": true,
"cwd": "${workspaceRoot}/services/telegram-bot/pod-telegram-bot"
} }
] ]
} }

View File

@ -27,7 +27,7 @@ import {
type ChannelInfo type ChannelInfo
} from '@hcengineering/chunter' } from '@hcengineering/chunter'
import presentation from '@hcengineering/model-presentation' import presentation from '@hcengineering/model-presentation'
import contact, { type Person } from '@hcengineering/contact' import contact, { type ChannelProvider as SocialChannelProvider, type Person } from '@hcengineering/contact'
import { import {
type Class, type Class,
type Doc, type Doc,
@ -98,6 +98,9 @@ export class TChatMessage extends TActivityMessage implements ChatMessage {
shortLabel: attachment.string.Files shortLabel: attachment.string.Files
}) })
attachments?: number attachments?: number
@Prop(TypeRef(contact.class.ChannelProvider), core.string.Object)
provider?: Ref<SocialChannelProvider>
} }
@Model(chunter.class.ThreadMessage, chunter.class.ChatMessage) @Model(chunter.class.ThreadMessage, chunter.class.ChatMessage)

View File

@ -24,6 +24,7 @@
import { getClient } from '@hcengineering/presentation' import { getClient } from '@hcengineering/presentation'
import { Action, Icon, Label } from '@hcengineering/ui' import { Action, Icon, Label } from '@hcengineering/ui'
import { getActions, restrictionStore, showMenu } from '@hcengineering/view-resources' import { getActions, restrictionStore, showMenu } from '@hcengineering/view-resources'
import { Asset } from '@hcengineering/platform'
import ReactionsPresenter from '../reactions/ReactionsPresenter.svelte' import ReactionsPresenter from '../reactions/ReactionsPresenter.svelte'
import ActivityMessagePresenter from './ActivityMessagePresenter.svelte' import ActivityMessagePresenter from './ActivityMessagePresenter.svelte'
@ -56,6 +57,8 @@
export let type: ActivityMessageViewType = 'default' export let type: ActivityMessageViewType = 'default'
export let onClick: (() => void) | undefined = undefined export let onClick: (() => void) | undefined = undefined
export let socialIcon: Asset | undefined = undefined
const client = getClient() const client = getClient()
let menuActionIds: string[] = [] let menuActionIds: string[] = []
@ -187,6 +190,11 @@
<Icon icon={activity.icon.BookmarkFilled} size="xx-small" /> <Icon icon={activity.icon.BookmarkFilled} size="xx-small" />
</div> </div>
{/if} {/if}
{#if socialIcon}
<div class="socialIcon">
<Icon icon={socialIcon} size="x-small" />
</div>
{/if}
</div> </div>
{/if} {/if}
<div class="flex-col ml-2 w-full clear-mins message-content"> <div class="flex-col ml-2 w-full clear-mins message-content">
@ -391,4 +399,20 @@
flex-shrink: 1; flex-shrink: 1;
padding: 0; padding: 0;
} }
.socialIcon {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
width: 1.25rem;
height: 1.25rem;
padding: var(--spacing-1);
border-radius: 50%;
background: var(--theme-bg-color);
border: 1px solid var(--global-ui-BorderColor);
bottom: -0.375rem;
right: -0.375rem;
color: var(--content-color);
}
</style> </style>

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { Person, PersonAccount } from '@hcengineering/contact' import contact, { Person, PersonAccount } from '@hcengineering/contact'
import { personAccountByIdStore, personByIdStore } from '@hcengineering/contact-resources' import { personAccountByIdStore, personByIdStore } from '@hcengineering/contact-resources'
import { Class, Doc, getCurrentAccount, Ref, Space, WithLookup } from '@hcengineering/core' import { Class, Doc, getCurrentAccount, Ref, Space, WithLookup } from '@hcengineering/core'
import { getClient, MessageViewer } from '@hcengineering/presentation' import { getClient, MessageViewer } from '@hcengineering/presentation'
@ -142,6 +142,10 @@
let attachments: Attachment[] | undefined = undefined let attachments: Attachment[] | undefined = undefined
$: attachments = value?.$lookup?.attachments as Attachment[] | undefined $: attachments = value?.$lookup?.attachments as Attachment[] | undefined
$: socialProvider = value?.provider
? client.getModel().findAllSync(contact.class.ChannelProvider, { _id: value.provider })[0]
: undefined
</script> </script>
{#if inline && object} {#if inline && object}
@ -173,6 +177,7 @@
{skipLabel} {skipLabel}
{pending} {pending}
{stale} {stale}
socialIcon={socialProvider?.icon}
showDatePreposition={hideLink} showDatePreposition={hideLink}
{type} {type}
{onClick} {onClick}

View File

@ -20,7 +20,7 @@ import type { Asset, Plugin } from '@hcengineering/platform'
import { IntlString, plugin } from '@hcengineering/platform' import { IntlString, plugin } from '@hcengineering/platform'
import { AnyComponent } from '@hcengineering/ui' import { AnyComponent } from '@hcengineering/ui'
import { Action } from '@hcengineering/view' import { Action } from '@hcengineering/view'
import { Person } from '@hcengineering/contact' import { Person, ChannelProvider as SocialChannelProvider } from '@hcengineering/contact'
/** /**
* @public * @public
@ -53,6 +53,7 @@ export interface ChatMessage extends ActivityMessage {
message: Markup message: Markup
attachments?: number attachments?: number
editedOn?: Timestamp editedOn?: Timestamp
provider?: Ref<SocialChannelProvider>
} }
/** /**

View File

@ -55,7 +55,8 @@ export class WorkspaceClient {
objectClass: thread.objectClass, objectClass: thread.objectClass,
message: text, message: text,
attachments: 0, attachments: 0,
collection: 'replies' collection: 'replies',
provider: contact.channelProvider.Telegram
}) })
) )
await this.client.tx(collectionTx) await this.client.tx(collectionTx)
@ -72,7 +73,8 @@ export class WorkspaceClient {
objectClass: message.attachedToClass, objectClass: message.attachedToClass,
message: text, message: text,
attachments: 0, attachments: 0,
collection: 'replies' collection: 'replies',
provider: contact.channelProvider.Telegram
}) })
) )
await this.client.tx(collectionTx) await this.client.tx(collectionTx)