From 9c67f0ed51200aaf6cf0cd85fc4fcf5e18ae03f0 Mon Sep 17 00:00:00 2001 From: brf153 <153hsb@gmail.com> Date: Fri, 19 Jan 2024 18:53:43 +0530 Subject: [PATCH 1/9] feat:removed emojis from the app Signed-off-by: brf153 <153hsb@gmail.com> --- README.md | 6 +++--- enum/OAuth2.ts | 4 ++-- enum/messages.ts | 20 ++++++++++---------- i18n/en.json | 6 +++--- src/authorization/OAuth2Client.ts | 4 ++-- src/endpoints/webhook.ts | 2 +- src/handlers/ExecuteViewSubmitHandler.ts | 14 +++++++------- src/helper/getConnectLayout.ts | 4 ++-- src/lib/NotionSDK.ts | 4 ++-- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 0d5e1df..1c4afbf 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Where RocketChat and Notion work together seamlessly to fuel your team's success ``` - 👋 Need some help with /notion? + Need some help with /notion? • use `/notion connect` to connect your workspace • use `/notion disconnect` to disconnect workspace @@ -117,7 +117,7 @@ Where RocketChat and Notion work together seamlessly to fuel your team's success ``` -## ✨ Glimpse : +## Glimpse : [Video Demo Day](https://www.youtube.com/watch?v=G1fZBqy5jp8) @@ -136,7 +136,7 @@ Don't forget to give the project a star! Thanks again! 4. Push to the Branch (`git push origin feat/AmazingFeature`) 5. Open a Pull Request -## 📚 Resources +## Resources Here are some links to examples and documentation: diff --git a/enum/OAuth2.ts b/enum/OAuth2.ts index 369fd67..3b395af 100644 --- a/enum/OAuth2.ts +++ b/enum/OAuth2.ts @@ -8,8 +8,8 @@ export enum OAuth2Locator { export enum OAuth2Content { success = "https://github-production-user-asset-6210df.s3.amazonaws.com/65061890/243671111-9964efff-3b23-4223-aadd-5f4be441037c.svg", failed = "https://open.rocket.chat/assets/logo.png", - NOT_CONNECTED_MESSAGE = `👋 You are not connected to **Workspace**!`, - NOT_CONNECTED_MESSAGE_WITH_INFO = `👋 Connect to workspace to access \`pages\` & \`database\``, + NOT_CONNECTED_MESSAGE = `You are not connected to **Workspace**!`, + NOT_CONNECTED_MESSAGE_WITH_INFO = `Connect to workspace to access \`pages\` & \`database\``, CONNECT_TO_WORKSPACE = "Connect to Workspace", CREDENTIALS_MISSING_USER = `🚫 Something Went Wrong, Please Contact the Admin!`, CREDENTIALS_MISSING_ADMIN = `Please Configure the App and Ensure the \`SiteUrl\` is correct in the Server Settings. diff --git a/enum/messages.ts b/enum/messages.ts index 33a6b86..8f27952 100644 --- a/enum/messages.ts +++ b/enum/messages.ts @@ -8,21 +8,21 @@ export enum Messages { • use \`/notion share\` to share pages `, - HELPER_TEXT = `:wave: Need some help with \`/notion\`?`, + HELPER_TEXT = `Need some help with \`/notion\`?`, } export enum OnInstallContent { - PREVIEW_TITLE = "[**📖 Notion App**](https://github.com/RocketChat/Apps.Notion/)", - PREVIEW_DESCRIPTION = "**🙌 Installed and Rollin' on your Server!**", - PREVIEW_CONTEXT = "[**🤝 Support's Page**](https://github.com/RocketChat/Apps.Notion/issues)", + PREVIEW_TITLE = "[**Notion App**](https://github.com/RocketChat/Apps.Notion/)", + PREVIEW_DESCRIPTION = "**Installed and Rollin' on your Server!**", + PREVIEW_CONTEXT = "[**Support's Page**](https://github.com/RocketChat/Apps.Notion/issues)", PREVIEW_IMAGE = "https://upload.wikimedia.org/wikipedia/commons/e/e9/Notion-logo.svg", - WELCOMING_MESSAGE = `🔧 Setting up the Notion App is a breeze! Create a [**Notion Public Integration**](https://developers.notion.com/docs/authorization#how-to-make-an-integration-public) and Just head over to the App Settings, Provide your credentials. - 🎉 You're all set to experience the seamless integration of Notion and RocketChat. - ✨ Need some help getting started? Just type \`/notion help\` to access our comprehensive command list. - 💌 We love hearing from you! If you have any suggestions, questions, or just want to share your thoughts, simply tap on the **Support's Page** in Preview. - 🌟 Let's streamline your productivity and collaboration together. Enjoy the journey! + WELCOMING_MESSAGE = `Setting up the Notion App is a breeze! Create a [**Notion Public Integration**](https://developers.notion.com/docs/authorization#how-to-make-an-integration-public) and Just head over to the App Settings, Provide your credentials. + You're all set to experience the seamless integration of Notion and RocketChat. + Need some help getting started? Just type \`/notion help\` to access our comprehensive command list. + We love hearing from you! If you have any suggestions, questions, or just want to share your thoughts, simply tap on the **Support's Page** in Preview. + Let's streamline your productivity and collaboration together. Enjoy the journey! Thanks for choosing \`Notion App\` `, - WELCOME_TEXT = `Welcome to **Notion App** in RocketChat! 🙌`, + WELCOME_TEXT = `Welcome to **Notion App** in RocketChat! `, } diff --git a/i18n/en.json b/i18n/en.json index df5eb48..bd7acfe 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -6,7 +6,7 @@ "CredentialsSettings": "Authorization Settings", "NotionCommandParams": "connect | disconnect | workspace | create | schema | comment", "NotionCommandDescription": "Create Notion pages and database from Rocket.Chat", - "CommentOnPagesLabel": "💬 Comment on Page", - "SendToPageLabel": "📝 Send to Page", - "SendToNewPageLabel": "📢 Send to New Page" + "CommentOnPagesLabel": "Comment on Page", + "SendToPageLabel": "Send to Page", + "SendToNewPageLabel": "Send to New Page" } diff --git a/src/authorization/OAuth2Client.ts b/src/authorization/OAuth2Client.ts index 8c7581e..4bbd4ed 100644 --- a/src/authorization/OAuth2Client.ts +++ b/src/authorization/OAuth2Client.ts @@ -37,7 +37,7 @@ export class OAuth2Client implements IOAuth2Client { return; } - const message = `Hey **${sender.username}**!👋 Connect your Notion Workspace`; + const message = `Hey **${sender.username}**! Connect your Notion Workspace`; const blocks = await getConnectBlock( this.app, message, @@ -66,7 +66,7 @@ export class OAuth2Client implements IOAuth2Client { if (tokenInfo) { await oAuthStorage.disconnectUserFromCurrentWorkspace(userId); - const message = `👋 You are disconnected from the Workspace **${tokenInfo.workspace_name}**`; + const message = `You are disconnected from the Workspace **${tokenInfo.workspace_name}**`; await sendNotification(read, modify, sender, room, { message }); return; } diff --git a/src/endpoints/webhook.ts b/src/endpoints/webhook.ts index 92c2ef0..c317744 100644 --- a/src/endpoints/webhook.ts +++ b/src/endpoints/webhook.ts @@ -113,7 +113,7 @@ export class WebHookEndpoint extends ApiEndpoint { const successTemplate = getAuthPageTemplate( "Connected to Workspace", OAuth2Content.success, - `👋 Connected to ${response.workspace_name}❗`, + `Connected to ${response.workspace_name}❗`, "YOU CAN NOW CLOSE THIS WINDOW" ); diff --git a/src/handlers/ExecuteViewSubmitHandler.ts b/src/handlers/ExecuteViewSubmitHandler.ts index cb2f2d5..1f3b51b 100644 --- a/src/handlers/ExecuteViewSubmitHandler.ts +++ b/src/handlers/ExecuteViewSubmitHandler.ts @@ -226,7 +226,7 @@ export class ExecuteViewSubmitHandler { } else { const name: string = response.name; const link: string = response.link; - message = `✨ Your Database [**${name}**](${link}) is created successfully in **${workspace_name}**.`; + message = `Your Database [**${name}**](${link}) is created successfully in **${workspace_name}**.`; await sendNotificationWithAttachments( this.read, @@ -387,7 +387,7 @@ export class ExecuteViewSubmitHandler { message = `🚫 Something went wrong while creating page in **${workspace_name}**.`; } else { const { name, link, title, pageId } = createdPage; - message = `✨ Your Page [**${title}**](${link}) is created successfully as a subpage in **${name}**.`; + message = `Your Page [**${title}**](${link}) is created successfully as a subpage in **${name}**.`; const preserveMessage = await modalInteraction.getInputElementState( ActionButton.SEND_TO_NEW_PAGE_MESSAGE_ACTION @@ -430,7 +430,7 @@ export class ExecuteViewSubmitHandler { )) as ICredential; const messageLink = `${siteUrl}/${urlPath}/${displayName}?msg=${id}`; - const preserveText = `📝 Created New Page [**${title}**](${link}) and Preserved Following [Message](${messageLink}) `; + const preserveText = `Created New Page [**${title}**](${link}) and Preserved Following [Message](${messageLink}) `; await sendMessage( this.read, @@ -501,7 +501,7 @@ export class ExecuteViewSubmitHandler { ]; const { fields, url, pageId } = createdRecord; - message = `✨ Created [**${title}**](${url}) in [**${databasename}**](${databaselink})`; + message = `Created [**${title}**](${url}) in [**${databasename}**](${databaselink})`; const messageId = await sendMessageWithAttachments( this.read, @@ -554,7 +554,7 @@ export class ExecuteViewSubmitHandler { )) as ICredential; const messageLink = `${siteUrl}/${urlPath}/${displayName}?msg=${id}`; - const preserveText = `📝 Created [**${title}**](${url}) Page and Preserved Following [Message](${messageLink}) `; + const preserveText = `Created [**${title}**](${url}) Page and Preserved Following [Message](${messageLink}) `; await sendMessage( this.read, @@ -814,7 +814,7 @@ export class ExecuteViewSubmitHandler { const { name, parent, url } = pageInfo; - const message = `✨ Sharing [**${name}**](${url}) from **${workspace_name}**`; + const message = `Sharing [**${name}**](${url}) from **${workspace_name}**`; await sendMessage(this.read, this.modify, user, room, { message, @@ -913,7 +913,7 @@ export class ExecuteViewSubmitHandler { )) as ICredential; const messageLink = `${siteUrl}/${urlPath}/${displayName}?msg=${id}`; - const preserveText = `📝 Preserved Following [Message](${messageLink}) in [**${name}**](${url}) `; + const preserveText = `Preserved Following [Message](${messageLink}) in [**${name}**](${url}) `; await sendMessage( this.read, diff --git a/src/helper/getConnectLayout.ts b/src/helper/getConnectLayout.ts index 85b1e64..ad9b9f3 100644 --- a/src/helper/getConnectLayout.ts +++ b/src/helper/getConnectLayout.ts @@ -21,8 +21,8 @@ export function getConnectPreview( : undefined; const thumb = workspace_icon_url ? { url: workspace_icon_url } : undefined; const title = [ - `**📚 [**${workspace_name}**](${Notion.WEBSITE_URL})**`, - "**👋 Connected to Workspace**", + `** [**${workspace_name}**](${Notion.WEBSITE_URL})**`, + "**Connected to Workspace**", ]; const description = [""]; const avatarElement = elementBuilder.addImage({ diff --git a/src/lib/NotionSDK.ts b/src/lib/NotionSDK.ts index 618033a..4575f4d 100644 --- a/src/lib/NotionSDK.ts +++ b/src/lib/NotionSDK.ts @@ -180,7 +180,7 @@ export class NotionSDK implements INotionSDK { private returnPage(name: string, page_id: string): IPage { return { - name: `📄 ${name}`, + name: `${name}`, parent: { type: NotionObjectTypes.PAGE_ID, page_id, @@ -549,7 +549,7 @@ export class NotionSDK implements INotionSDK { return { info: { - name: `📚 ${name}`, + name: ` ${name}`, link: item?.url, }, parent: { From 7f752058595b294d1f6e7f4071d93fce1f51ea97 Mon Sep 17 00:00:00 2001 From: brf153 <153hsb@gmail.com> Date: Fri, 19 Jan 2024 20:11:35 +0530 Subject: [PATCH 2/9] feat:added conditional rendering of emojis for page and database Signed-off-by: brf153 <153hsb@gmail.com> --- src/lib/NotionSDK.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/lib/NotionSDK.ts b/src/lib/NotionSDK.ts index 4575f4d..4d919da 100644 --- a/src/lib/NotionSDK.ts +++ b/src/lib/NotionSDK.ts @@ -120,7 +120,7 @@ export class NotionSDK implements INotionSDK { const result: Array = []; results.forEach(async (item) => { - const pageObject = await this.getPageObjectFromResults(item); + const pageObject = await this.getPageObjectFromResults(item, false); if (pageObject) { result.push(pageObject); } @@ -132,7 +132,7 @@ export class NotionSDK implements INotionSDK { } } - private async getPageObjectFromResults(item): Promise { + private async getPageObjectFromResults(item, emoji): Promise { const typesWithTitleProperty = [ NotionObjectTypes.WORKSPACE.toString(), NotionObjectTypes.PAGE_ID.toString(), @@ -145,7 +145,7 @@ export class NotionSDK implements INotionSDK { const pageName: string = properties.title.title[0]?.text?.content || NotionObjectTypes.UNTITLED; - return this.returnPage(pageName, pageId); + return this.returnPage(pageName, pageId, emoji); } // title property either be at first or last position @@ -161,7 +161,7 @@ export class NotionSDK implements INotionSDK { const name: string = properties[firstColumn].title[0]?.text?.content || NotionObjectTypes.UNTITLED; - return this.returnPage(name, pageId); + return this.returnPage(name, pageId, emoji); } //title at last position and has subpage @@ -172,15 +172,15 @@ export class NotionSDK implements INotionSDK { const name: string = properties[lastColumn].title[0]?.text?.content || NotionObjectTypes.UNTITLED; - return this.returnPage(name, pageId); + return this.returnPage(name, pageId, emoji); } return null; } - private returnPage(name: string, page_id: string): IPage { + private returnPage(name: string, page_id: string, emoji: boolean): IPage { return { - name: `${name}`, + name: `${emoji ? "📄" : ""} ${name}`, parent: { type: NotionObjectTypes.PAGE_ID, page_id, @@ -520,7 +520,8 @@ export class NotionSDK implements INotionSDK { const objectType: string = item?.[NotionObjectTypes.OBJECT]; if (objectType.includes(NotionObjectTypes.PAGE)) { const pageObject = await this.getPageObjectFromResults( - item + item, + true ); if (pageObject) { @@ -528,7 +529,7 @@ export class NotionSDK implements INotionSDK { } } else { const databaseObject = - await this.getDatabaseObjectFromResults(item); + await this.getDatabaseObjectFromResults(item, true); result.push(databaseObject); } @@ -540,7 +541,7 @@ export class NotionSDK implements INotionSDK { } } - private async getDatabaseObjectFromResults(item): Promise { + private async getDatabaseObjectFromResults(item, emoji:boolean): Promise { const databaseNameTitleObject = item?.[NotionObjectTypes.TITLE]; const name: string = databaseNameTitleObject.length ? databaseNameTitleObject[0]?.plain_text @@ -549,7 +550,7 @@ export class NotionSDK implements INotionSDK { return { info: { - name: ` ${name}`, + name: `${emoji ? "📚":""} ${name}`, link: item?.url, }, parent: { @@ -989,7 +990,8 @@ export class NotionSDK implements INotionSDK { const pageInfo = response.data; const page = (await this.getPageObjectFromResults( - pageInfo + pageInfo, + false )) as IPage; const url: string = pageInfo?.url; @@ -1089,7 +1091,8 @@ export class NotionSDK implements INotionSDK { results.forEach(async (item) => { const objectType: string = item?.[NotionObjectTypes.OBJECT]; const databaseObject = await this.getDatabaseObjectFromResults( - item + item, + false ); result.push(databaseObject); From da8f382ba145efdd215b94be144bd60fa9de97cf Mon Sep 17 00:00:00 2001 From: brf153 <153hsb@gmail.com> Date: Tue, 23 Jan 2024 12:16:07 +0530 Subject: [PATCH 3/9] =?UTF-8?q?fix:removed=20the=20=F0=9F=9A=AB=20emoji=20?= =?UTF-8?q?along=20with=20page=20and=20database=20emoji=20from=20IPage=20a?= =?UTF-8?q?nd=20IDatabase=20in=20createPage=20and=20createRecord?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: brf153 <153hsb@gmail.com> --- enum/OAuth2.ts | 2 +- src/endpoints/webhook.ts | 2 +- src/handlers/ExecuteViewSubmitHandler.ts | 32 +++++++++++++++++------- src/lib/NotionSDK.ts | 5 ++-- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/enum/OAuth2.ts b/enum/OAuth2.ts index 3b395af..641be14 100644 --- a/enum/OAuth2.ts +++ b/enum/OAuth2.ts @@ -11,7 +11,7 @@ export enum OAuth2Content { NOT_CONNECTED_MESSAGE = `You are not connected to **Workspace**!`, NOT_CONNECTED_MESSAGE_WITH_INFO = `Connect to workspace to access \`pages\` & \`database\``, CONNECT_TO_WORKSPACE = "Connect to Workspace", - CREDENTIALS_MISSING_USER = `🚫 Something Went Wrong, Please Contact the Admin!`, + CREDENTIALS_MISSING_USER = `Something Went Wrong, Please Contact the Admin!`, CREDENTIALS_MISSING_ADMIN = `Please Configure the App and Ensure the \`SiteUrl\` is correct in the Server Settings. \xa0\xa0• Go to **NotionApp** Settings and add \`ClientId\` and \`ClientSecret\` Generated from a Notion Public Integration `, diff --git a/src/endpoints/webhook.ts b/src/endpoints/webhook.ts index c317744..92c2ef0 100644 --- a/src/endpoints/webhook.ts +++ b/src/endpoints/webhook.ts @@ -113,7 +113,7 @@ export class WebHookEndpoint extends ApiEndpoint { const successTemplate = getAuthPageTemplate( "Connected to Workspace", OAuth2Content.success, - `Connected to ${response.workspace_name}❗`, + `👋 Connected to ${response.workspace_name}❗`, "YOU CAN NOW CLOSE THIS WINDOW" ); diff --git a/src/handlers/ExecuteViewSubmitHandler.ts b/src/handlers/ExecuteViewSubmitHandler.ts index 1f3b51b..c6da466 100644 --- a/src/handlers/ExecuteViewSubmitHandler.ts +++ b/src/handlers/ExecuteViewSubmitHandler.ts @@ -218,7 +218,7 @@ export class ExecuteViewSubmitHandler { if (response instanceof Error) { this.app.getLogger().error(response); - message = `🚫 Something went wrong while creating Database in **${workspace_name}**.`; + message = `Something went wrong while creating Database in **${workspace_name}**.`; await sendNotification(this.read, this.modify, user, room, { message: message, @@ -341,6 +341,7 @@ export class ExecuteViewSubmitHandler { const parentType: string = parent.type; if (parentType.includes(NotionObjectTypes.PAGE_ID)) { + console.log("handleCreationofPage ", Objects) return this.handleCreationOfPage( tokenInfo, room, @@ -349,7 +350,13 @@ export class ExecuteViewSubmitHandler { Objects as IPage ); } - + console.log("handleCreationofRecord ", Objects) + // const newObjects = { + // ...Objects, + // info: { + // name: Objects.info.name + // }, + // } return this.handleCreationOfRecord( tokenInfo, room, @@ -384,7 +391,7 @@ export class ExecuteViewSubmitHandler { if (createdPage instanceof Error) { this.app.getLogger().error(createdPage.message); - message = `🚫 Something went wrong while creating page in **${workspace_name}**.`; + message = `Something went wrong while creating page in **${workspace_name}**.`; } else { const { name, link, title, pageId } = createdPage; message = `Your Page [**${title}**](${link}) is created successfully as a subpage in **${name}**.`; @@ -410,7 +417,7 @@ export class ExecuteViewSubmitHandler { if (appendBlock instanceof Error) { this.app.getLogger().error(appendBlock.message); - message = `🚫 Something went wrong while appending message in **${workspace_name}**.`; + message = `Something went wrong while appending message in **${workspace_name}**.`; await sendNotification(this.read, this.modify, user, room, { message, }); @@ -463,6 +470,13 @@ export class ExecuteViewSubmitHandler { const { NotionSdk } = this.app.getUtils(); const { access_token, workspace_name, owner } = tokenInfo; const username = owner.user.name; + const newDatabase = { + ...database, + info: { + name: database.info.name.replace("📚 ",""), + link: database.info.link, + }, + } const properties = (await modalInteraction.getInputElementState( SearchPageAndDatabase.ACTION_ID @@ -479,7 +493,7 @@ export class ExecuteViewSubmitHandler { const createdRecord = await NotionSdk.createRecord( access_token, - database, + newDatabase, data ); @@ -487,12 +501,12 @@ export class ExecuteViewSubmitHandler { if (createdRecord instanceof Error) { this.app.getLogger().error(createdRecord.message); - message = `🚫 Something went wrong while creating record in **${workspace_name}**.`; + message = `Something went wrong while creating record in **${workspace_name}**.`; await sendNotification(this.read, this.modify, user, room, { message, }); } else { - const { info } = database; + const { info } = newDatabase; const databasename = info.name; const databaselink = info.link; const title: string = @@ -533,7 +547,7 @@ export class ExecuteViewSubmitHandler { if (appendBlock instanceof Error) { this.app.getLogger().error(appendBlock.message); - message = `🚫 Something went wrong while appending message in **${workspace_name}**.`; + message = `Something went wrong while appending message in **${workspace_name}**.`; await sendNotification(this.read, this.modify, user, room, { message, }); @@ -878,7 +892,7 @@ export class ExecuteViewSubmitHandler { if (appendBlock instanceof Error) { this.app.getLogger().error(appendBlock.message); - const message = `🚫 Something went wrong while appending message in **${workspace_name}**.`; + const message = `Something went wrong while appending message in **${workspace_name}**.`; await sendNotification(this.read, this.modify, user, room, { message, }); diff --git a/src/lib/NotionSDK.ts b/src/lib/NotionSDK.ts index 4d919da..16a904b 100644 --- a/src/lib/NotionSDK.ts +++ b/src/lib/NotionSDK.ts @@ -568,7 +568,8 @@ export class NotionSDK implements INotionSDK { try { const { name, parent } = page; const { title } = prop; - + const nameWithoutEmoji = name.replace("📄", ""); + console.log("name", nameWithoutEmoji , "title", title, "parent", parent) const data = { parent, properties: { @@ -598,7 +599,7 @@ export class NotionSDK implements INotionSDK { let result: INotionPage = { link: response?.data?.url, - name, + name: nameWithoutEmoji, title, }; From af9031522c39f3a07881be6ef3ebb9838ef2f4f6 Mon Sep 17 00:00:00 2001 From: brf153 <153hsb@gmail.com> Date: Tue, 23 Jan 2024 12:20:16 +0530 Subject: [PATCH 4/9] fix:set default value of emoji to false Signed-off-by: brf153 <153hsb@gmail.com> --- src/lib/NotionSDK.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/NotionSDK.ts b/src/lib/NotionSDK.ts index 16a904b..f8510e8 100644 --- a/src/lib/NotionSDK.ts +++ b/src/lib/NotionSDK.ts @@ -132,7 +132,7 @@ export class NotionSDK implements INotionSDK { } } - private async getPageObjectFromResults(item, emoji): Promise { + private async getPageObjectFromResults(item, emoji:boolean=false): Promise { const typesWithTitleProperty = [ NotionObjectTypes.WORKSPACE.toString(), NotionObjectTypes.PAGE_ID.toString(), @@ -178,7 +178,7 @@ export class NotionSDK implements INotionSDK { return null; } - private returnPage(name: string, page_id: string, emoji: boolean): IPage { + private returnPage(name: string, page_id: string, emoji: boolean=false): IPage { return { name: `${emoji ? "📄" : ""} ${name}`, parent: { @@ -541,7 +541,7 @@ export class NotionSDK implements INotionSDK { } } - private async getDatabaseObjectFromResults(item, emoji:boolean): Promise { + private async getDatabaseObjectFromResults(item, emoji:boolean=false): Promise { const databaseNameTitleObject = item?.[NotionObjectTypes.TITLE]; const name: string = databaseNameTitleObject.length ? databaseNameTitleObject[0]?.plain_text From 2a4ca7a953d097f0cdb15a4e6160d279363e2a83 Mon Sep 17 00:00:00 2001 From: brf153 <153hsb@gmail.com> Date: Tue, 23 Jan 2024 12:21:15 +0530 Subject: [PATCH 5/9] code cleaned Signed-off-by: brf153 <153hsb@gmail.com> --- src/handlers/ExecuteViewSubmitHandler.ts | 10 ++-------- src/lib/NotionSDK.ts | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/handlers/ExecuteViewSubmitHandler.ts b/src/handlers/ExecuteViewSubmitHandler.ts index c6da466..da9ca2d 100644 --- a/src/handlers/ExecuteViewSubmitHandler.ts +++ b/src/handlers/ExecuteViewSubmitHandler.ts @@ -341,7 +341,7 @@ export class ExecuteViewSubmitHandler { const parentType: string = parent.type; if (parentType.includes(NotionObjectTypes.PAGE_ID)) { - console.log("handleCreationofPage ", Objects) + return this.handleCreationOfPage( tokenInfo, room, @@ -350,13 +350,7 @@ export class ExecuteViewSubmitHandler { Objects as IPage ); } - console.log("handleCreationofRecord ", Objects) - // const newObjects = { - // ...Objects, - // info: { - // name: Objects.info.name - // }, - // } + return this.handleCreationOfRecord( tokenInfo, room, diff --git a/src/lib/NotionSDK.ts b/src/lib/NotionSDK.ts index f8510e8..6bfa493 100644 --- a/src/lib/NotionSDK.ts +++ b/src/lib/NotionSDK.ts @@ -569,7 +569,7 @@ export class NotionSDK implements INotionSDK { const { name, parent } = page; const { title } = prop; const nameWithoutEmoji = name.replace("📄", ""); - console.log("name", nameWithoutEmoji , "title", title, "parent", parent) + const data = { parent, properties: { From eed2116d17dd429124fd8b4aa776994fc81d6ab8 Mon Sep 17 00:00:00 2001 From: brf153 <153hsb@gmail.com> Date: Tue, 23 Jan 2024 12:25:15 +0530 Subject: [PATCH 6/9] fix:added emojis to the readme Signed-off-by: brf153 <153hsb@gmail.com> --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1c4afbf..680d325 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Where RocketChat and Notion work together seamlessly to fuel your team's success ``` - Need some help with /notion? + 👋 Need some help with /notion? • use `/notion connect` to connect your workspace • use `/notion disconnect` to disconnect workspace @@ -117,7 +117,7 @@ Where RocketChat and Notion work together seamlessly to fuel your team's success ``` -## Glimpse : +## ✨ Glimpse : [Video Demo Day](https://www.youtube.com/watch?v=G1fZBqy5jp8) @@ -136,7 +136,7 @@ Don't forget to give the project a star! Thanks again! 4. Push to the Branch (`git push origin feat/AmazingFeature`) 5. Open a Pull Request -## Resources +## 📚 Resources Here are some links to examples and documentation: @@ -163,4 +163,4 @@ Here are some links to examples and documentation: [issues-shield]: https://img.shields.io/github/issues/RocketChat/Apps.Notion?style=for-the-badge [issues-url]: https://github.com/RocketChat/Apps.Notion/issues [license-shield]: https://img.shields.io/github/license/RocketChat/Apps.Notion?style=for-the-badge -[license-url]: https://github.com/RocketChat/Apps.Notion/blob/master/LICENSE.txt +[license-url]: https://github.com/RocketChat/Apps.Notion/blob/master/LICENSE.txt \ No newline at end of file From 56b7798fa1b9e1592600dae9e2e8ffb028c4704e Mon Sep 17 00:00:00 2001 From: brf153 <153hsb@gmail.com> Date: Tue, 23 Jan 2024 14:38:50 +0530 Subject: [PATCH 7/9] feat:removed emojis from getSelectDatabaseLayout Signed-off-by: brf153 <153hsb@gmail.com> --- src/helper/getSelectDatabaseLayout.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helper/getSelectDatabaseLayout.ts b/src/helper/getSelectDatabaseLayout.ts index cb142cc..2ab9dc6 100644 --- a/src/helper/getSelectDatabaseLayout.ts +++ b/src/helper/getSelectDatabaseLayout.ts @@ -15,6 +15,7 @@ export function getSelectDatabaseLayout( const database_name = properties.name; const database_url = properties.link; + const databaseNameWithoutEmoji = database_name.replace("📚 ", "") const elementBuilder = new ElementBuilder(appId); const blockBuilder = new BlockBuilder(appId); @@ -26,8 +27,8 @@ export function getSelectDatabaseLayout( : undefined; const thumb = workspace_icon_url ? { url: workspace_icon_url } : undefined; const title = [ - `**📋 Database Name**`, - `[**${database_name}**](${database_url})`, + `**Database Name**`, + `[**${databaseNameWithoutEmoji}**](${database_url})`, ]; const description = [""]; const avatarElement = elementBuilder.addImage({ From b7b34b77e33406f542caec51d7f8bf166681a9cf Mon Sep 17 00:00:00 2001 From: brf153 <153hsb@gmail.com> Date: Thu, 25 Jan 2024 13:29:52 +0530 Subject: [PATCH 8/9] enhance: added required changes Signed-off-by: brf153 <153hsb@gmail.com> --- src/handlers/ExecuteViewSubmitHandler.ts | 14 ++++---------- src/helper/getSelectDatabaseLayout.ts | 5 ++--- src/lib/NotionSDK.ts | 18 ++++++++---------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/handlers/ExecuteViewSubmitHandler.ts b/src/handlers/ExecuteViewSubmitHandler.ts index da9ca2d..56ee184 100644 --- a/src/handlers/ExecuteViewSubmitHandler.ts +++ b/src/handlers/ExecuteViewSubmitHandler.ts @@ -464,13 +464,6 @@ export class ExecuteViewSubmitHandler { const { NotionSdk } = this.app.getUtils(); const { access_token, workspace_name, owner } = tokenInfo; const username = owner.user.name; - const newDatabase = { - ...database, - info: { - name: database.info.name.replace("📚 ",""), - link: database.info.link, - }, - } const properties = (await modalInteraction.getInputElementState( SearchPageAndDatabase.ACTION_ID @@ -487,7 +480,7 @@ export class ExecuteViewSubmitHandler { const createdRecord = await NotionSdk.createRecord( access_token, - newDatabase, + database, data ); @@ -500,8 +493,9 @@ export class ExecuteViewSubmitHandler { message, }); } else { - const { info } = newDatabase; - const databasename = info.name; + const { info } = database; + const databasename = info.name.replace("📚 ", ""); + console.log("databaseName ", databasename) const databaselink = info.link; const title: string = state?.[NotionPageOrRecord.TITLE_BLOCK]?.[ diff --git a/src/helper/getSelectDatabaseLayout.ts b/src/helper/getSelectDatabaseLayout.ts index 2ab9dc6..0e43253 100644 --- a/src/helper/getSelectDatabaseLayout.ts +++ b/src/helper/getSelectDatabaseLayout.ts @@ -13,9 +13,8 @@ export function getSelectDatabaseLayout( const { workspace_icon, owner } = tokenInfo; const { name, avatar_url } = owner.user; - const database_name = properties.name; + const database_name = properties.name.replace("📚 ", ""); const database_url = properties.link; - const databaseNameWithoutEmoji = database_name.replace("📚 ", "") const elementBuilder = new ElementBuilder(appId); const blockBuilder = new BlockBuilder(appId); @@ -28,7 +27,7 @@ export function getSelectDatabaseLayout( const thumb = workspace_icon_url ? { url: workspace_icon_url } : undefined; const title = [ `**Database Name**`, - `[**${databaseNameWithoutEmoji}**](${database_url})`, + `[**${database_name}**](${database_url})`, ]; const description = [""]; const avatarElement = elementBuilder.addImage({ diff --git a/src/lib/NotionSDK.ts b/src/lib/NotionSDK.ts index 6bfa493..7f25153 100644 --- a/src/lib/NotionSDK.ts +++ b/src/lib/NotionSDK.ts @@ -120,7 +120,7 @@ export class NotionSDK implements INotionSDK { const result: Array = []; results.forEach(async (item) => { - const pageObject = await this.getPageObjectFromResults(item, false); + const pageObject = await this.getPageObjectFromResults(item); if (pageObject) { result.push(pageObject); } @@ -132,7 +132,7 @@ export class NotionSDK implements INotionSDK { } } - private async getPageObjectFromResults(item, emoji:boolean=false): Promise { + private async getPageObjectFromResults(item, emoji:boolean = false): Promise { const typesWithTitleProperty = [ NotionObjectTypes.WORKSPACE.toString(), NotionObjectTypes.PAGE_ID.toString(), @@ -541,7 +541,7 @@ export class NotionSDK implements INotionSDK { } } - private async getDatabaseObjectFromResults(item, emoji:boolean=false): Promise { + private async getDatabaseObjectFromResults(item, emoji:boolean = false): Promise { const databaseNameTitleObject = item?.[NotionObjectTypes.TITLE]; const name: string = databaseNameTitleObject.length ? databaseNameTitleObject[0]?.plain_text @@ -566,9 +566,9 @@ export class NotionSDK implements INotionSDK { prop: IPageProperties ): Promise<(INotionPage & { pageId: string }) | Error> { try { - const { name, parent } = page; + const { parent } = page; const { title } = prop; - const nameWithoutEmoji = name.replace("📄", ""); + const name = page.name.replace("📄", ""); const data = { parent, @@ -599,7 +599,7 @@ export class NotionSDK implements INotionSDK { let result: INotionPage = { link: response?.data?.url, - name: nameWithoutEmoji, + name: name, title, }; @@ -991,8 +991,7 @@ export class NotionSDK implements INotionSDK { const pageInfo = response.data; const page = (await this.getPageObjectFromResults( - pageInfo, - false + pageInfo )) as IPage; const url: string = pageInfo?.url; @@ -1092,8 +1091,7 @@ export class NotionSDK implements INotionSDK { results.forEach(async (item) => { const objectType: string = item?.[NotionObjectTypes.OBJECT]; const databaseObject = await this.getDatabaseObjectFromResults( - item, - false + item ); result.push(databaseObject); From 77d91033a233bcc5834d32d622192a76675fc9e9 Mon Sep 17 00:00:00 2001 From: brf153 <153hsb@gmail.com> Date: Sat, 27 Jan 2024 13:00:34 +0530 Subject: [PATCH 9/9] fix:made the required changes Signed-off-by: brf153 <153hsb@gmail.com> --- src/handlers/ExecuteViewSubmitHandler.ts | 1 - src/lib/NotionSDK.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/handlers/ExecuteViewSubmitHandler.ts b/src/handlers/ExecuteViewSubmitHandler.ts index 56ee184..05a9d5f 100644 --- a/src/handlers/ExecuteViewSubmitHandler.ts +++ b/src/handlers/ExecuteViewSubmitHandler.ts @@ -495,7 +495,6 @@ export class ExecuteViewSubmitHandler { } else { const { info } = database; const databasename = info.name.replace("📚 ", ""); - console.log("databaseName ", databasename) const databaselink = info.link; const title: string = state?.[NotionPageOrRecord.TITLE_BLOCK]?.[ diff --git a/src/lib/NotionSDK.ts b/src/lib/NotionSDK.ts index 7f25153..ec8ef49 100644 --- a/src/lib/NotionSDK.ts +++ b/src/lib/NotionSDK.ts @@ -178,7 +178,7 @@ export class NotionSDK implements INotionSDK { return null; } - private returnPage(name: string, page_id: string, emoji: boolean=false): IPage { + private returnPage(name: string, page_id: string, emoji:boolean = false): IPage { return { name: `${emoji ? "📄" : ""} ${name}`, parent: { @@ -599,7 +599,7 @@ export class NotionSDK implements INotionSDK { let result: INotionPage = { link: response?.data?.url, - name: name, + name, title, };