Skip to content

Commit

Permalink
fix: setting conversation name instead of subject
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin.jaroschewski committed Jul 4, 2024
1 parent 72a878b commit c0da926
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions src/calendarIntegration/addMeetingLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,20 @@ async function fetchCustomProperties(): Promise<void> {
}

/**
* Creates a new subject for the mailbox item by getting the meeting date and appending it to the existing subject.
* Modifies the conversation subject by appending the meeting date.
*
* @return {Promise<void>} A promise that resolves when the new subject is set on the mailbox item.
* @param {string} conversationSubject - The current subject of the conversation.
* @return {Promise<string>} The modified conversation subject.
*/
async function createSubject() {
const getMeetingDate = await getMeetingTime(mailboxItem);
const subject = `CLDR::${getMeetingDate}`;
async function modifyConversationName(conversationSubject: string): Promise<string> {
const meetingDate = await getMeetingTime(mailboxItem);

await setSubject(mailboxItem, subject);
}

/**
* Appends the meeting date to the current subject of the mailbox item.
*
* @param {string} currentSubject - The current subject of the mailbox item.
* @return {Promise<void>} A promise that resolves when the subject is appended.
*/
async function appendSubject(currentSubject:string){
const getMeetingDate = await getMeetingTime(mailboxItem);
const newSubject = `${currentSubject} - CLDR::${getMeetingDate}`;
const modifiedSubject = conversationSubject ? `CLDR:: ${conversationSubject}` : `CLDR:: ${meetingDate}`;

await setSubject(mailboxItem, newSubject);
return modifiedSubject;
}


/**
* Creates a new meeting by calling the createEvent function with a subject obtained from the mailboxItem.
* If the eventResult is not null, it sets the createdMeeting object to eventResult, updates the meeting details,
Expand All @@ -87,13 +77,13 @@ async function createNewMeeting(): Promise<void> {
Office.MailboxEnums.ItemNotificationMessageType.ProgressIndicator
);

const subject = await getMailboxItemSubject(mailboxItem);
let subject = await getMailboxItemSubject(mailboxItem);
subject = await modifyConversationName(subject);

const eventResult = await createEvent(subject || defaultSubjectValue);

if (eventResult) {
createdMeeting = eventResult;
subject ? appendSubject(subject) : createSubject();
await updateMeetingDetails(eventResult);
await setCustomPropertyAsync(mailboxItem, "wireId", eventResult.id);
await setCustomPropertyAsync(mailboxItem, "wireLink", eventResult.link);
Expand Down Expand Up @@ -135,11 +125,6 @@ async function handleExistingMeeting(): Promise<void> {

getOrganizer(mailboxItem, async (organizer) => {

//Check if subject is empty
if(!currentSubject.includes("CLDR::")){
currentSubject ? appendSubject(currentSubject) : createSubject();
}

//Check if location is empty
if (!currentLocation) {
await setLocation(mailboxItem, createdMeeting.link);
Expand Down

0 comments on commit c0da926

Please sign in to comment.