Skip to content

Commit

Permalink
v2.6.1
Browse files Browse the repository at this point in the history
1、新增垃圾邮件过滤插件
2、使用使用github.com/dlclark/regexp2替换go原生的正则包
3、修复空数据导致的邮件插入失败
  • Loading branch information
Jinnrry committed Jul 20, 2024
1 parent 9ffbdf4 commit 19b8b3d
Show file tree
Hide file tree
Showing 78 changed files with 1,123 additions and 329 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
echo "TGFILENAME=telegram_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
echo "WCFILENAME=wechat_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
echo "WEBFILENAME=web_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
echo "SPAMBLOCKFILENAME=spam_block_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
echo "ZIPNAME=${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
- name: Rename Windows File
if: matrix.goos == 'windows'
Expand All @@ -50,6 +51,7 @@ jobs:
echo "TGFILENAME=telegram_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
echo "WCFILENAME=wechat_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
echo "WEBFILENAME=web_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
echo "SPAMBLOCKFILENAME=spam_block_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
- name: FE Build
run: cd fe && yarn && yarn build
- name: BE Build
Expand All @@ -59,6 +61,7 @@ jobs:
go build -ldflags "-s -w" -o ${{ env.TGFILENAME }} hooks/telegram_push/telegram_push.go
go build -ldflags "-s -w" -o ${{ env.WEBFILENAME }} hooks/web_push/web_push.go
go build -ldflags "-s -w" -o ${{ env.WCFILENAME }} hooks/wechat_push/wechat_push.go
go build -ldflags "-s -w" -o ${{ env.SPAMBLOCKFILENAME }} hooks/spam_blcok/spam_blcok.go
ls -alh
- name: Zip
run: |
Expand All @@ -67,6 +70,7 @@ jobs:
mv ${{ env.TGFILENAME }} plugins/
mv ${{ env.WEBFILENAME }} plugins/
mv ${{ env.WCFILENAME }} plugins/
mv ${{ env.SPAMBLOCKFILENAME }} plugins/
zip -r ${{ env.ZIPNAME }}.zip ${{ env.FILENAME }} plugins
ls
- name: Upload files to Artifacts
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN cd /work/server && go build -ldflags "-s -w -X 'main.version=${VERSION}' -X
RUN cd /work/server/hooks/telegram_push && go build -ldflags "-s -w" -o output/telegram_push telegram_push.go
RUN cd /work/server/hooks/web_push && go build -ldflags "-s -w" -o output/web_push web_push.go
RUN cd /work/server/hooks/wechat_push && go build -ldflags "-s -w" -o output/wechat_push wechat_push.go
RUN cd /work/server/hooks/spam_blcok && go build -ldflags "-s -w" -o output/spam_blcok spam_blcok.go


