Skip to content

Commit

Permalink
新增webhook通知方式 (#5)
Browse files Browse the repository at this point in the history
* fix code

* fix

* v0.0.12 fix #3
  • Loading branch information
mouday authored Oct 31, 2022
1 parent 6095bc8 commit c3965ed
Show file tree
Hide file tree
Showing 35 changed files with 263 additions and 71 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 参考
# Build and push Docker images
# https://github.com/marketplace/actions/build-and-push-docker-images
# Docker Metadata action
# https://github.com/marketplace/actions/docker-metadata-action

name: Docker Publish

on:
release:
types: [published]

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: mouday/domain-admin
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker Image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
30 changes: 0 additions & 30 deletions .github/workflows/github-action.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# https://github.com/actions/starter-workflows/blob/main/ci/python-publish.yml
name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build

- name: Publish package
# https://github.com/pypa/gh-action-pypi-publish
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: mouday
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
3 changes: 2 additions & 1 deletion docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ ADD . /app

WORKDIR /app

RUN apk add --no-cache --virtual .build-deps gcc musl-dev libffi-dev openssl-dev bash\
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& apk add --no-cache --virtual .build-deps gcc musl-dev libffi-dev openssl-dev bash\
&& apk add --no-cache libffi openssl \
&& pip install --no-cache-dir --upgrade pip setuptools wheel\
&& pip install --no-cache-dir -r requirements.txt \
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@ make dev

![](https://raw.githubusercontent.com/mouday/domain-admin/master/image/system-list.png)

2、设置接收邮件的邮箱
2、批量导入域名

![](https://raw.githubusercontent.com/mouday/domain-admin/master/image/user-edit.png)
导入文本示例: [/doc/domain.txt](/doc/domain.txt)

3、批量导入域名
3、设置邮件通知

导入文本示例: [/doc/domain.txt](/doc/domain.txt)
![](https://raw.githubusercontent.com/mouday/domain-admin/master/image/notify-email.png)

4、设置webhook通知

![](https://raw.githubusercontent.com/mouday/domain-admin/master/image/notify-webhook.png)

## 二次开发

Expand Down Expand Up @@ -219,6 +223,9 @@ $ waitress-serve --listen=127.0.0.1:8000 domain_admin.main:app
## 更新日志
- v0.0.12
- 新增webhook通知方式
- v0.0.11
- 优化前端页面显示,增加页面加载进度条
- 修复有效期天数显示不对的问题
Expand Down
14 changes: 12 additions & 2 deletions domain_admin/api/notify_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from playhouse.shortcuts import model_to_dict

from domain_admin.model.notify_model import NotifyModel
from domain_admin.service import notify_service


def get_notify_of_user():
"""
获取ip地址的信息
获取用户通知配置
:return:
"""
current_user_id = g.user_id
Expand All @@ -38,7 +39,7 @@ def get_notify_of_user():

def update_notify_of_user():
"""
获取ip地址的信息
更新用户通知配置
:return:
"""
current_user_id = g.user_id
Expand All @@ -65,3 +66,12 @@ def update_notify_of_user():
type_id=type_id,
value_raw=value_raw
)

def test_webhook_notify_of_user():
"""
测试webhook调用
:return:
"""
current_user_id = g.user_id

return notify_service.notify_webhook_of_user(current_user_id)
4 changes: 2 additions & 2 deletions domain_admin/api/user_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def update_user_info():

avatar_url = request.json.get('avatar_url')
before_expire_days = request.json.get('before_expire_days')
email_list = request.json.get('email_list')
# email_list = request.json.get('email_list')

UserModel.update({
'avatar_url': avatar_url,
'before_expire_days': before_expire_days,
'email_list_raw': json.dumps(email_list, ensure_ascii=False),
# 'email_list_raw': json.dumps(email_list, ensure_ascii=False),
'update_time': datetime_util.get_datetime()
}).where(
UserModel.id == current_user_id
Expand Down
17 changes: 0 additions & 17 deletions domain_admin/const.py

This file was deleted.

6 changes: 6 additions & 0 deletions domain_admin/enums/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
"""
@File : __init__.py.py
@Date : 2022-10-30
@Author : Peng Shiyu
"""
17 changes: 17 additions & 0 deletions domain_admin/enums/notify_type_enum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
"""
@File : notify_type_enum.py
@Date : 2022-10-30
@Author : Peng Shiyu
"""


class NotifyTypeEnum(object):
# 未知
Unknown = 0

# 邮件
Email = 1

# webkook
Webkook = 2
4 changes: 2 additions & 2 deletions domain_admin/model/notify_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class NotifyModel(BaseModel):
# 用户id
user_id = IntegerField(null=False)

#
type_id = IntegerField(null=False)
# 分类
type_id = IntegerField(null=False, default=0)

# 值
value_raw = TextField(default=None, null=True)
Expand Down
1 change: 1 addition & 0 deletions domain_admin/public/css/index.8961c6ee.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.notify-edit-container[data-v-e5abf4d9]{display:flex}.notify-edit__menu[data-v-e5abf4d9]{width:200px;flex-shrink:0}.notify-edit__main[data-v-e5abf4d9]{box-sizing:border-box;padding-left:20px;flex:1}
1 change: 1 addition & 0 deletions domain_admin/public/css/index.a97e8dd1.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions domain_admin/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
content="no-referrer"
/>
<title>Domain Admin-域名证书SSL监测系统</title>
<script type="module" crossorigin src="/js/index.ad435d7d.js"></script>
<script type="module" crossorigin src="/js/index.8912f4d7.js"></script>
<link rel="modulepreload" crossorigin href="/js/vendor-vue.e07d7f7e.js">
<link rel="modulepreload" crossorigin href="/js/element-icon.bb5f2c38.js">
<link rel="modulepreload" crossorigin href="/js/element-plus.93c2f37e.js">
<link rel="modulepreload" crossorigin href="/js/vendor-lib.bb870261.js">
<link rel="stylesheet" href="/css/index.cadc79a9.css">
<link rel="stylesheet" href="/css/index.a97e8dd1.css">
</head>
<body>
<div id="app"></div>
Expand Down
1 change: 1 addition & 0 deletions domain_admin/public/js/ConnectStatus.30fced90.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions domain_admin/public/js/ConnectStatus.32f95be2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions domain_admin/public/js/index.05eaf718.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c3965ed

Please sign in to comment.