Compare commits

19 Commits
1.15.0 ... main

Author SHA1 Message Date
cf92c3ef8f try things
Some checks failed
Lint / Run linters (push) Failing after 1m43s
2023-05-01 23:23:23 +00:00
37c316b457 npm install 2023-05-01 23:11:39 +00:00
71dbf25e22 Revert "no nodejs, only eslint"
Some checks failed
Lint / Run linters (push) Failing after 1m32s
This reverts commit cd707eb6c2.
2023-05-01 23:10:22 +00:00
cd707eb6c2 no nodejs, only eslint
Some checks failed
Lint / Run linters (push) Failing after 1m12s
2023-05-01 23:04:54 +00:00
3feab3d957 simpler eslint
Some checks failed
Lint / Run linters (push) Failing after 1m5s
2023-05-01 23:04:01 +00:00
4da9ea5179 new package.json stuff
Some checks failed
Lint / Run linters (push) Failing after 27s
2023-05-01 22:44:51 +00:00
0b2620a0ab don't use package-lock.json
Some checks failed
Lint / Run linters (push) Failing after 43s
2023-05-01 22:33:05 +00:00
c4889b9d7f try without package.json
Some checks failed
Lint / Run linters (push) Failing after 31s
2023-05-01 22:31:19 +00:00
ee905058f3 grrrr... just work pls.
Some checks failed
Lint / Run linters (push) Failing after 37s
2023-05-01 22:25:47 +00:00
ba71d2e80a Revert "i need to rebase all of this"
Some checks failed
Lint / Run linters (push) Failing after 37s
This reverts commit 95e4306edd.
2023-05-01 22:24:05 +00:00
de53019210 don't include this
Some checks failed
Lint / Run linters (push) Failing after 26s
2023-05-01 22:19:16 +00:00
95e4306edd i need to rebase all of this
Some checks failed
Lint / Run linters (push) Failing after 29s
2023-05-01 22:18:14 +00:00
196466972c [lint] try a little more
Some checks failed
Lint / Run linters (push) Failing after 36s
2023-05-01 22:17:11 +00:00
9c4ccb8102 [lint] try to fix linting issues
Some checks failed
Lint / Run linters (push) Failing after 34s
2023-05-01 22:14:52 +00:00
f0399d4d7e [lint] use npm i for dependency install
Some checks failed
Lint / Run linters (push) Failing after 29s
2023-05-01 22:02:51 +00:00
7cbbb9249a Don't impersonate users
Some checks failed
Lint / Run linters (push) Failing after 29s
2023-05-01 21:57:15 +00:00
b26ba18a5b [actions] add linting 2023-05-01 21:31:27 +00:00
Austin Su
d0117a1be4 Update gitea-rocketchat.hooks.js 2022-04-29 00:24:25 +08:00
Austin Su
8c568c473d Support RockChat 4.x up
according to field object form https://developer.rocket.chat/reference/api/rest-api/endpoints/team-collaboration-endpoints/chat-endpoints/postmessage#attachment-field-objects .
fill information properly.
2022-03-05 18:29:07 +08:00
5 changed files with 321 additions and 28 deletions

16
.eslintrc.json Normal file
View File

@@ -0,0 +1,16 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 14
},
"rules": {
}
}

View File

@@ -0,0 +1,34 @@
name: Lint
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
run: apt update; apt install -y nodejs eslint
- name: Check out Git repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install Node.js dependencies
run: npm install
- name: Run eslint
run: eslint *.js

130
.gitignore vendored Normal file
View File

@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

View File

