Skip to content

Commit

Permalink
Aftral[premieroctet#120]: add created conversation to ticket after it…
Browse files Browse the repository at this point in the history
…'s creation
  • Loading branch information
SeghirOumo committed Aug 28, 2024
1 parent 565a38f commit 8dbd810
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/web/server/plugins/aftral-lms/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const { getBlockDisliked } = require('./block')
const { setBlockLiked } = require('./block')
const { setBlockDisliked } = require('./block')
const Permission = require('../../models/Permission')
const Ticket = require('../../models/Ticket')
const Group = require('../../models/Group')
const HelpDeskConversation = require('../../models/HelpDeskConversation')
const SessionConversation = require('../../models/SessionConversation')
Expand Down Expand Up @@ -660,11 +661,15 @@ const postCreate = async ({model, params, data}) => {
}

if(model == `ticket`) {
await HelpDeskConversation.create({
const conv = await HelpDeskConversation.create({
ticket: data._id,
user: data.user,
block: data.block,
})
await Ticket.findOneAndUpdate(
{_id:data._id},
{conversation: conv._id}
)
}
}

Expand Down
4 changes: 4 additions & 0 deletions backend/web/server/plugins/aftral-lms/schemas/TicketSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const TicketSchema = new Schema({
type: String,
required: false,
},
conversation: {
type: Schema.Types.ObjectId,
ref: `helpDeskConversation`,
}
}, {...schemaOptions})

/* eslint-disable prefer-arrow-callback */
Expand Down

0 comments on commit 8dbd810

Please sign in to comment.