FROM alpine
Expand All @@ -34,6 +35,7 @@ COPY --from=serverbuild /work/server/pmail .
COPY --from=serverbuild /work/server/hooks/telegram_push/output/* ./plugins/
COPY --from=serverbuild /work/server/hooks/web_push/output/* ./plugins/
COPY --from=serverbuild /work/server/hooks/wechat_push/output/* ./plugins/
COPY --from=serverbuild /work/server/hooks/spam_blcok/output/* ./plugins/

EXPOSE 25 80 110 443 465 995

Expand Down
2 changes: 2 additions & 0 deletions DockerfileGithubAction
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN go build -ldflags "-s -w -X 'main.version=${VERSION}' -X 'main.goVersion=$(g
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
RUN cd /work/hooks/spam_blcok && go build -ldflags "-s -w" -o output/spam_blcok spam_blcok.go


FROM alpine
Expand All @@ -28,6 +29,7 @@ COPY --from=serverbuild /work/pmail .
COPY --from=serverbuild /work/hooks/telegram_push/output/* ./plugins/
COPY --from=serverbuild /work/hooks/web_push/output/* ./plugins/
COPY --from=serverbuild /work/hooks/wechat_push/output/* ./plugins/
COPY --from=serverbuild /work/hooks/spam_blcok/output/* ./plugins/

EXPOSE 25 80 110 443 465 995

Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ wechat_push:
cd server/hooks/wechat_push && CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o output/wechat_push_mac_amd64 wechat_push.go
cd server/hooks/wechat_push && CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -o output/wechat_push_mac_arm64 wechat_push.go

spam_block:
cd server/hooks/spam_block && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o output/spam_block_linux_amd64 spam_block.go
cd server/hooks/spam_block && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o output/spam_block_windows_amd64.exe spam_block.go
cd server/hooks/spam_block && CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o output/spam_block_mac_amd64 spam_block.go
cd server/hooks/spam_block && CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -o output/spam_block_mac_arm64 spam_block.go



plugin: telegram_push wechat_push web_push


Expand Down
6 changes: 3 additions & 3 deletions server/controllers/attachments.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package controllers

import (
"fmt"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/services/attachments"
"github.com/Jinnrry/pmail/utils/context"
"github.com/spf13/cast"
"net/http"
"pmail/dto/response"
"pmail/services/attachments"
"pmail/utils/context"
"strings"
)

Expand Down
2 changes: 1 addition & 1 deletion server/controllers/base.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package controllers

import (
"github.com/Jinnrry/pmail/utils/context"
"net/http"
"pmail/utils/context"
)

type HandlerFunc func(*context.Context, http.ResponseWriter, *http.Request)
6 changes: 3 additions & 3 deletions server/controllers/email/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package email

import (
"encoding/json"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/services/del_email"
"github.com/Jinnrry/pmail/utils/context"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"pmail/dto/response"
"pmail/services/del_email"
"pmail/utils/context"
)

type emailDeleteRequest struct {
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/email/detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package email

import (
"encoding/json"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/services/detail"
"github.com/Jinnrry/pmail/utils/context"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"pmail/dto/response"
"pmail/services/detail"
"pmail/utils/context"
)

type emailDetailRequest struct {
Expand Down
8 changes: 4 additions & 4 deletions server/controllers/email/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package email

import (
"encoding/json"
"github.com/Jinnrry/pmail/dto"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/services/list"
"github.com/Jinnrry/pmail/utils/context"
log "github.com/sirupsen/logrus"
"github.com/spf13/cast"
"io"
"math"
"net/http"
"pmail/dto"
"pmail/dto/response"
"pmail/services/list"
"pmail/utils/context"
)

type emailListResponse struct {
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/email/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package email

import (
"encoding/json"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/services/group"
"github.com/Jinnrry/pmail/utils/context"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"pmail/dto/response"
"pmail/services/group"
"pmail/utils/context"
)

type moveRequest struct {
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/email/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package email

import (
"encoding/json"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/services/detail"
"github.com/Jinnrry/pmail/utils/context"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"pmail/dto/response"
"pmail/services/detail"
"pmail/utils/context"
)

type markReadRequest struct {
Expand Down
63 changes: 32 additions & 31 deletions server/controllers/email/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import (
"database/sql"
"encoding/base64"
"encoding/json"
"github.com/Jinnrry/pmail/config"
"github.com/Jinnrry/pmail/db"
"github.com/Jinnrry/pmail/dto/parsemail"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/hooks"
"github.com/Jinnrry/pmail/hooks/framework"
"github.com/Jinnrry/pmail/i18n"
"github.com/Jinnrry/pmail/models"
"github.com/Jinnrry/pmail/utils/array"
"github.com/Jinnrry/pmail/utils/async"
"github.com/Jinnrry/pmail/utils/context"
"github.com/Jinnrry/pmail/utils/send"
log "github.com/sirupsen/logrus"
"github.com/spf13/cast"
"io"
"net/http"
"pmail/config"
"pmail/db"
"pmail/dto/parsemail"
"pmail/dto/response"
"pmail/hooks"
"pmail/hooks/framework"
"pmail/i18n"
"pmail/models"
"pmail/utils/array"
"pmail/utils/async"
"pmail/utils/context"
"pmail/utils/send"
"strings"
"time"
)
Expand Down Expand Up @@ -168,30 +168,31 @@ func Send(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
log.WithContext(ctx).Debugf("插件执行--SendBefore End")

modelEmail := models.Email{
Type: 1,
Subject: e.Subject,
ReplyTo: json2string(e.ReplyTo),
FromName: e.From.Name,
FromAddress: e.From.EmailAddress,
To: json2string(e.To),
Bcc: json2string(e.Bcc),
Cc: json2string(e.Cc),
Text: sql.NullString{String: string(e.Text), Valid: true},
Html: sql.NullString{String: string(e.HTML), Valid: true},
Sender: json2string(e.Sender),
Attachments: json2string(e.Attachments),
SPFCheck: 1,
DKIMCheck: 1,
SendUserID: ctx.UserID,
SendDate: time.Now(),
Status: 1,
CreateTime: time.Now(),
Type: 1,
Subject: e.Subject,
ReplyTo: json2string(e.ReplyTo),
FromName: e.From.Name,
FromAddress: e.From.EmailAddress,
To: json2string(e.To),
Bcc: json2string(e.Bcc),
Cc: json2string(e.Cc),
Text: sql.NullString{String: string(e.Text), Valid: true},
Html: sql.NullString{String: string(e.HTML), Valid: true},
Sender: json2string(e.Sender),
Attachments: json2string(e.Attachments),
SPFCheck: 1,
DKIMCheck: 1,
SendUserID: ctx.UserID,
SendDate: time.Now(),
CronSendTime: time.Now(),
Status: 1,
CreateTime: time.Now(),
}

_, err = db.Instance.Insert(&modelEmail)

if err != nil || modelEmail.Id <= 0 {
log.Println("mysql insert error:", err.Error())
log.Println("insert error:", err.Error())
response.NewErrorResponse(response.ServerError, i18n.GetText(ctx.Lang, "send_fail"), err.Error()).FPrint(w)
return
}
Expand Down
16 changes: 8 additions & 8 deletions server/controllers/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package controllers

import (
"encoding/json"
"github.com/Jinnrry/pmail/db"
"github.com/Jinnrry/pmail/dto"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/i18n"
"github.com/Jinnrry/pmail/models"
"github.com/Jinnrry/pmail/services/group"
"github.com/Jinnrry/pmail/utils/array"
"github.com/Jinnrry/pmail/utils/context"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"pmail/db"
"pmail/dto"
"pmail/dto/response"
"pmail/i18n"
"pmail/models"
"pmail/services/group"
"pmail/utils/array"
"pmail/utils/context"
)

func GetUserGroupList(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/interceptor.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package controllers

import (
"github.com/Jinnrry/pmail/config"
"net/http"
"pmail/config"
)

func Interceptor(w http.ResponseWriter, r *http.Request) {
Expand Down
20 changes: 10 additions & 10 deletions server/controllers/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package controllers
import (
"database/sql"
"encoding/json"
"github.com/Jinnrry/pmail/config"
"github.com/Jinnrry/pmail/db"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/i18n"
"github.com/Jinnrry/pmail/models"
"github.com/Jinnrry/pmail/session"
"github.com/Jinnrry/pmail/utils/array"
"github.com/Jinnrry/pmail/utils/context"
"github.com/Jinnrry/pmail/utils/errors"
"github.com/Jinnrry/pmail/utils/password"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"pmail/config"
"pmail/db"
"pmail/dto/response"
"pmail/i18n"
"pmail/models"
"pmail/session"
"pmail/utils/array"
"pmail/utils/context"
"pmail/utils/errors"
"pmail/utils/password"
)

type loginRequest struct {
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/ping.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package controllers

import (
"github.com/Jinnrry/pmail/dto/response"
"net/http"
"pmail/dto/response"
)

func Ping(w http.ResponseWriter, req *http.Request) {
Expand Down
20 changes: 10 additions & 10 deletions server/controllers/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package controllers

import (
"encoding/json"
"github.com/Jinnrry/pmail/db"
"github.com/Jinnrry/pmail/dto"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/i18n"
"github.com/Jinnrry/pmail/models"
"github.com/Jinnrry/pmail/services/rule"
"github.com/Jinnrry/pmail/utils/address"
"github.com/Jinnrry/pmail/utils/array"
"github.com/Jinnrry/pmail/utils/context"
"github.com/Jinnrry/pmail/utils/errors"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"pmail/db"
"pmail/dto"
"pmail/dto/response"
"pmail/i18n"
"pmail/models"
"pmail/services/rule"
"pmail/utils/address"
"pmail/utils/array"
"pmail/utils/context"
"pmail/utils/errors"
)

func GetRule(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
Expand Down
10 changes: 5 additions & 5 deletions server/controllers/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package controllers

import (
"encoding/json"
"github.com/Jinnrry/pmail/db"
"github.com/Jinnrry/pmail/dto/response"
"github.com/Jinnrry/pmail/i18n"
"github.com/Jinnrry/pmail/utils/context"
"github.com/Jinnrry/pmail/utils/password"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"pmail/db"
"pmail/dto/response"
"pmail/i18n"
"pmail/utils/context"
"pmail/utils/password"
)

type modifyPasswordRequest struct {
Expand Down
Loading

0 comments on commit 19b8b3d

Please sign in to comment.