From 01d05223e9e0f76a874c3ab8cf2b98d79718fcbe Mon Sep 17 00:00:00 2001 From: VipinDevelops Date: Sat, 24 Feb 2024 14:52:34 +0530 Subject: [PATCH 1/7] change action to submit --- github/handlers/ExecuteBlockActionHandler.ts | 70 +------------------- github/handlers/ExecuteViewSubmitHandler.ts | 67 ++++++++++++++++++- github/helpers/githubActivityGraphURL.ts | 4 -- github/modals/UserProfileModal.ts | 7 -- github/modals/profileShareModal.ts | 29 +++----- 5 files changed, 76 insertions(+), 101 deletions(-) delete mode 100644 github/helpers/githubActivityGraphURL.ts diff --git a/github/handlers/ExecuteBlockActionHandler.ts b/github/handlers/ExecuteBlockActionHandler.ts index ecf8576..0171fa1 100644 --- a/github/handlers/ExecuteBlockActionHandler.ts +++ b/github/handlers/ExecuteBlockActionHandler.ts @@ -287,79 +287,13 @@ export class ExecuteBlockActionHandler { } case ModalsEnum.SHARE_PROFILE_PARAMS : { const profileInteractionData = context.getInteractionData().value; - const datAny = profileInteractionData as any; + const dataAny = profileInteractionData as any; const storeData = { - profileParams : datAny as string[] + profileParams : dataAny as string[] } - await this.persistence.updateByAssociation(new RocketChatAssociationRecord(RocketChatAssociationModel.MISC, "ProfileShareParam"), storeData); break; } - case ModalsEnum.SHARE_PROFILE_EXEC : { - let {user, room} = context.getInteractionData(); - const block = this.modify.getCreator().getBlockBuilder(); - let accessToken = await getAccessTokenForUser(this.read, user ,this.app.oauth2Config) as IAuthData; - const userProfile = await getBasicUserInfo(this.http, accessToken.token); - - const idRecord = new RocketChatAssociationRecord(RocketChatAssociationModel.MISC, "ProfileShareParam") - - const profileData = await this.read.getPersistenceReader().readByAssociation(idRecord); - - let profileShareParams: string[] = []; - - if (profileData.length == 0){ - profileShareParams = ['username', 'avatar', 'email', 'bio', 'followers', 'following' , 'contributionGraph']; - } - else { - const dat = profileData[0] as {profileParams : string[]}; - profileShareParams = dat.profileParams; - } - - if (profileShareParams.includes('avatar')){ - block.addImageBlock({ - imageUrl : userProfile.avatar, - altText : "User Info" - }) - } - - profileShareParams.map((value) => { - if (value != 'contributionGraph' && value != 'avatar'){ - block.addSectionBlock({ - text : block.newPlainTextObject(value), - }) - block.addContextBlock({ - elements : [ - block.newPlainTextObject(userProfile[value], true), - ] - }); - block.addDividerBlock(); - } - }) - - if (profileShareParams.includes('contributionGraph')){ - block.addImageBlock({imageUrl : `https://activity-graph.herokuapp.com/graph?username=${userProfile.username}&bg_color=ffffff&color=708090&line=24292e&point=24292e`, altText: "Github Contribution Graph"}) - } - - - if(user?.id){ - if(room?.id){ - await sendMessage(this.modify, room!, user, `${userProfile.name}'s Github Profile`, block) - }else{ - let roomId = ( - await getInteractionRoomData( - this.read.getPersistenceReader(), - user.id - ) - ).roomId; - room = await this.read.getRoomReader().getById(roomId) as IRoom; - await sendMessage(this.modify, room, user, `${userProfile.name}'s Github Profile`, block) - } - } - - this.persistence.removeByAssociation(idRecord); - - break; - } case ModalsEnum.VIEW_FILE_ACTION: { const codeModal = await fileCodeModal({ data, diff --git a/github/handlers/ExecuteViewSubmitHandler.ts b/github/handlers/ExecuteViewSubmitHandler.ts index 12dcd27..e8ea19e 100644 --- a/github/handlers/ExecuteViewSubmitHandler.ts +++ b/github/handlers/ExecuteViewSubmitHandler.ts @@ -17,7 +17,7 @@ import { IGitHubSearchResultData } from '../definitions/searchResultData'; import { githubSearchErrorModal } from '../modals/githubSearchErrorModal'; import { GithubSearchResultStorage } from '../persistance/searchResults'; import { githubSearchResultShareModal } from '../modals/githubSearchResultsShareModal'; -import { addSubscribedEvents, createSubscription, updateSubscription, createNewIssue, getIssueTemplates,githubSearchIssuesPulls, mergePullRequest, addNewPullRequestComment, getPullRequestData, getPullRequestComments, getRepoData, getRepositoryIssues, updateGithubIssues, addNewIssueComment, getIssuesComments, getIssueData } from '../helpers/githubSDK'; +import { addSubscribedEvents, createSubscription, updateSubscription, createNewIssue, getIssueTemplates,githubSearchIssuesPulls, mergePullRequest, addNewPullRequestComment, getPullRequestData, getPullRequestComments, getRepoData, getRepositoryIssues, updateGithubIssues, addNewIssueComment, getIssuesComments, getIssueData, getBasicUserInfo } from '../helpers/githubSDK'; import { NewIssueModal } from '../modals/newIssueModal'; import { issueTemplateSelectionModal } from '../modals/issueTemplateSelectionModal'; import { githubIssuesListModal } from '../modals/githubIssuesListModal'; @@ -27,7 +27,8 @@ import { IGitHubIssueData } from '../definitions/githubIssueData'; import { githubIssuesShareModal } from '../modals/githubIssuesShareModal'; import { issueCommentsModal } from '../modals/issueCommentsModal'; import { createReminder } from './CreateReminder'; - +import { RocketChatAssociationModel, RocketChatAssociationRecord } from '@rocket.chat/apps-engine/definition/metadata'; +import { IAuthData } from '@rocket.chat/apps-engine/definition/oauth2/IOAuth2'; export class ExecuteViewSubmitHandler { constructor( private readonly app: GithubApp, @@ -745,7 +746,67 @@ export class ExecuteViewSubmitHandler { } break; } - + case ModalsEnum.SHARE_PROFILE_EXEC : { + let {user, room} = context.getInteractionData(); + const block = this.modify.getCreator().getBlockBuilder(); + let accessToken = await getAccessTokenForUser(this.read, user ,this.app.oauth2Config) as IAuthData; + const userProfile = await getBasicUserInfo(this.http, accessToken.token); + + const idRecord = new RocketChatAssociationRecord(RocketChatAssociationModel.MISC, "ProfileShareParam") + + const profileData = await this.read.getPersistenceReader().readByAssociation(idRecord); + + let profileShareParams: string[] = []; + + if (profileData.length == 0){ + profileShareParams = ['username', 'avatar', 'email', 'bio', 'followers', 'following']; + }else { + const data = profileData[0] as {profileParams : string[]}; + profileShareParams = data.profileParams; + } + + console.log(profileShareParams, "params") + + if (profileShareParams.includes('avatar')){ + block.addImageBlock({ + imageUrl : userProfile.avatar, + altText : "User Info" + }) + } + + profileShareParams.map((value) => { + if (value != 'avatar'){ + block.addSectionBlock({ + text : block.newPlainTextObject(value), + }) + block.addContextBlock({ + elements : [ + block.newPlainTextObject(userProfile[value], true), + ] + }); + block.addDividerBlock(); + } + }) + + if(user?.id){ + if(room?.id){ + await sendMessage(this.modify, room!, user, `${userProfile.name}'s Github Profile`, block) + }else{ + let roomId = ( + await getInteractionRoomData( + this.read.getPersistenceReader(), + user.id + ) + ).roomId; + room = await this.read.getRoomReader().getById(roomId) as IRoom; + await sendMessage(this.modify, room, user, `${userProfile.name}'s Github Profile`, block) + } + } + + // this.persistence.removeByAssociation(idRecord); + + break; + } default: break; } diff --git a/github/helpers/githubActivityGraphURL.ts b/github/helpers/githubActivityGraphURL.ts deleted file mode 100644 index fe17d07..0000000 --- a/github/helpers/githubActivityGraphURL.ts +++ /dev/null @@ -1,4 +0,0 @@ - -export function githubActivityGraphUrl(username : string): string { - return `https://activity-graph.herokuapp.com/graph?username=${username}&bg_color=ffffff&color=708090&line=24292e&point=24292e` -} diff --git a/github/modals/UserProfileModal.ts b/github/modals/UserProfileModal.ts index 864c992..8781639 100644 --- a/github/modals/UserProfileModal.ts +++ b/github/modals/UserProfileModal.ts @@ -7,7 +7,6 @@ import { ModalsEnum } from "../enum/Modals"; import { getBasicUserInfo } from "../helpers/githubSDK"; import { getInteractionRoomData, storeInteractionRoomData } from "../persistance/roomInteraction"; import {} from "@rocket.chat/apps-engine/definition/uikit/" -import { githubActivityGraphUrl } from "../helpers/githubActivityGraphURL"; export async function userProfileModal({ access_token, @@ -67,12 +66,6 @@ export async function userProfileModal({ ] }); - block.addDividerBlock(); - - block.addImageBlock({imageUrl : githubActivityGraphUrl(userInfo.username), altText: "Github Contribution Graph"}); - - - block.addDividerBlock(); block.addSectionBlock({ diff --git a/github/modals/profileShareModal.ts b/github/modals/profileShareModal.ts index 5efc163..f23e7ca 100644 --- a/github/modals/profileShareModal.ts +++ b/github/modals/profileShareModal.ts @@ -22,7 +22,7 @@ export async function shareProfileModal({ uikitcontext?: UIKitInteractionContext }) : Promise { - const viewId = "ProfileShareView"; + const viewId = ModalsEnum.SHARE_PROFILE_EXEC; const block = modify.getCreator().getBlockBuilder(); block.addActionsBlock({ @@ -30,7 +30,7 @@ export async function shareProfileModal({ elements : [ block.newMultiStaticElement({ actionId: ModalsEnum.SHARE_PROFILE_PARAMS, - initialValue: ['username', 'avatar', 'email', 'bio', 'followers', 'following' , 'contributionGraph'], + initialValue: ['username', 'avatar', 'email', 'bio', 'followers', 'following'], options: [ { value: 'followers', @@ -77,28 +77,12 @@ export async function shareProfileModal({ text: 'bio' } }, - { - value : 'contributionGraph', - text : { - text: 'Contribution', - type : TextObjectType.PLAINTEXT - } - } ], placeholder: { type: TextObjectType.PLAINTEXT, text: 'Select Property to Share', }, }), - block.newButtonElement({ - actionId : ModalsEnum.SHARE_PROFILE_EXEC, - text : { - text : "Share to Chat", - type : TextObjectType.PLAINTEXT - }, - value : "shareChat" - - }) ] }) @@ -108,7 +92,14 @@ export async function shareProfileModal({ type: TextObjectType.PLAINTEXT, text: "Share Profile" }, - blocks: block.getBlocks() + blocks: block.getBlocks(), + submit:block.newButtonElement({ + text : { + text : "Share to Chat", + type : TextObjectType.PLAINTEXT + }, + value : "shareChat" + }) } } From 44c3a575a2a360e601bc6a0f6e5ef10c07094098 Mon Sep 17 00:00:00 2001 From: VipinDevelops Date: Sat, 24 Feb 2024 15:48:37 +0530 Subject: [PATCH 2/7] remove storage --- github/handlers/ExecuteViewSubmitHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/handlers/ExecuteViewSubmitHandler.ts b/github/handlers/ExecuteViewSubmitHandler.ts index e8ea19e..3caaad4 100644 --- a/github/handlers/ExecuteViewSubmitHandler.ts +++ b/github/handlers/ExecuteViewSubmitHandler.ts @@ -803,7 +803,7 @@ export class ExecuteViewSubmitHandler { } } - // this.persistence.removeByAssociation(idRecord); + this.persistence.removeByAssociation(idRecord); break; } From 0383c0f3f743ebca052d6b14532c2f0ecf7156e0 Mon Sep 17 00:00:00 2001 From: VipinDevelops Date: Fri, 1 Mar 2024 12:12:52 +0530 Subject: [PATCH 3/7] remove any type usage --- github/handlers/ExecuteBlockActionHandler.ts | 23 ++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/github/handlers/ExecuteBlockActionHandler.ts b/github/handlers/ExecuteBlockActionHandler.ts index 0171fa1..8727cea 100644 --- a/github/handlers/ExecuteBlockActionHandler.ts +++ b/github/handlers/ExecuteBlockActionHandler.ts @@ -287,11 +287,12 @@ export class ExecuteBlockActionHandler { } case ModalsEnum.SHARE_PROFILE_PARAMS : { const profileInteractionData = context.getInteractionData().value; - const dataAny = profileInteractionData as any; - const storeData = { - profileParams : dataAny as string[] - } + if(Array.isArray(profileInteractionData)) { + const storeData = { + profileParams: profileInteractionData as string[] + } await this.persistence.updateByAssociation(new RocketChatAssociationRecord(RocketChatAssociationModel.MISC, "ProfileShareParam"), storeData); + } break; } case ModalsEnum.VIEW_FILE_ACTION: { @@ -669,13 +670,13 @@ export class ExecuteBlockActionHandler { return context.getInteractionResponder().openModalViewResponse(shareProfileMod); } case ModalsEnum.APPROVE_PULL_REQUEST_ACTION:{ - + let value: string = context.getInteractionData().value as string; let splittedValues = value?.split(" "); let { user } = await context.getInteractionData(); let { room} = await context.getInteractionData(); let accessToken = await getAccessTokenForUser(this.read, user, this.app.oauth2Config) as IAuthData; - + if(splittedValues.length==2 && accessToken?.token){ let data={ "repo" : splittedValues[0], @@ -1024,8 +1025,8 @@ export class ExecuteBlockActionHandler { } } break; - } - + } + case ModalsEnum.GITHUB_LOGIN_ACTION :{ const {user, room} = context.getInteractionData(); if(room){ @@ -1071,7 +1072,7 @@ export class ExecuteBlockActionHandler { }); return context.getInteractionResponder().openModalViewResponse(newIssueModal); } - + case ModalsEnum.TRIGGER_SEARCH_MODAL: { const searchModal = await githubSearchModal({ modify: this.modify, @@ -1094,7 +1095,7 @@ export class ExecuteBlockActionHandler { const message = `You have unsubscribed from repository [${repo} Pull Request #${number}](https://github.com/${repo}/pull/${number})`; await sendNotification(this.read, this.modify, user, room as IRoom, message); - + } } } catch (error) { @@ -1103,4 +1104,4 @@ export class ExecuteBlockActionHandler { return context.getInteractionResponder().successResponse(); } -} \ No newline at end of file +} From 4d2e59d926905fced9731c943a106b83e994fbfe Mon Sep 17 00:00:00 2001 From: VipinDevelops Date: Fri, 1 Mar 2024 12:16:21 +0530 Subject: [PATCH 4/7] remove console.log --- github/handlers/ExecuteViewSubmitHandler.ts | 24 ++++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/github/handlers/ExecuteViewSubmitHandler.ts b/github/handlers/ExecuteViewSubmitHandler.ts index 3caaad4..8f64ad0 100644 --- a/github/handlers/ExecuteViewSubmitHandler.ts +++ b/github/handlers/ExecuteViewSubmitHandler.ts @@ -154,12 +154,12 @@ export class ExecuteViewSubmitHandler { }else{ await sendNotification(this.read,this.modify,user,room,`Invalid Issue !`); } - } + } break; } case ModalsEnum.NEW_ISSUE_STARTER_VIEW:{ const { roomId } = await getInteractionRoomData(this.read.getPersistenceReader(), user.id); - + if (roomId) { let room = await this.read.getRoomReader().getById(roomId) as IRoom; let repository = view.state?.[ModalsEnum.REPO_NAME_INPUT]?.[ModalsEnum.REPO_NAME_INPUT_ACTION] as string; @@ -167,7 +167,7 @@ export class ExecuteViewSubmitHandler { if (!accessToken) { await sendNotification(this.read, this.modify, user, room, `Login To Github ! -> /github login`); }else{ - + repository=repository?.trim(); let response = await getIssueTemplates(this.http,repository,accessToken.token); if((!response.template_not_found) && response?.templates?.length){ @@ -185,7 +185,7 @@ export class ExecuteViewSubmitHandler { .openModalViewResponse(createNewIssue); } } - } + } break; } case ModalsEnum.SEARCH_VIEW: { @@ -227,7 +227,7 @@ export class ExecuteViewSubmitHandler { }else{ resourceState = resourceState?.trim(); } - + let accessToken = await getAccessTokenForUser(this.read, user, this.app.oauth2Config); if(repository?.length == 0 && labelsArray?.length == 0 && authorsArray?.length == 0){ await sendNotification(this.read, this.modify, user, room, "*Invalid Search Query !*"); @@ -404,7 +404,7 @@ export class ExecuteViewSubmitHandler { return context .getInteractionResponder() .openModalViewResponse(unauthorizedMessageModal); - }else{ + }else{ let pullRequestComments = await getPullRequestComments(this.http,repository,accessToken.token,pullNumber); let pullRequestData = await getPullRequestData(this.http,repository,accessToken.token,pullNumber); if(pullRequestData?.serverError || pullRequestComments?.pullRequestData){ @@ -482,7 +482,7 @@ export class ExecuteViewSubmitHandler { return context .getInteractionResponder() .openModalViewResponse(unauthorizedMessageModal); - }else{ + }else{ let issueComments = await getIssuesComments(this.http,repository,accessToken?.token,issueNumber); let issueData = await getIssueData(repository,issueNumber,accessToken.token,this.http); if(issueData?.issue_compact === "Error Fetching Issue" || issueComments?.issueData){ @@ -626,7 +626,7 @@ export class ExecuteViewSubmitHandler { .getInteractionResponder() .openModalViewResponse(issuesListModal); } - } + } break; } case ModalsEnum.ADD_ISSUE_ASSIGNEE_VIEW: { @@ -696,7 +696,7 @@ export class ExecuteViewSubmitHandler { } } } - } + } break; } case ModalsEnum.ISSUE_LIST_VIEW:{ @@ -742,7 +742,7 @@ export class ExecuteViewSubmitHandler { let repository = view.state?.[ModalsEnum.REPO_NAME_INPUT]?.[ModalsEnum.REPO_NAME_INPUT_ACTION] as string; await createReminder(repository,room,this.read,this.app,this.persistence,this.modify,this.http,user) - + } break; } @@ -765,8 +765,6 @@ export class ExecuteViewSubmitHandler { profileShareParams = data.profileParams; } - console.log(profileShareParams, "params") - if (profileShareParams.includes('avatar')){ block.addImageBlock({ imageUrl : userProfile.avatar, @@ -818,4 +816,4 @@ export class ExecuteViewSubmitHandler { success: true, }; } -} \ No newline at end of file +} From db14e56a9d953abe7951b9cf98551dbeb9ccddfd Mon Sep 17 00:00:00 2001 From: VipinDevelops Date: Fri, 1 Mar 2024 12:59:04 +0530 Subject: [PATCH 5/7] Revert "remove console.log" This reverts commit 4d2e59d926905fced9731c943a106b83e994fbfe. --- github/handlers/ExecuteViewSubmitHandler.ts | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/github/handlers/ExecuteViewSubmitHandler.ts b/github/handlers/ExecuteViewSubmitHandler.ts index 8f64ad0..3caaad4 100644 --- a/github/handlers/ExecuteViewSubmitHandler.ts +++ b/github/handlers/ExecuteViewSubmitHandler.ts @@ -154,12 +154,12 @@ export class ExecuteViewSubmitHandler { }else{ await sendNotification(this.read,this.modify,user,room,`Invalid Issue !`); } - } + } break; } case ModalsEnum.NEW_ISSUE_STARTER_VIEW:{ const { roomId } = await getInteractionRoomData(this.read.getPersistenceReader(), user.id); - + if (roomId) { let room = await this.read.getRoomReader().getById(roomId) as IRoom; let repository = view.state?.[ModalsEnum.REPO_NAME_INPUT]?.[ModalsEnum.REPO_NAME_INPUT_ACTION] as string; @@ -167,7 +167,7 @@ export class ExecuteViewSubmitHandler { if (!accessToken) { await sendNotification(this.read, this.modify, user, room, `Login To Github ! -> /github login`); }else{ - + repository=repository?.trim(); let response = await getIssueTemplates(this.http,repository,accessToken.token); if((!response.template_not_found) && response?.templates?.length){ @@ -185,7 +185,7 @@ export class ExecuteViewSubmitHandler { .openModalViewResponse(createNewIssue); } } - } + } break; } case ModalsEnum.SEARCH_VIEW: { @@ -227,7 +227,7 @@ export class ExecuteViewSubmitHandler { }else{ resourceState = resourceState?.trim(); } - + let accessToken = await getAccessTokenForUser(this.read, user, this.app.oauth2Config); if(repository?.length == 0 && labelsArray?.length == 0 && authorsArray?.length == 0){ await sendNotification(this.read, this.modify, user, room, "*Invalid Search Query !*"); @@ -404,7 +404,7 @@ export class ExecuteViewSubmitHandler { return context .getInteractionResponder() .openModalViewResponse(unauthorizedMessageModal); - }else{ + }else{ let pullRequestComments = await getPullRequestComments(this.http,repository,accessToken.token,pullNumber); let pullRequestData = await getPullRequestData(this.http,repository,accessToken.token,pullNumber); if(pullRequestData?.serverError || pullRequestComments?.pullRequestData){ @@ -482,7 +482,7 @@ export class ExecuteViewSubmitHandler { return context .getInteractionResponder() .openModalViewResponse(unauthorizedMessageModal); - }else{ + }else{ let issueComments = await getIssuesComments(this.http,repository,accessToken?.token,issueNumber); let issueData = await getIssueData(repository,issueNumber,accessToken.token,this.http); if(issueData?.issue_compact === "Error Fetching Issue" || issueComments?.issueData){ @@ -626,7 +626,7 @@ export class ExecuteViewSubmitHandler { .getInteractionResponder() .openModalViewResponse(issuesListModal); } - } + } break; } case ModalsEnum.ADD_ISSUE_ASSIGNEE_VIEW: { @@ -696,7 +696,7 @@ export class ExecuteViewSubmitHandler { } } } - } + } break; } case ModalsEnum.ISSUE_LIST_VIEW:{ @@ -742,7 +742,7 @@ export class ExecuteViewSubmitHandler { let repository = view.state?.[ModalsEnum.REPO_NAME_INPUT]?.[ModalsEnum.REPO_NAME_INPUT_ACTION] as string; await createReminder(repository,room,this.read,this.app,this.persistence,this.modify,this.http,user) - + } break; } @@ -765,6 +765,8 @@ export class ExecuteViewSubmitHandler { profileShareParams = data.profileParams; } + console.log(profileShareParams, "params") + if (profileShareParams.includes('avatar')){ block.addImageBlock({ imageUrl : userProfile.avatar, @@ -816,4 +818,4 @@ export class ExecuteViewSubmitHandler { success: true, }; } -} +} \ No newline at end of file From 1cbae0ce5a9ef6dd2961cdbe08b9ecd07cd1b3ae Mon Sep 17 00:00:00 2001 From: VipinDevelops Date: Fri, 1 Mar 2024 12:59:12 +0530 Subject: [PATCH 6/7] Revert "remove any type usage" This reverts commit 0383c0f3f743ebca052d6b14532c2f0ecf7156e0. --- github/handlers/ExecuteBlockActionHandler.ts | 23 ++++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/github/handlers/ExecuteBlockActionHandler.ts b/github/handlers/ExecuteBlockActionHandler.ts index 8727cea..0171fa1 100644 --- a/github/handlers/ExecuteBlockActionHandler.ts +++ b/github/handlers/ExecuteBlockActionHandler.ts @@ -287,12 +287,11 @@ export class ExecuteBlockActionHandler { } case ModalsEnum.SHARE_PROFILE_PARAMS : { const profileInteractionData = context.getInteractionData().value; - if(Array.isArray(profileInteractionData)) { - const storeData = { - profileParams: profileInteractionData as string[] - } - await this.persistence.updateByAssociation(new RocketChatAssociationRecord(RocketChatAssociationModel.MISC, "ProfileShareParam"), storeData); + const dataAny = profileInteractionData as any; + const storeData = { + profileParams : dataAny as string[] } + await this.persistence.updateByAssociation(new RocketChatAssociationRecord(RocketChatAssociationModel.MISC, "ProfileShareParam"), storeData); break; } case ModalsEnum.VIEW_FILE_ACTION: { @@ -670,13 +669,13 @@ export class ExecuteBlockActionHandler { return context.getInteractionResponder().openModalViewResponse(shareProfileMod); } case ModalsEnum.APPROVE_PULL_REQUEST_ACTION:{ - + let value: string = context.getInteractionData().value as string; let splittedValues = value?.split(" "); let { user } = await context.getInteractionData(); let { room} = await context.getInteractionData(); let accessToken = await getAccessTokenForUser(this.read, user, this.app.oauth2Config) as IAuthData; - + if(splittedValues.length==2 && accessToken?.token){ let data={ "repo" : splittedValues[0], @@ -1025,8 +1024,8 @@ export class ExecuteBlockActionHandler { } } break; - } - + } + case ModalsEnum.GITHUB_LOGIN_ACTION :{ const {user, room} = context.getInteractionData(); if(room){ @@ -1072,7 +1071,7 @@ export class ExecuteBlockActionHandler { }); return context.getInteractionResponder().openModalViewResponse(newIssueModal); } - + case ModalsEnum.TRIGGER_SEARCH_MODAL: { const searchModal = await githubSearchModal({ modify: this.modify, @@ -1095,7 +1094,7 @@ export class ExecuteBlockActionHandler { const message = `You have unsubscribed from repository [${repo} Pull Request #${number}](https://github.com/${repo}/pull/${number})`; await sendNotification(this.read, this.modify, user, room as IRoom, message); - + } } } catch (error) { @@ -1104,4 +1103,4 @@ export class ExecuteBlockActionHandler { return context.getInteractionResponder().successResponse(); } -} +} \ No newline at end of file From 723dc14c1a4c7bd2226914ad0ef42e04a78fd72e Mon Sep 17 00:00:00 2001 From: VipinDevelops Date: Fri, 1 Mar 2024 13:02:26 +0530 Subject: [PATCH 7/7] fix issues --- github/handlers/ExecuteBlockActionHandler.ts | 9 +++++---- github/handlers/ExecuteViewSubmitHandler.ts | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/github/handlers/ExecuteBlockActionHandler.ts b/github/handlers/ExecuteBlockActionHandler.ts index 0171fa1..337872e 100644 --- a/github/handlers/ExecuteBlockActionHandler.ts +++ b/github/handlers/ExecuteBlockActionHandler.ts @@ -287,11 +287,12 @@ export class ExecuteBlockActionHandler { } case ModalsEnum.SHARE_PROFILE_PARAMS : { const profileInteractionData = context.getInteractionData().value; - const dataAny = profileInteractionData as any; - const storeData = { - profileParams : dataAny as string[] - } + if(Array.isArray(profileInteractionData)) { + const storeData = { + profileParams: profileInteractionData as string[] + } await this.persistence.updateByAssociation(new RocketChatAssociationRecord(RocketChatAssociationModel.MISC, "ProfileShareParam"), storeData); + } break; } case ModalsEnum.VIEW_FILE_ACTION: { diff --git a/github/handlers/ExecuteViewSubmitHandler.ts b/github/handlers/ExecuteViewSubmitHandler.ts index 3caaad4..38c34b4 100644 --- a/github/handlers/ExecuteViewSubmitHandler.ts +++ b/github/handlers/ExecuteViewSubmitHandler.ts @@ -765,8 +765,6 @@ export class ExecuteViewSubmitHandler { profileShareParams = data.profileParams; } - console.log(profileShareParams, "params") - if (profileShareParams.includes('avatar')){ block.addImageBlock({ imageUrl : userProfile.avatar,