Merge branch 'develop' into dev
* develop: fix log (#8) test log test log discord-notify.yml (#7)
This commit is contained in:
commit
09cfff98b1
2 changed files with 53 additions and 53 deletions
22
.github/workflows/discord-notify.yml
vendored
Normal file
22
.github/workflows/discord-notify.yml
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
name: Discord PR Notify
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
discord:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Send Discord
|
||||||
|
run: |
|
||||||
|
curl -X POST "${{ secrets.DISCORD_WEBHOOK_PULLREQUEST }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"embeds": [{
|
||||||
|
"title": "🔔 **Service:** ${{ github.repository }}",
|
||||||
|
"description": "👤 **Author:** ${{ github.event.pull_request.user.login }}\n🌿 **Branch:** ${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }}\n📦 **Pull Request:** [#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})",
|
||||||
|
"color": 5814783,
|
||||||
|
"timestamp": "${{ github.event.pull_request.created_at }}"
|
||||||
|
}]
|
||||||
|
}'
|
||||||
|
|
@ -184,46 +184,24 @@ class CheckAuth {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public async checkOrg(token: any, keycloakId: string) {
|
public async checkOrg(token: any, keycloakId: string) {
|
||||||
|
const redisClient = await this.redis.createClient({
|
||||||
|
host: process.env.REDIS_HOST,
|
||||||
|
port: process.env.REDIS_PORT,
|
||||||
|
})
|
||||||
|
const getAsync = promisify(redisClient.get).bind(redisClient)
|
||||||
try {
|
try {
|
||||||
// Validate required environment variables
|
let reply = await getAsync("org_" + keycloakId)
|
||||||
const REDIS_HOST = process.env.REDIS_HOST;
|
|
||||||
const REDIS_PORT = process.env.REDIS_PORT ? Number(process.env.REDIS_PORT) : 6379;
|
|
||||||
|
|
||||||
if (!REDIS_HOST) {
|
|
||||||
throw new Error("REDIS_HOST is not set in environment variables");
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`[REDIS] Connecting to Redis at ${REDIS_HOST}:${REDIS_PORT}`);
|
|
||||||
|
|
||||||
// Create Redis client
|
|
||||||
const redisClient = this.redis.createClient({
|
|
||||||
socket: {
|
|
||||||
host: REDIS_HOST,
|
|
||||||
port: REDIS_PORT,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
redisClient.on("error", (err: any) => {
|
|
||||||
console.error("[REDIS] Connection error:", err.message);
|
|
||||||
});
|
|
||||||
|
|
||||||
await redisClient.connect();
|
|
||||||
console.log("[REDIS] Connected successfully!");
|
|
||||||
|
|
||||||
const getAsync = promisify(redisClient.get).bind(redisClient);
|
|
||||||
|
|
||||||
let reply = await getAsync("org_" + keycloakId);
|
|
||||||
if (reply != null) {
|
if (reply != null) {
|
||||||
reply = JSON.parse(reply);
|
reply = JSON.parse(reply)
|
||||||
} else {
|
} else {
|
||||||
if (!keycloakId) throw new Error("No KeycloakId provided");
|
if (!keycloakId) throw new Error("No KeycloakId provided")
|
||||||
const x = await new CallAPI().GetData(
|
const x = await new CallAPI().GetData(
|
||||||
{
|
{
|
||||||
headers: { authorization: token },
|
headers: { authorization: token },
|
||||||
},
|
},
|
||||||
`/org/permission/checkOrg/${keycloakId}`,
|
`/org/permission/checkOrg/${keycloakId}`,
|
||||||
false,
|
false
|
||||||
);
|
)
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
orgRootId: x.orgRootId,
|
orgRootId: x.orgRootId,
|
||||||
|
|
@ -231,13 +209,13 @@ class CheckAuth {
|
||||||
orgChild2Id: x.orgChild2Id,
|
orgChild2Id: x.orgChild2Id,
|
||||||
orgChild3Id: x.orgChild3Id,
|
orgChild3Id: x.orgChild3Id,
|
||||||
orgChild4Id: x.orgChild4Id,
|
orgChild4Id: x.orgChild4Id,
|
||||||
};
|
}
|
||||||
|
|
||||||
return data;
|
return data
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
throw error;
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async PermissionCreate(req: RequestWithUser, system: string) {
|
public async PermissionCreate(req: RequestWithUser, system: string) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue