mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-07 00:09:34 +00:00
Fix create doc (#2672)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
117f9f291a
commit
dae9de4800
@ -45,10 +45,7 @@
|
|||||||
// date = new Date().getTime() + value.shift
|
// date = new Date().getTime() + value.shift
|
||||||
// }
|
// }
|
||||||
if (date === undefined) return
|
if (date === undefined) return
|
||||||
const _id = await client.createDoc(calendar.class.Event, space, {
|
const _id = await client.addCollection(calendar.class.Event, space, attachedTo, attachedToClass, 'reminders', {
|
||||||
attachedTo,
|
|
||||||
attachedToClass,
|
|
||||||
collection: 'reminders',
|
|
||||||
date,
|
date,
|
||||||
description: '',
|
description: '',
|
||||||
participants,
|
participants,
|
||||||
|
@ -36,13 +36,13 @@
|
|||||||
async function onMessage (event: CustomEvent) {
|
async function onMessage (event: CustomEvent) {
|
||||||
const { message, attachments } = event.detail
|
const { message, attachments } = event.detail
|
||||||
const me = getCurrentAccount()._id
|
const me = getCurrentAccount()._id
|
||||||
await client.createDoc<Message>(
|
await client.addCollection(
|
||||||
_class,
|
_class,
|
||||||
space,
|
space,
|
||||||
|
space,
|
||||||
|
chunter.class.ChunterSpace,
|
||||||
|
'messages',
|
||||||
{
|
{
|
||||||
attachedTo: space,
|
|
||||||
attachedToClass: chunter.class.ChunterSpace,
|
|
||||||
collection: 'messages',
|
|
||||||
content: message,
|
content: message,
|
||||||
createOn: Date.now(),
|
createOn: Date.now(),
|
||||||
createBy: me,
|
createBy: me,
|
||||||
@ -59,12 +59,9 @@
|
|||||||
chunterSpace.members
|
chunterSpace.members
|
||||||
.filter((accId) => accId !== me)
|
.filter((accId) => accId !== me)
|
||||||
.map((accId) =>
|
.map((accId) =>
|
||||||
client.createDoc(notification.class.LastView, space, {
|
client.addCollection(notification.class.LastView, space, space, chunterSpace._class, 'lastViews', {
|
||||||
user: accId,
|
user: accId,
|
||||||
lastView: 0,
|
lastView: 0
|
||||||
attachedTo: space,
|
|
||||||
attachedToClass: chunterSpace._class,
|
|
||||||
collection: 'lastViews'
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -195,13 +195,17 @@
|
|||||||
|
|
||||||
const reaction = reactions?.find((r) => r.emoji === emoji && r.createBy === me)
|
const reaction = reactions?.find((r) => r.emoji === emoji && r.createBy === me)
|
||||||
if (!reaction) {
|
if (!reaction) {
|
||||||
await client.createDoc(chunter.class.Reaction, message.space, {
|
await client.addCollection(
|
||||||
attachedTo: message._id,
|
chunter.class.Reaction,
|
||||||
attachedToClass: chunter.class.ChunterMessage,
|
message.space,
|
||||||
emoji,
|
message._id,
|
||||||
createBy: me,
|
chunter.class.ChunterMessage,
|
||||||
collection: 'reactions'
|
'reactions',
|
||||||
})
|
{
|
||||||
|
emoji,
|
||||||
|
createBy: me
|
||||||
|
}
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
await client.removeDoc(chunter.class.Reaction, message.space, reaction._id)
|
await client.removeDoc(chunter.class.Reaction, message.space, reaction._id)
|
||||||
}
|
}
|
||||||
|
@ -152,13 +152,13 @@
|
|||||||
async function onMessage (event: CustomEvent) {
|
async function onMessage (event: CustomEvent) {
|
||||||
const { message, attachments } = event.detail
|
const { message, attachments } = event.detail
|
||||||
const me = getCurrentAccount()._id
|
const me = getCurrentAccount()._id
|
||||||
await client.createDoc(
|
await client.addCollection(
|
||||||
chunter.class.ThreadMessage,
|
chunter.class.ThreadMessage,
|
||||||
currentSpace,
|
currentSpace,
|
||||||
|
_id,
|
||||||
|
chunter.class.Message,
|
||||||
|
'replies',
|
||||||
{
|
{
|
||||||
attachedTo: _id,
|
|
||||||
attachedToClass: chunter.class.Message,
|
|
||||||
collection: 'replies',
|
|
||||||
content: message,
|
content: message,
|
||||||
createBy: me,
|
createBy: me,
|
||||||
createOn: Date.now(),
|
createOn: Date.now(),
|
||||||
|
@ -41,10 +41,7 @@
|
|||||||
} else if (status && !newStatus) {
|
} else if (status && !newStatus) {
|
||||||
client.removeDoc(contact.class.Status, status.space, status._id)
|
client.removeDoc(contact.class.Status, status.space, status._id)
|
||||||
} else {
|
} else {
|
||||||
client.createDoc(contact.class.Status, employee!.space, {
|
client.addCollection(contact.class.Status, employee!.space, employeeId, contact.class.Employee, 'statuses', {
|
||||||
attachedTo: employeeId,
|
|
||||||
attachedToClass: contact.class.Employee,
|
|
||||||
collection: 'statuses',
|
|
||||||
name: newStatus.name,
|
name: newStatus.name,
|
||||||
dueDate: newStatus.dueDate
|
dueDate: newStatus.dueDate
|
||||||
})
|
})
|
||||||
|
@ -62,7 +62,8 @@
|
|||||||
async function createCustomer () {
|
async function createCustomer () {
|
||||||
const candidate: Data<Contact> = {
|
const candidate: Data<Contact> = {
|
||||||
name: formatName(targetClass._id, firstName, lastName, object.name),
|
name: formatName(targetClass._id, firstName, lastName, object.name),
|
||||||
city: object.city
|
city: object.city,
|
||||||
|
createOn: Date.now()
|
||||||
}
|
}
|
||||||
if (avatar !== undefined) {
|
if (avatar !== undefined) {
|
||||||
candidate.avatar = await avatarEditor.createAvatar()
|
candidate.avatar = await avatarEditor.createAvatar()
|
||||||
|
@ -129,16 +129,16 @@
|
|||||||
async function onMessage (event: CustomEvent) {
|
async function onMessage (event: CustomEvent) {
|
||||||
if (channel === undefined) return
|
if (channel === undefined) return
|
||||||
const { message, attachments } = event.detail
|
const { message, attachments } = event.detail
|
||||||
await client.createDoc(
|
await client.addCollection(
|
||||||
telegram.class.NewMessage,
|
telegram.class.NewMessage,
|
||||||
telegram.space.Telegram,
|
telegram.space.Telegram,
|
||||||
|
channel._id,
|
||||||
|
channel._class,
|
||||||
|
'newMessages',
|
||||||
{
|
{
|
||||||
content: message,
|
content: message,
|
||||||
status: 'new',
|
status: 'new',
|
||||||
attachments,
|
attachments
|
||||||
attachedTo: channel._id,
|
|
||||||
attachedToClass: channel._class,
|
|
||||||
collection: 'newMessages'
|
|
||||||
},
|
},
|
||||||
objectId
|
objectId
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user