Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for all methods with webhook
- Loading branch information
1 parent
4c0a3b0
commit bce20a0
Showing
3 changed files
with
38 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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 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 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,29 @@ | ||
import { LogEntry, SlackMessageRequest } from './types'; | ||
|
||
export async function parseLog(entry: LogEntry): Promise<SlackMessageRequest> { | ||
if (entry.jsonPayload?.slack) { | ||
return entry.jsonPayload.slack; | ||
} | ||
|
||
if ( | ||
entry.operation?.producer === 'github.com/bjerkio/nestjs-slack@v1' && | ||
typeof entry.jsonPayload?.message !== 'string' | ||
) { | ||
return entry.jsonPayload?.message?.slack; | ||
} | ||
|
||
if ( | ||
entry.jsonPayload?.message && | ||
typeof entry.jsonPayload?.message === 'string' | ||
) { | ||
return { | ||
text: entry.jsonPayload?.message, | ||
}; | ||
} | ||
|
||
if (entry.textPayload) { | ||
return { | ||
text: entry.textPayload, | ||
}; | ||
} | ||
} |