Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
check empty meeting title
Browse files Browse the repository at this point in the history
  • Loading branch information
enkhtuvshinD committed Oct 17, 2023
1 parent 4d35cca commit 52f563b
Showing 1 changed file with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import { IContext } from '../../../messageBroker';
import { IContext, sendCommonMessage } from '../../../messageBroker';

const meetingMutations = {
// /**
// * Creates a new meetings
// */
async meetingAdd(_root, doc, { models, user }: IContext) {
const { participantIds } = doc;
async meetingAdd(_root, doc, { models, subdomain, user }: IContext) {
const { participantIds, companyId, title } = doc;

if (!title && companyId) {
const company = await sendCommonMessage({
subdomain,
serviceName: 'contacts',
action: 'companies.findOne',
data: {
_id: companyId
},
isRPC: true
});

if (company) {
doc.title = company.primaryName;
} else {
throw new Error('Company not found');
}
}
const allParticipantIds =
participantIds && participantIds.includes(user._id)
? participantIds
Expand All @@ -16,7 +34,25 @@ const meetingMutations = {
// /**
// * Edits a meetings
// */
async meetingEdit(_root, doc, { models, user }: IContext) {
async meetingEdit(_root, doc, { models, subdomain, user }: IContext) {
const { companyId, title } = doc;
if (!title && companyId) {
const company = await sendCommonMessage({
subdomain,
serviceName: 'contacts',
action: 'companies.findOne',
data: {
_id: companyId
},
isRPC: true
});

if (company) {
doc.title = company.primaryName;
} else {
throw new Error('Company not found');
}
}
return models.Meetings.updateMeeting(doc, user);
},
/**
Expand Down

0 comments on commit 52f563b

Please sign in to comment.