Skip to content

Commit

Permalink
Merge pull request 'v2.4.2' (#4) from v2.4.2 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinnrry committed Mar 6, 2024
2 parents f6b1be7 + 5f75015 commit e95930c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ jobs:
- uses: actions/setup-node@v4

- name: Build FE
run: make build_fe
run: |
echo "$(git show -s --format=%H)"
echo "GITHASH=$(git show -s --format=%H)" >> ${GITHUB_ENV}
make build_fe
- name: Log in to the Container registry
uses: docker/login-action@v2.1.0
Expand All @@ -51,6 +54,9 @@ jobs:
- name: Build and push Docker images
uses: docker/build-push-action@v4
with:
build-args: |
VERSION=${{ env.VERSION }}
GITHASH=${{ env.GITHASH }}
context: .
file: ./DockerfileGithubAction
platforms: |
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/docker_build_pre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ jobs:
- uses: actions/setup-node@v4

- name: Build FE
run: make build_fe
run: |
echo "GITHASH=$(git show -s --format=%H)" >> ${GITHUB_ENV}
make build_fe
- name: Log in to the Container registry
uses: docker/login-action@v2.1.0
Expand All @@ -51,7 +53,9 @@ jobs:
- name: Build and push Docker images
uses: docker/build-push-action@v4
with:
build-args: VERSION=${{ env.VERSION }}
build-args: |
VERSION=${{ env.VERSION }}
GITHASH=${{ env.GITHASH }}
context: .
file: ./DockerfileGithubAction
platforms: |
Expand Down
3 changes: 2 additions & 1 deletion DockerfileGithubAction
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM golang:alpine as serverbuild
ARG VERSION
ARG GITHASH
WORKDIR /work

COPY server .

RUN apk update && apk add git
RUN go build -ldflags "-s -w -X 'main.version=${VERSION}' -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(TZ=UTC-8 date +%Y-%m-%d" "%H:%M:%S)'" -o pmail main.go
RUN go build -ldflags "-s -w -X 'main.version=${VERSION}' -X 'main.goVersion=$(go version)' -X 'main.gitHash=${GITHASH}' -X 'main.buildTime=$(TZ=UTC-8 date +%Y-%m-%d" "%H:%M:%S)'" -o pmail main.go
RUN cd /work/hooks/telegram_push && go build -ldflags "-s -w" -o output/telegram_push telegram_push.go
RUN cd /work/hooks/web_push && go build -ldflags "-s -w" -o output/web_push web_push.go
RUN cd /work/hooks/wechat_push && go build -ldflags "-s -w" -o output/wechat_push wechat_push.go
Expand Down
15 changes: 8 additions & 7 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func main() {
// 日志消息输出可以是任意的io.writer类型
log.SetOutput(os.Stdout)

var cst, _ = time.LoadLocation("Asia/Shanghai")
time.Local = cst
var cstZone = time.FixedZone("CST", 8*3600)
time.Local = cstZone

config.Init()

Expand All @@ -75,15 +75,16 @@ func main() {
}

if version == "" {
version = time.Now().Format("2006-01-02 15:04:05")
version = "TestVersion"
}

log.Infoln("***************************************************")
log.Infof("***\tServer Start Success Version:%s\n", version)
log.Infoln("*******************************************************************")
log.Infof("***\tServer Start Success \n")
log.Infof("***\tServer Version: %s \n", version)
log.Infof("***\tGit Commit Hash: %s ", gitHash)
log.Infof("***\tBuild TimeStamp: %s ", buildTime)
log.Infof("***\tBuild Date: %s ", buildTime)
log.Infof("***\tBuild GoLang Version: %s ", goVersion)
log.Infoln("***************************************************")
log.Infoln("*******************************************************************")

// 定时任务启动
go cron_server.Start()
Expand Down
27 changes: 24 additions & 3 deletions server/smtp_server/read_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ func (s *Session) Data(r io.Reader) error {
// 判断是收信还是转发,只要是登陆了,都当成转发处理
//account, domain := email.From.GetDomainAccount()
if s.Ctx.UserID > 0 {

log.WithContext(ctx).Debugf("开始执行插件SendBefore!")
as2 := async.New(ctx)
for _, hook := range hooks.HookList {
if hook == nil {
continue
}
as2.WaitProcess(func(hk any) {
hk.(framework.EmailHook).SendBefore(ctx, email)
}, hook)
}
as2.Wait()
log.WithContext(ctx).Debugf("开始执行插件SendBefore!End")

if email == nil {
return nil
}

// 转发
err := saveEmail(ctx, email, 1, true, true)
if err != nil {
Expand All @@ -86,10 +104,7 @@ func (s *Session) Data(r io.Reader) error {

SPFStatus = spfCheck(s.RemoteAddress.String(), email.Sender, email.Sender.EmailAddress)

saveEmail(ctx, email, 0, SPFStatus, dkimStatus)

log.WithContext(ctx).Debugf("开始执行插件ReceiveParseAfter!")

as2 := async.New(ctx)
for _, hook := range hooks.HookList {
if hook == nil {
Expand All @@ -102,6 +117,12 @@ func (s *Session) Data(r io.Reader) error {
as2.Wait()
log.WithContext(ctx).Debugf("开始执行插件ReceiveParseAfter!End")

if email == nil {
return nil
}

saveEmail(ctx, email, 0, SPFStatus, dkimStatus)

log.WithContext(ctx).Debugf("开始执行邮件规则!")
// 执行邮件规则
rs := rule.GetAllRules(ctx)
Expand Down

0 comments on commit e95930c

Please sign in to comment.