-
Notifications
You must be signed in to change notification settings - Fork 101
Rb sept 15 slack integration #2200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e36106e
create functions to encrypt and decrypt texts
rachanabasnet 1f349ec
create interface, model, migration for Slack Webhooks
rachanabasnet dbabc8d
create api to create, update, and retrieve slack webhooks
rachanabasnet bc8cf53
integrate slack oauth to frontend, list integrations
rachanabasnet 3d11b19
Merge branch 'develop' of https://github.com/bluewave-labs/verifywise…
rachanabasnet 11b11bf
change env variable names
rachanabasnet 3b2d1f2
create endpoints to send messages to slack
rachanabasnet 1f77a17
Merge branch 'develop' of https://github.com/bluewave-labs/verifywise…
rachanabasnet 6f32061
create separate component to get slack integration lists
rachanabasnet 239e4f7
add permission to access slack integration page
rachanabasnet 60189b1
Merge branch 'develop' of https://github.com/bluewave-labs/verifywise…
rachanabasnet 28f8aa5
clean console logs, fix alert for success and error
rachanabasnet 6d35287
Merge branch 'develop' of https://github.com/bluewave-labs/verifywise…
rachanabasnet f638152
Merge branch 'develop' of https://github.com/bluewave-labs/verifywise…
rachanabasnet b8ead7a
fix build fail
rachanabasnet 41a1747
Merge branch 'develop' of https://github.com/bluewave-labs/verifywise…
rachanabasnet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { useEffect, useState } from "react"; | ||
| import { getSlackIntegrations } from "../repository/slack.integration.repository"; | ||
|
|
||
| interface ISlackWebhook { | ||
| id?: number; | ||
| access_token_iv?: string; | ||
| access_token: string; | ||
| scope: string; | ||
| user_id?: number; // FK to users table | ||
| team_name: string; | ||
| team_id: string; | ||
| channel: string; | ||
| channel_id: string; | ||
| configuration_url: string; // configuration URL to manage the webhook | ||
| url_iv?: string; | ||
| url: string; // URL of the slack workspace | ||
| created_at?: string; | ||
| is_active?: boolean; | ||
| } | ||
| export interface SlackWebhook { | ||
| id?: number; | ||
| scope: string; | ||
| teamName: string; | ||
| teamId: string; | ||
| channel: string; | ||
| channelId: string; | ||
| createdAt?: string; | ||
| isActive?: boolean; | ||
| } | ||
|
|
||
| interface ApiResponse { | ||
| data: ISlackWebhook[]; | ||
| } | ||
|
|
||
| const useSlackIntegrations = (userId: number | null) => { | ||
| const [slackIntegrations, setSlackIntegrations] = useState<SlackWebhook[]>( | ||
| [], | ||
| ); | ||
| const [loading, setLoading] = useState(true); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| const fetchSlackIntegrations = async () => { | ||
| try { | ||
| const controller = new AbortController(); | ||
| const signal = controller.signal; | ||
| setLoading(true); | ||
| const response = await getSlackIntegrations({ id: userId!, signal }); | ||
|
|
||
| const integrations: SlackWebhook[] = (response as ApiResponse).data.map( | ||
| (item: ISlackWebhook): SlackWebhook => ({ | ||
|
rachanabasnet marked this conversation as resolved.
|
||
| id: item.id, | ||
| scope: item.scope, | ||
| teamName: item.team_name, | ||
| teamId: item.team_id, | ||
| channel: item.channel, | ||
| channelId: item.channel_id, | ||
| createdAt: item.created_at, | ||
| isActive: item.is_active, | ||
| }), | ||
| ); | ||
|
|
||
| setSlackIntegrations(integrations); | ||
| setError(null); | ||
| } catch (err) { | ||
| setError( | ||
| err instanceof Error | ||
| ? err.message | ||
| : "Failed to fetch slack integrations", | ||
| ); | ||
| } finally { | ||
| setLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| fetchSlackIntegrations(); | ||
| }, []); | ||
|
|
||
| return { | ||
| slackIntegrations, | ||
| loading, | ||
| error, | ||
| refreshSlackIntegrations: fetchSlackIntegrations, | ||
| }; | ||
| }; | ||
|
|
||
| export default useSlackIntegrations; | ||
68 changes: 68 additions & 0 deletions
68
Clients/src/application/repository/slack.integration.repository.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { apiServices } from "../../infrastructure/api/networkServices"; | ||
|
|
||
| export async function getSlackIntegrations({ | ||
| id, | ||
| channel, | ||
| signal, | ||
| responseType = "json", | ||
| }: { | ||
| id: number; | ||
| channel?: string; | ||
| signal?: AbortSignal; | ||
| responseType?: string; | ||
| }): Promise<any> { | ||
| const response = await apiServices.get(`/slackWebhooks`, { | ||
| userId: id, | ||
| channel, | ||
| signal, | ||
| responseType, | ||
| }); | ||
| return response.data; | ||
| } | ||
|
|
||
| export async function getSlackIntegrationById({ | ||
| id, | ||
| signal, | ||
| responseType = "json", | ||
| }: { | ||
| id: string; | ||
| signal?: AbortSignal; | ||
| responseType?: string; | ||
| }): Promise<any> { | ||
| const response = await apiServices.get(`/slackWebhooks/${id}`, { | ||
| signal, | ||
| responseType, | ||
| }); | ||
| return response.data; | ||
| } | ||
|
|
||
| export async function createSlackIntegration({ | ||
| body, | ||
| }: { | ||
| body: any; | ||
| }): Promise<any> { | ||
| const response = await apiServices.post("/slackWebhooks", body); | ||
| return response.data; | ||
| } | ||
|
|
||
| export async function updateSlackIntegration({ | ||
| id, | ||
| body, | ||
| }: { | ||
| id: string; | ||
| body: any; | ||
| }): Promise<any> { | ||
| const response = await apiServices.patch(`/slackWebhooks/${id}`, body); | ||
| return response; | ||
| } | ||
|
|
||
| export async function sendSlackMessage({ | ||
| id, | ||
| body, | ||
| }: { | ||
| id: number; | ||
| body: { title: string; message: string }; | ||
| }): Promise<any> { | ||
| const response = await apiServices.post(`/slackWebhooks/${id}/send`, body); | ||
| return response.data; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.