@@ -44,8 +44,6 @@ const giteaEvents = {
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text
}
};
@@ -64,8 +62,6 @@ const giteaEvents = {
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text
}
};
@@ -78,8 +74,6 @@ const giteaEvents = {
const text = "Forked from **[" + forkee.full_name + '](' + forkee.html_url + ')** to **[' + repo.full_name + '](' + repo.html_url + ')**';
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text
}
};
@@ -100,9 +94,10 @@ const giteaEvents = {
for (var i = 0; i < commits.length; i++) {
var commit = commits[i];
var shortID = commit.id.substring(0, 7);
output = '[#' + shortID + '](' + commit.url + '): \n' + commit.message
attachment.fields.push({
value: output,
short: false,
title: '[#' + shortID + '](' + commit.url + '): \n',
value: commit.message,
});
}
@@ -112,8 +107,6 @@ const giteaEvents = {
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text,
attachments: [attachment]
}
@@ -142,8 +135,6 @@ const giteaEvents = {
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text
}
};
@@ -170,8 +161,6 @@ const giteaEvents = {
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text
}
};
@@ -213,8 +202,6 @@ const giteaEvents = {
is.html_url + ')** ' + 'at [' + repo.full_name + '](' + repo.html_url + ')\n\n';
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text,
attachments: [{
text: body
@@ -270,8 +257,6 @@ const giteaEvents = {
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text,
attachments: [
{
@@ -296,14 +281,17 @@ const giteaEvents = {
var body = "Current labels: " + getLabelsField(pr.labels).value;
} else if (action == "assigned" || action == "unassigned") {
if (pr.assignee) {
var body = "Current assignee: " + getAssigneesField(pr.assignees).value;
var assign_text = "Current assignee: " + getAssigneesField(pr.assignees).value;
} else {
var body = "There is no assignee";
var assign_text = "There is no assignee";
}
} else if (action == "closed") {
if (pr.merged) {
var body = "Merged by: " + pr.merged_by.login;
}
else{
var body = "Not merged pull request"
}
} else if (action == "milestoned" || action == "demilestoned") {
var body = "Milestone: [" + pr.milestone.title + "](" + repo.html_url + "/milestone/" + pr.milestone.id + ")";
} else if (action == "synchronized"){
@@ -316,15 +304,20 @@ const giteaEvents = {
}
};
}
const text =
if(assign_text){
var text =
action.capitalizeFirstLetter() + ' **[pull request #' + pr.number +
' - ' + pr.title + '](' +
pr.html_url + ')**' + ' at [' + repo.full_name + '](' + repo.html_url + ')\n\n'+ assign_text;
}
else{
var text =
action.capitalizeFirstLetter() + ' **[pull request #' + pr.number +
' - ' + pr.title + '](' +
pr.html_url + ')**' + ' at [' + repo.full_name + '](' + repo.html_url + ')\n\n';
}
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text,
attachments: [
{
@@ -347,8 +340,6 @@ const giteaEvents = {
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text,
attachments: [
{
@@ -370,8 +361,6 @@ const giteaEvents = {
return {
content: {
icon_url: user.avatar_url,
alias: user.login,
text: text,
attachments: [
{

124
package.json Normal file
View File

@@ -0,0 +1,124 @@
{
"name": "rocketchat-gitea-hook",
"version": "1.15.0",
"description": "Rocket.Chat integrate Gitea's notifications via Incoming Webhook",
"main": "gitea-rocketchat.hooks.js",
"dependencies": {
"acorn-jsx": "^5.3.2",
"ajv": "^6.12.6",
"ansi-regex": "^5.0.1",
"ansi-styles": "^4.3.0",
"are-docs-informative": "^0.0.2",
"argparse": "^2.0.1",
"balanced-match": "^1.0.2",
"brace-expansion": "^1.1.11",
"callsites": "^3.1.0",
"chalk": "^4.1.2",
"color-convert": "^2.0.1",
"color-name": "^1.1.4",
"comment-parser": "^1.3.1",
"concat-map": "^0.0.1",
"cross-spawn": "^7.0.3",
"debug": "^4.3.4",
"deep-is": "^0.1.4",
"doctrine": "^3.0.0",
"escape-string-regexp": "^4.0.0",
"eslint-plugin-jsdoc": "^43.1.1",
"eslint-scope": "^7.2.0",
"eslint-visitor-keys": "^3.4.0",
"espree": "^9.5.1",
"esquery": "^1.5.0",
"esrecurse": "^4.3.0",
"estraverse": "^5.3.0",
"esutils": "^2.0.3",
"fast-deep-equal": "^3.1.3",
"fast-json-stable-stringify": "^2.1.0",
"fast-levenshtein": "^2.0.6",
"fastq": "^1.15.0",
"file-entry-cache": "^6.0.1",
"find-up": "^5.0.0",
"flat-cache": "^3.0.4",
"flatted": "^3.2.7",
"fs.realpath": "^1.0.0",
"glob": "^7.2.3",
"glob-parent": "^6.0.2",
"globals": "^13.20.0",
"grapheme-splitter": "^1.0.4",
"has-flag": "^4.0.0",
"ignore": "^5.2.4",
"import-fresh": "^3.3.0",
"imurmurhash": "^0.1.4",
"inflight": "^1.0.6",
"inherits": "^2.0.4",
"is-extglob": "^2.1.1",
"is-glob": "^4.0.3",
"is-path-inside": "^3.0.3",
"isexe": "^2.0.0",
"js-sdsl": "^4.4.0",
"js-yaml": "^4.1.0",
"jsdoc-type-pratt-parser": "^4.0.0",
"json-schema-traverse": "^0.4.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
"locate-path": "^6.0.0",
"lodash.merge": "^4.6.2",
"lru-cache": "^6.0.0",
"minimatch": "^3.1.2",
"ms": "^2.1.2",
"natural-compare": "^1.4.0",
"once": "^1.4.0",
"optionator": "^0.9.1",
"p-limit": "^3.1.0",
"p-locate": "^5.0.0",
"parent-module": "^1.0.1",
"path-exists": "^4.0.0",
"path-is-absolute": "^1.0.1",
"path-key": "^3.1.1",
"prelude-ls": "^1.2.1",
"prettier": "^2.8.8",
"punycode": "^2.3.0",
"queue-microtask": "^1.2.3",
"resolve-from": "^4.0.0",
"reusify": "^1.0.4",
"rimraf": "^3.0.2",
"run-parallel": "^1.2.0",
"semver": "^7.5.0",
"shebang-command": "^2.0.0",
"shebang-regex": "^3.0.0",
"spdx-exceptions": "^2.3.0",
"spdx-expression-parse": "^3.0.1",
"spdx-license-ids": "^3.0.13",
"strip-ansi": "^6.0.1",
"strip-json-comments": "^3.1.1",
"supports-color": "^7.2.0",
"text-table": "^0.2.0",
"type-check": "^0.4.0",
"type-fest": "^0.20.2",
"uri-js": "^4.4.1",
"which": "^2.0.2",
"word-wrap": "^1.2.3",
"wrappy": "^1.0.2",
"yallist": "^4.0.0",
"yocto-queue": "^0.1.0"
},
"scripts": {
"test": "npm test"
},
"repository": {
"type": "git",
"url": "git@git.sporq.de:sporq/rocketchat-gitea-hook.git"
},
"keywords": [
"notifications",
"webhooks",
"webhook",
"gitea",
"rocketchat",
"incoming-webhooks"
],
"author": "Austin Su",
"license": "MIT",
"devDependencies": {
"eslint": "^8.39.0"
}
}