Version 0.1
This commit is contained in:
commit
7d677a2d83
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
13
assets/new_verification.txt
Normal file
13
assets/new_verification.txt
Normal file
@ -0,0 +1,13 @@
|
||||
New verification:
|
||||
ID: {{ .ID }}
|
||||
UserID: {{ .UserID }}
|
||||
Accepted: {{ .Accepted }}
|
||||
Status: {{ .Status }}
|
||||
UpdatedAt: {{ .UpdatedAt.Format "Mon, 02 Jan 2006 15:04:05 MST"}}
|
||||
Comment: {{ .Comment }}
|
||||
=============================
|
||||
Files
|
||||
=============================
|
||||
{{ range .Files }}
|
||||
Название: {{ .Name }} ({{ .Url }})
|
||||
{{ end }}
|
13
assets/updated_verification.txt
Normal file
13
assets/updated_verification.txt
Normal file
@ -0,0 +1,13 @@
|
||||
Updated verification:
|
||||
ID: {{ .ID }}
|
||||
UserID: {{ .UserID }}
|
||||
Accepted: {{ .Accepted }}
|
||||
Status: {{ .Status }}
|
||||
UpdatedAt: {{ .UpdatedAt.Format "Mon, 02 Jan 2006 15:04:05 MST"}}
|
||||
Comment: {{ .Comment }}
|
||||
=============================
|
||||
Files
|
||||
=============================
|
||||
{{ range .Files }}
|
||||
Название: {{ .Name }} ({{ .Url }})
|
||||
{{ end }}
|
16
cmd/verification/main.go
Normal file
16
cmd/verification/main.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"verification/internal/app"
|
||||
"verification/internal/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg, err := config.NewConfig("test.env")
|
||||
if err != nil {
|
||||
log.Fatal("can't load config: ", err.Error())
|
||||
}
|
||||
|
||||
app.Run(cfg)
|
||||
}
|
141
docs/openapi.yaml
Normal file
141
docs/openapi.yaml
Normal file
@ -0,0 +1,141 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: Сервис логики верификации аккаунта пользователя
|
||||
description: |-
|
||||
Область отвественности сервиса - получить на вход набор файлов необходимый для подтверждения статуса пользователя, оповещение менеджера для обработки поступившей заявки и оповещение польовательского сервиса о подтверждении статуса верификации пользователя
|
||||
version: 1.0.0
|
||||
tags:
|
||||
- name: verification
|
||||
paths:
|
||||
/verification/{userId}:
|
||||
get:
|
||||
description: метод для получения текущего статуса верификации текущего пользователя
|
||||
parameters:
|
||||
- name: userId
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
tags:
|
||||
- verification
|
||||
responses:
|
||||
'200':
|
||||
description: успешное получение данных
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Verification'
|
||||
'401':
|
||||
description: Неавторизован
|
||||
/verification:
|
||||
get:
|
||||
description: метод для получения текущего статуса верификации текущего пользователя
|
||||
tags:
|
||||
- verification
|
||||
responses:
|
||||
'200':
|
||||
description: успешное получение данных
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Verification'
|
||||
'401':
|
||||
description: Неавторизован
|
||||
post:
|
||||
description: метод подания запроса на верификацию. При получении запроса отправить сообщение в канал телеграмма. Айдишник канала и токен бота передавать через переменные окружения. Файл с шаблоном сообщения встраивать в приложение. В тексте сообщения должно быть место для вставки урла для получения страницы админки с этим запросом, вида https://admin.pena.digital/user/{Id}/verification
|
||||
tags:
|
||||
- verification
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
$ref: '#/components/schemas/Status'
|
||||
inn:
|
||||
type: file
|
||||
contentMediaType: application/pdf
|
||||
contentEncoding: base64
|
||||
rule:
|
||||
type: file
|
||||
contentMediaType: application/pdf
|
||||
contentEncoding: base64
|
||||
egrule:
|
||||
type: file
|
||||
contentMediaType: application/pdf
|
||||
contentEncoding: base64
|
||||
certificate:
|
||||
type: file
|
||||
description: только для status == nko
|
||||
contentMediaType: application/pdf
|
||||
contentEncoding: base64
|
||||
responses:
|
||||
'200':
|
||||
description: успешный запрос на верификацию
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Verification'
|
||||
'401':
|
||||
description: Неавторизован
|
||||
patch:
|
||||
description: метод подтверждения или отклонения верификации. При подтверждении надо передать статус верификации в customer сервис. Эндпоинт для этого получить из переменных окружения. Документация для этого эндпоинта - https://penahub.gitlab.yandexcloud.net/pena-services/customer/-/blob/dev/openapi.yaml PATCH /account/{userId}. Слать запрос туда лучше через воркер, сохраняя задачи на отправку запросов в базу, чтобы не потерялись при перезагрузке сервиса.
|
||||
tags:
|
||||
- verification
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: айдишник юзера
|
||||
status:
|
||||
$ref: '#/components/schemas/Status'
|
||||
comment:
|
||||
type: string
|
||||
accepted:
|
||||
type: boolean
|
||||
responses:
|
||||
'200':
|
||||
description: успешное подтверждение или отклонение верификации
|
||||
'401':
|
||||
description: Неавторизован
|
||||
components:
|
||||
schemas:
|
||||
Verification:
|
||||
type: object
|
||||
properties:
|
||||
_id:
|
||||
type: string
|
||||
description: айдишник юзера, который запросил верификацию
|
||||
accepted:
|
||||
type: boolean
|
||||
status:
|
||||
$ref: '#/components/schemas/Status'
|
||||
updated_at:
|
||||
type: string
|
||||
format: "date-time"
|
||||
comment:
|
||||
type: string
|
||||
files:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/File'
|
||||
File:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
Status:
|
||||
type: string
|
||||
description: только no, nko или org
|
||||
example: nko
|
||||
enum:
|
||||
- no
|
||||
- nko
|
||||
- org
|
67
go.mod
Normal file
67
go.mod
Normal file
@ -0,0 +1,67 @@
|
||||
module verification
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/caarlos0/env/v8 v8.0.0
|
||||
github.com/go-playground/validator/v10 v10.14.1
|
||||
github.com/gofiber/contrib/fiberzap v1.0.2
|
||||
github.com/gofiber/fiber/v2 v2.46.0
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/minio/minio-go/v7 v7.0.56
|
||||
go.mongodb.org/mongo-driver v1.11.7
|
||||
go.uber.org/zap v1.24.0
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20230222172022-007eb6fd0b1f
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/andybalholm/brotli v1.0.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 // indirect
|
||||
github.com/golang/snappy v0.0.1 // indirect
|
||||
github.com/google/go-cmp v0.5.8 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.16.5 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||
github.com/minio/md5-simd v1.1.2 // indirect
|
||||
github.com/minio/sha256-simd v1.0.1 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
|
||||
github.com/philhofer/fwd v1.1.2 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.3 // indirect
|
||||
github.com/rs/xid v1.5.0 // indirect
|
||||
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect
|
||||
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
|
||||
github.com/sirupsen/logrus v1.9.2 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
github.com/tinylib/msgp v1.1.8 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.47.0 // indirect
|
||||
github.com/valyala/tcplisten v1.0.0 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.1.1 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.3 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
203
go.sum
Normal file
203
go.sum
Normal file
@ -0,0 +1,203 @@
|
||||
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
|
||||
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
|
||||
github.com/caarlos0/env/v8 v8.0.0 h1:POhxHhSpuxrLMIdvTGARuZqR4Jjm8AYmoi/JKlcScs0=
|
||||
github.com/caarlos0/env/v8 v8.0.0/go.mod h1:7K4wMY9bH0esiXSSHlfHLX5xKGQMnkH5Fk4TDSSSzfo=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k=
|
||||
github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
|
||||
github.com/gofiber/contrib/fiberzap v1.0.2 h1:EQwhggtszVfIdBeXxN9Xrmld71es34Ufs+ef8VMqZxc=
|
||||
github.com/gofiber/contrib/fiberzap v1.0.2/go.mod h1:jGO8BHU4gRI9U0JtM6zj2CIhYfgVmW5JxziN8NTgVwE=
|
||||
github.com/gofiber/fiber/v2 v2.46.0 h1:wkkWotblsGVlLjXj2dpgKQAYHtXumsK/HyFugQM68Ns=
|
||||
github.com/gofiber/fiber/v2 v2.46.0/go.mod h1:DNl0/c37WLe0g92U6lx1VMQuxGUQY5V7EIaVoEsUffc=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
|
||||
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
|
||||
github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
||||
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
|
||||
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
|
||||
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||
github.com/minio/minio-go/v7 v7.0.56 h1:pkZplIEHu8vinjkmhsexcXpWth2tjVLphrTZx6fBVZY=
|
||||
github.com/minio/minio-go/v7 v7.0.56/go.mod h1:NUDy4A4oXPq1l2yK6LTSvCEzAMeIcoz9lcj5dbzSrRE=
|
||||
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
|
||||
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
|
||||
github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw=
|
||||
github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
|
||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 h1:rmMl4fXJhKMNWl+K+r/fq4FbbKI+Ia2m9hYBLm2h4G4=
|
||||
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94/go.mod h1:90zrgN3D/WJsDd1iXHT96alCoN2KJo6/4x1DZC3wZs8=
|
||||
github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d/go.mod h1:Gy+0tqhJvgGlqnTF8CVGP0AaGRjwBtXs/a5PA0Y3+A4=
|
||||
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee h1:8Iv5m6xEo1NR1AvpV+7XmhI4r39LGNzwUL4YpMuL5vk=
|
||||
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee/go.mod h1:qwtSXrKuJh/zsFQ12yEE89xfCrGKK63Rr7ctU/uCo4g=
|
||||
github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y=
|
||||
github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw=
|
||||
github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0=
|
||||
github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.47.0 h1:y7moDoxYzMooFpT5aHgNgVOQDrS3qlkfiP9mDtGGK9c=
|
||||
github.com/valyala/fasthttp v1.47.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA=
|
||||
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
|
||||
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
|
||||
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
|
||||
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
|
||||
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.mongodb.org/mongo-driver v1.11.7 h1:LIwYxASDLGUg/8wOhgOOZhX8tQa/9tgZPgzZoVqJvcs=
|
||||
go.mongodb.org/mongo-driver v1.11.7/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
|
||||
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
|
||||
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
||||
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
|
||||
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20230222172022-007eb6fd0b1f h1:/ACy953BoX+0T8nizgukSZe/+seDvLne0zJC2lAa4EU=
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20230222172022-007eb6fd0b1f/go.mod h1:SCqfOb+FHQayOQcxHQKd52Az4sur3hr3Lx1I4UiLf6g=
|
67
internal/app/app_verification.go
Normal file
67
internal/app/app_verification.go
Normal file
@ -0,0 +1,67 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"verification/internal/client"
|
||||
"verification/internal/config"
|
||||
"verification/internal/initialize"
|
||||
"verification/internal/server"
|
||||
)
|
||||
|
||||
func Run(cfg *config.Config) {
|
||||
cfgLogger := zap.NewDevelopmentConfig()
|
||||
cfgLogger.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
cfgLogger.EncoderConfig.ConsoleSeparator = " "
|
||||
|
||||
logger, err := cfgLogger.Build()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
logger.Info("RUN", zap.Any("ENV", cfg))
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
mongoClient, err := mongo.Connect(ctx, options.Client().ApplyURI(cfg.MongoUri))
|
||||
if err != nil {
|
||||
logger.Fatal("MongoClient", zap.Error(err))
|
||||
}
|
||||
|
||||
minioClient, err := minio.New(cfg.S3Endpoint, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(cfg.S3AccessKeyID, cfg.S3SecretKey, ""),
|
||||
Secure: false,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Fatal("MinioClient", zap.Error(err))
|
||||
}
|
||||
|
||||
reps, err := initialize.NewRepositories(ctx, logger, mongoClient, cfg.DatabaseName, minioClient)
|
||||
if err != nil {
|
||||
logger.Fatal("Repositories", zap.Error(err))
|
||||
}
|
||||
tgBot, err := tgbotapi.NewBotAPI(cfg.TelegramToken)
|
||||
if err != nil {
|
||||
logger.Fatal("TelegramBotApi", zap.Error(err))
|
||||
}
|
||||
|
||||
telegram := client.NewTelegram(logger, tgBot, cfg.TelegramChannelID)
|
||||
cons := initialize.NewControllers(reps, telegram, client.NewCustomer(logger, cfg.CustomerSvcAddress))
|
||||
|
||||
httpSrv := server.NewHTTP(cfg, logger).Register(cons.List()...)
|
||||
|
||||
go func() {
|
||||
err := httpSrv.Start()
|
||||
if err != nil {
|
||||
logger.Fatal("CanNotServe", zap.Error(err))
|
||||
}
|
||||
}()
|
||||
|
||||
gracefulShutdown(ctx, logger, httpSrv, mongoClient)
|
||||
}
|
32
internal/app/shutdown.go
Normal file
32
internal/app/shutdown.go
Normal file
@ -0,0 +1,32 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"verification/internal/server"
|
||||
)
|
||||
|
||||
func gracefulShutdown(ctx context.Context, logger *zap.Logger, httpSrv *server.HTTP, mongoClient *mongo.Client) {
|
||||
interrupt := make(chan os.Signal, 1)
|
||||
signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM)
|
||||
killSignal := <-interrupt
|
||||
switch killSignal {
|
||||
case os.Interrupt:
|
||||
logger.Info("AppInterrupted")
|
||||
case syscall.SIGTERM:
|
||||
logger.Info("AppTerminated")
|
||||
}
|
||||
|
||||
if err := httpSrv.Stop(); err != nil {
|
||||
logger.Error("HttpServerShutdown", zap.Error(err))
|
||||
}
|
||||
|
||||
if err := mongoClient.Disconnect(ctx); err != nil {
|
||||
logger.Error("BoltDB", zap.Error(err))
|
||||
}
|
||||
|
||||
}
|
52
internal/client/customer.go
Normal file
52
internal/client/customer.go
Normal file
@ -0,0 +1,52 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"go.uber.org/zap"
|
||||
"verification/internal/models"
|
||||
)
|
||||
|
||||
type Customer struct {
|
||||
logger *zap.Logger
|
||||
address string
|
||||
}
|
||||
|
||||
func NewCustomer(logger *zap.Logger, address string) *Customer {
|
||||
return &Customer{logger: logger, address: address}
|
||||
}
|
||||
|
||||
func (c *Customer) UpdateAccountVerification(userId, status string) (*models.RespUpdateVerificationStatus, error) {
|
||||
agent := fiber.Patch(fmt.Sprintf("%s/account/%s", c.address, userId))
|
||||
agent.JSON(&models.ReqCreateVerification{Status: status})
|
||||
|
||||
err := agent.Parse()
|
||||
if err != nil {
|
||||
c.logger.Error("CustomerUpdateAccountVerification", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var resp models.RespUpdateVerificationStatus
|
||||
statusCode, body, errs := agent.Struct(&resp)
|
||||
|
||||
if errs != nil || len(errs) > 0 {
|
||||
for _, err := range errs {
|
||||
c.logger.Error("CustomerUpdateAccountVerification", zap.Error(err))
|
||||
}
|
||||
return nil, errs[0]
|
||||
}
|
||||
|
||||
if statusCode != 200 {
|
||||
var respErr models.RespUpdateVerificationStatusError
|
||||
err = json.Unmarshal(body, &respErr)
|
||||
if err != nil {
|
||||
c.logger.Error("CustomerUpdateAccountVerification", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("got bad status: %v | %v", respErr.StatusCode, respErr.Message)
|
||||
}
|
||||
|
||||
return &resp, nil
|
||||
}
|
50
internal/client/telegram.go
Normal file
50
internal/client/telegram.go
Normal file
@ -0,0 +1,50 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"go.uber.org/zap"
|
||||
"text/template"
|
||||
"verification/internal/models"
|
||||
)
|
||||
|
||||
type Telegram struct {
|
||||
logger *zap.Logger
|
||||
bot *tgbotapi.BotAPI
|
||||
chatID int64
|
||||
}
|
||||
|
||||
func NewTelegram(logger *zap.Logger, bot *tgbotapi.BotAPI, chatID int64) *Telegram {
|
||||
return &Telegram{logger: logger, bot: bot, chatID: chatID}
|
||||
}
|
||||
|
||||
func (t *Telegram) SendVerification(data *models.Verification, isUpdate bool) error {
|
||||
tplPath := "assets/new_verification.txt"
|
||||
|
||||
if isUpdate {
|
||||
tplPath = "assets/updated_verification.txt"
|
||||
}
|
||||
|
||||
tpl, err := template.ParseFiles(tplPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var text bytes.Buffer
|
||||
|
||||
err = tpl.Execute(&text, data)
|
||||
if err != nil {
|
||||
t.logger.Error("ClientTelegram", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
msg := tgbotapi.NewMessage(t.chatID, text.String())
|
||||
|
||||
_, err = t.bot.Send(msg)
|
||||
if err != nil {
|
||||
t.logger.Error("ClientTelegram", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
31
internal/config/config.go
Normal file
31
internal/config/config.go
Normal file
@ -0,0 +1,31 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/caarlos0/env/v8"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
TelegramToken string `env:"TELEGRAM_TOKEN,required"`
|
||||
TelegramChannelID int64 `env:"TELEGRAM_CHANNEL_ID,required"`
|
||||
HttpAddress string `env:"HTTP_ADDRESS" envDefault:":80"`
|
||||
MongoUri string `env:"MONGO_URI,required"`
|
||||
DatabaseName string `env:"MONGO_DATABASE_NAME,required"`
|
||||
S3Endpoint string `env:"S3_ENDPOINT"`
|
||||
S3AccessKeyID string `env:"S3_ACCESS_KEY_ID"`
|
||||
S3SecretKey string `env:"S3_SECRET_KEY"`
|
||||
CustomerSvcAddress string `env:"CUSTOMER_SVC_ADDRESS,required"`
|
||||
}
|
||||
|
||||
func NewConfig(file ...string) (*Config, error) {
|
||||
if err := godotenv.Load(file...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var cfg Config
|
||||
if err := env.Parse(&cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &cfg, nil
|
||||
}
|
45
internal/controllers/controller.go
Normal file
45
internal/controllers/controller.go
Normal file
@ -0,0 +1,45 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"reflect"
|
||||
"verification/internal/models"
|
||||
)
|
||||
|
||||
var validate = validator.New()
|
||||
|
||||
type Route struct {
|
||||
Method string
|
||||
Path string
|
||||
Name string
|
||||
Handler fiber.Handler
|
||||
}
|
||||
|
||||
// validateStruct - возвращает строку с ошибкой, если структура не прошла валидацию
|
||||
func validateStruct(s any) []*models.RespErrorValidate {
|
||||
err := validate.Struct(s)
|
||||
|
||||
var errorsValidate []*models.RespErrorValidate
|
||||
if err != nil {
|
||||
for _, err := range err.(validator.ValidationErrors) {
|
||||
field := err.Field()
|
||||
|
||||
r, _ := reflect.TypeOf(s).Elem().FieldByName(err.Field())
|
||||
if queryTag := r.Tag.Get("query"); queryTag != "" {
|
||||
field = queryTag
|
||||
}
|
||||
if jsonTag := r.Tag.Get("json"); jsonTag != "" {
|
||||
field = jsonTag
|
||||
}
|
||||
|
||||
errorsValidate = append(errorsValidate, &models.RespErrorValidate{
|
||||
Field: field,
|
||||
Tag: err.Tag(),
|
||||
Value: err.Param(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return errorsValidate
|
||||
}
|
164
internal/controllers/verification.go
Normal file
164
internal/controllers/verification.go
Normal file
@ -0,0 +1,164 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"mime/multipart"
|
||||
"verification/internal/client"
|
||||
"verification/internal/models"
|
||||
"verification/internal/repository"
|
||||
)
|
||||
|
||||
type VerificationController struct {
|
||||
repository *repository.VerificationRepository
|
||||
telegram *client.Telegram
|
||||
customer *client.Customer
|
||||
}
|
||||
|
||||
func NewVerificationController(rep *repository.VerificationRepository, telegram *client.Telegram, customer *client.Customer) *VerificationController {
|
||||
return &VerificationController{repository: rep, telegram: telegram, customer: customer}
|
||||
}
|
||||
|
||||
func (r *VerificationController) GetRoutes() []Route {
|
||||
return []Route{
|
||||
{"GET", "/verification/:userID", "GetVerification", r.GetVerification},
|
||||
{"POST", "/verification", "CreateVerification", r.CreateVerification},
|
||||
{"PATCH", "/verification", "SetVerificationStatus", r.SetVerificationStatus},
|
||||
}
|
||||
}
|
||||
|
||||
func (r *VerificationController) GetVerification(c *fiber.Ctx) error {
|
||||
userID := c.Params("userID")
|
||||
|
||||
if userID == "" {
|
||||
userID = c.Locals("userID").(string)
|
||||
if userID == "" {
|
||||
return fiber.NewError(fiber.StatusUnauthorized)
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := r.repository.GetByUserId(c.Context(), userID)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).SendString(err.Error())
|
||||
}
|
||||
|
||||
if resp == nil {
|
||||
return c.SendStatus(fiber.StatusOK)
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).JSON(resp)
|
||||
}
|
||||
|
||||
func (r *VerificationController) CreateVerification(c *fiber.Ctx) error {
|
||||
var req models.ReqCreateVerification
|
||||
|
||||
userID := c.Params("userID")
|
||||
|
||||
if userID == "" {
|
||||
userID = c.Locals("userID").(string)
|
||||
if userID == "" {
|
||||
return fiber.NewError(fiber.StatusUnauthorized)
|
||||
}
|
||||
}
|
||||
|
||||
err := c.BodyParser(&req)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
errValidate := validateStruct(&req)
|
||||
if errValidate != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(errValidate)
|
||||
}
|
||||
|
||||
// INN FILE
|
||||
innFH, err := c.FormFile("inn")
|
||||
|
||||
if err != nil || innFH.Size == 0 || innFH == nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "inn file required")
|
||||
}
|
||||
|
||||
// RULE FILE
|
||||
ruleFH, err := c.FormFile("rule")
|
||||
|
||||
if err != nil || ruleFH.Size == 0 || ruleFH == nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "rule file required")
|
||||
}
|
||||
|
||||
// EGRULE FILE
|
||||
egruleFH, err := c.FormFile("egrule")
|
||||
|
||||
if err != nil || egruleFH.Size == 0 || egruleFH == nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "egrule file required")
|
||||
}
|
||||
|
||||
// CERTIFICATE FILE
|
||||
var certFH *multipart.FileHeader
|
||||
if req.Status == "nko" {
|
||||
certFH, err = c.FormFile("certificate")
|
||||
if err != nil || certFH.Size == 0 || certFH == nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "certificate file required")
|
||||
}
|
||||
} else {
|
||||
certFH = nil
|
||||
}
|
||||
|
||||
result, err := r.repository.Insert(c.Context(), userID, &models.Verification{
|
||||
UserID: userID,
|
||||
Accepted: false,
|
||||
Status: req.Status,
|
||||
Comment: "",
|
||||
}, innFH, ruleFH, egruleFH, certFH)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
err = r.telegram.SendVerification(result, false)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).JSON(result)
|
||||
}
|
||||
|
||||
func (r *VerificationController) SetVerificationStatus(c *fiber.Ctx) error {
|
||||
var req models.ReqSetVerification
|
||||
|
||||
userID := c.Params("userID")
|
||||
|
||||
if userID == "" {
|
||||
userID = c.Locals("userID").(string)
|
||||
if userID == "" {
|
||||
return fiber.NewError(fiber.StatusUnauthorized)
|
||||
}
|
||||
}
|
||||
|
||||
err := c.BodyParser(&req)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
errValidate := validateStruct(&req)
|
||||
if errValidate != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(errValidate)
|
||||
}
|
||||
|
||||
updated, err := r.repository.Update(c.Context(), &models.Verification{
|
||||
ID: req.ID,
|
||||
UserID: userID,
|
||||
Accepted: req.Accepted,
|
||||
Status: req.Status,
|
||||
Comment: req.Comment,
|
||||
})
|
||||
|
||||
err = r.telegram.SendVerification(updated, true)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
_, err = r.customer.UpdateAccountVerification(userID, req.Status)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return c.SendStatus(fiber.StatusOK)
|
||||
}
|
34
internal/initialize/controllers.go
Normal file
34
internal/initialize/controllers.go
Normal file
@ -0,0 +1,34 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"verification/internal/client"
|
||||
"verification/internal/controllers"
|
||||
)
|
||||
|
||||
type Controller interface {
|
||||
GetRoutes() []controllers.Route
|
||||
}
|
||||
|
||||
type Controllers struct {
|
||||
Verification *controllers.VerificationController
|
||||
}
|
||||
|
||||
func (c *Controllers) List() []Controller {
|
||||
fields := reflect.ValueOf(c).Elem()
|
||||
|
||||
var controllersArr []Controller
|
||||
for i := 0; i < fields.NumField(); i++ {
|
||||
vf := fields.Field(i)
|
||||
|
||||
if vf.Type().Implements(reflect.TypeOf((*Controller)(nil)).Elem()) {
|
||||
controllersArr = append(controllersArr, vf.Interface().(Controller))
|
||||
}
|
||||
}
|
||||
|
||||
return controllersArr
|
||||
}
|
||||
|
||||
func NewControllers(reps *Repositories, telegram *client.Telegram, customer *client.Customer) *Controllers {
|
||||
return &Controllers{Verification: controllers.NewVerificationController(reps.Verification, telegram, customer)}
|
||||
}
|
29
internal/initialize/repositories.go
Normal file
29
internal/initialize/repositories.go
Normal file
@ -0,0 +1,29 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.uber.org/zap"
|
||||
"verification/internal/repository"
|
||||
)
|
||||
|
||||
type Repositories struct {
|
||||
Verification *repository.VerificationRepository
|
||||
}
|
||||
|
||||
func NewRepositories(
|
||||
ctx context.Context,
|
||||
logger *zap.Logger,
|
||||
mongoClient *mongo.Client,
|
||||
dbName string,
|
||||
s3 *minio.Client) (*Repositories, error) {
|
||||
reps := &Repositories{Verification: repository.NewVerificationRepository(logger, mongoClient.Database(dbName), s3)}
|
||||
|
||||
err := reps.Verification.Init(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return reps, nil
|
||||
}
|
36
internal/models/customer.go
Normal file
36
internal/models/customer.go
Normal file
@ -0,0 +1,36 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type ReqUpdateVerificationStatus struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type RespUpdateVerificationStatus struct {
|
||||
Id string `json:"_id"`
|
||||
UserId string `json:"userId"`
|
||||
Name struct {
|
||||
Firstname string `json:"firstname"`
|
||||
Secondname string `json:"secondname"`
|
||||
Lastname string `json:"lastname"`
|
||||
Orgname string `json:"orgname"`
|
||||
} `json:"name"`
|
||||
Cart []string `json:"cart"`
|
||||
Wallet struct {
|
||||
Currency string `json:"currency"`
|
||||
Cash int `json:"cash"`
|
||||
PurchasesAmount int `json:"purchasesAmount"`
|
||||
Spent int `json:"spent"`
|
||||
Money int `json:"money"`
|
||||
} `json:"wallet"`
|
||||
Status string `json:"status"`
|
||||
Deleted bool `json:"deleted"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt time.Time `json:"deletedAt"`
|
||||
}
|
||||
|
||||
type RespUpdateVerificationStatusError struct {
|
||||
StatusCode int `json:"statusCode"`
|
||||
Message string `json:"message"`
|
||||
}
|
12
internal/models/requests.go
Normal file
12
internal/models/requests.go
Normal file
@ -0,0 +1,12 @@
|
||||
package models
|
||||
|
||||
type ReqCreateVerification struct {
|
||||
Status string `json:"status" form:"status" validate:"oneof=no nko org"`
|
||||
}
|
||||
|
||||
type ReqSetVerification struct {
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
Comment string `json:"comment"`
|
||||
Accepted bool `json:"accepted"`
|
||||
}
|
1
internal/models/responses.go
Normal file
1
internal/models/responses.go
Normal file
@ -0,0 +1 @@
|
||||
package models
|
7
internal/models/validate.go
Normal file
7
internal/models/validate.go
Normal file
@ -0,0 +1,7 @@
|
||||
package models
|
||||
|
||||
type RespErrorValidate struct {
|
||||
Field string `json:"field"`
|
||||
Tag string `json:"tag"`
|
||||
Value string `json:"value"`
|
||||
}
|
18
internal/models/verification.go
Normal file
18
internal/models/verification.go
Normal file
@ -0,0 +1,18 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Verification struct {
|
||||
ID string `json:"_id" bson:"_id,omitempty"`
|
||||
UserID string `json:"userID" bson:"user_id,omitempty"`
|
||||
Accepted bool `json:"accepted" bson:"accepted,omitempty"`
|
||||
Status string `json:"status" bson:"status,omitempty"`
|
||||
UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
|
||||
Comment string `json:"comment" bson:"comment,omitempty"`
|
||||
Files []VerificationFiles `json:"files" bson:"files,omitempty"`
|
||||
}
|
||||
|
||||
type VerificationFiles struct {
|
||||
Name string `json:"name" bson:"name"`
|
||||
Url string `json:"url" bson:"url"`
|
||||
}
|
221
internal/repository/verification.go
Normal file
221
internal/repository/verification.go
Normal file
@ -0,0 +1,221 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/policy"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"go.uber.org/zap"
|
||||
"mime/multipart"
|
||||
"time"
|
||||
"verification/internal/models"
|
||||
)
|
||||
|
||||
type VerificationRepository struct {
|
||||
logger *zap.Logger
|
||||
mongo *mongo.Collection
|
||||
s3 *minio.Client
|
||||
}
|
||||
|
||||
const (
|
||||
VerificationBucket = "verification"
|
||||
VerificationCollection = "verification"
|
||||
)
|
||||
|
||||
func NewVerificationRepository(logger *zap.Logger, mongoDb *mongo.Database, s3 *minio.Client) *VerificationRepository {
|
||||
return &VerificationRepository{
|
||||
logger: logger,
|
||||
mongo: mongoDb.Collection(VerificationCollection),
|
||||
s3: s3,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *VerificationRepository) Init(ctx context.Context) error {
|
||||
ok, err := r.s3.BucketExists(ctx, VerificationBucket)
|
||||
if r.err(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
if !ok {
|
||||
err = r.s3.MakeBucket(ctx, VerificationBucket, minio.MakeBucketOptions{})
|
||||
if r.err(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
p := policy.BucketAccessPolicy{Version: "2012-10-17"}
|
||||
|
||||
p.Statements = policy.SetPolicy(p.Statements, policy.BucketPolicyReadOnly, VerificationBucket, "*/*")
|
||||
|
||||
outPolicy, err := json.Marshal(&p)
|
||||
if r.err(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
err = r.s3.SetBucketPolicy(ctx, VerificationBucket, string(outPolicy))
|
||||
if r.err(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *VerificationRepository) Insert(
|
||||
ctx context.Context,
|
||||
userID string,
|
||||
record *models.Verification,
|
||||
innFH, ruleFH, egruleFH, certFH *multipart.FileHeader) (*models.Verification, error) {
|
||||
now := time.Now()
|
||||
record.ID = primitive.NewObjectIDFromTimestamp(now).Hex()
|
||||
record.UpdatedAt = now
|
||||
|
||||
// Put inn file
|
||||
inn, err := innFH.Open()
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = r.s3.PutObject(ctx, VerificationBucket, fmt.Sprintf("%s/%s", userID, innFH.Filename), inn, innFH.Size, minio.PutObjectOptions{})
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rule, err := ruleFH.Open()
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Put rule file
|
||||
_, err = r.s3.PutObject(ctx, VerificationBucket, fmt.Sprintf("%s/%s", userID, ruleFH.Filename), rule, ruleFH.Size, minio.PutObjectOptions{})
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Put egrule file
|
||||
egrule, err := egruleFH.Open()
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = r.s3.PutObject(ctx, VerificationBucket, fmt.Sprintf("%s/%s", userID, egruleFH.Filename), egrule, egruleFH.Size, minio.PutObjectOptions{})
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Put certificate file
|
||||
if certFH != nil {
|
||||
cert, err := certFH.Open()
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = r.s3.PutObject(ctx, VerificationBucket, fmt.Sprintf("%s/%s", userID, certFH.Filename), cert, certFH.Size, minio.PutObjectOptions{})
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
record.Files = []models.VerificationFiles{
|
||||
{
|
||||
Name: "certificate",
|
||||
Url: fmt.Sprintf("%s/verification/%s/%s", r.s3.EndpointURL(), userID, certFH.Filename),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Insert to MongoDB
|
||||
record.Files = append(record.Files, []models.VerificationFiles{
|
||||
{
|
||||
Name: "inn",
|
||||
Url: fmt.Sprintf("%s/verification/%s/%s", r.s3.EndpointURL(), userID, innFH.Filename),
|
||||
},
|
||||
{
|
||||
Name: "rule",
|
||||
Url: fmt.Sprintf("%s/verification/%s/%s", r.s3.EndpointURL(), userID, ruleFH.Filename),
|
||||
},
|
||||
{
|
||||
Name: "egrule",
|
||||
Url: fmt.Sprintf("%s/verification/%s/%s", r.s3.EndpointURL(), userID, egruleFH.Filename),
|
||||
},
|
||||
}...)
|
||||
|
||||
result, err := r.mongo.InsertOne(ctx, record)
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
record.ID = result.InsertedID.(string)
|
||||
return record, nil
|
||||
}
|
||||
|
||||
func (r *VerificationRepository) GetByUserId(ctx context.Context, userID string) (*models.Verification, error) {
|
||||
if userID == "" {
|
||||
err := errors.New("userID cannot be empty")
|
||||
r.logger.Error("VerificationRepositoryError", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filter := bson.M{
|
||||
"user_id": userID,
|
||||
}
|
||||
|
||||
var result models.Verification
|
||||
err := r.mongo.FindOne(ctx, filter).Decode(&result)
|
||||
if err != nil {
|
||||
if err == mongo.ErrNoDocuments {
|
||||
return nil, nil
|
||||
}
|
||||
r.logger.Error("VerificationRepositoryError", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r *VerificationRepository) Get(ctx context.Context, id string) (*models.Verification, error) {
|
||||
if id == "" {
|
||||
err := errors.New("_id cannot be empty")
|
||||
r.logger.Error("VerificationRepositoryError", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filter := bson.M{
|
||||
"_id": id,
|
||||
}
|
||||
|
||||
var result models.Verification
|
||||
err := r.mongo.FindOne(ctx, filter).Decode(&result)
|
||||
if err != nil {
|
||||
if err == mongo.ErrNoDocuments {
|
||||
return nil, nil
|
||||
}
|
||||
r.logger.Error("VerificationRepositoryError", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r *VerificationRepository) Update(ctx context.Context, record *models.Verification) (*models.Verification, error) {
|
||||
record.UpdatedAt = time.Now()
|
||||
|
||||
var result models.Verification
|
||||
err := r.mongo.FindOneAndUpdate(ctx, bson.M{"_id": record.ID}, bson.M{"$set": record}, options.FindOneAndUpdate().SetReturnDocument(options.After)).Decode(&result)
|
||||
if r.err(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
func (r *VerificationRepository) err(err error) bool {
|
||||
if err != nil {
|
||||
r.logger.Error("VerificationRepositoryError", zap.Error(err))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
54
internal/server/http.go
Normal file
54
internal/server/http.go
Normal file
@ -0,0 +1,54 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/gofiber/contrib/fiberzap"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
"go.uber.org/zap"
|
||||
"verification/internal/config"
|
||||
"verification/internal/initialize"
|
||||
)
|
||||
|
||||
type HTTP struct {
|
||||
fiber *fiber.App
|
||||
cfg *config.Config
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func NewHTTP(cfg *config.Config, logger *zap.Logger) *HTTP {
|
||||
srv := fiber.New(fiber.Config{
|
||||
AppName: "Verification",
|
||||
ErrorHandler: fiber.DefaultErrorHandler,
|
||||
BodyLimit: 50 << 20,
|
||||
})
|
||||
|
||||
srv.Use(
|
||||
recover.New(recover.Config{EnableStackTrace: true}),
|
||||
fiberzap.New(fiberzap.Config{Logger: logger}),
|
||||
LocalJwt(),
|
||||
Jwt(),
|
||||
)
|
||||
|
||||
return &HTTP{fiber: srv, cfg: cfg, logger: logger}
|
||||
}
|
||||
|
||||
// Register - автоматически регистрирует все контроллеры
|
||||
func (srv *HTTP) Register(controllers ...initialize.Controller) *HTTP {
|
||||
for _, controller := range controllers {
|
||||
for _, route := range controller.GetRoutes() {
|
||||
srv.fiber.Add(route.Method, route.Path, route.Handler).Name(route.Name)
|
||||
}
|
||||
|
||||
}
|
||||
return srv
|
||||
}
|
||||
|
||||
// Start - запускает http сервер
|
||||
func (srv *HTTP) Start() error {
|
||||
return srv.fiber.Listen(srv.cfg.HttpAddress)
|
||||
}
|
||||
|
||||
// Stop - останавливает http сервер
|
||||
func (srv *HTTP) Stop() error {
|
||||
return srv.fiber.Shutdown()
|
||||
}
|
42
internal/server/middleware.go
Normal file
42
internal/server/middleware.go
Normal file
@ -0,0 +1,42 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"penahub.gitlab.yandexcloud.net/backend/penahub_common/jwt_adapter"
|
||||
)
|
||||
|
||||
func LocalJwt() fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
if c.Get("LocalUserID") != "" {
|
||||
c.Locals("userID", c.Get("LocalUserID"))
|
||||
}
|
||||
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func Jwt() fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
// check LocalJwt
|
||||
if c.Locals("userID") != nil {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
jwt, err := jwt_adapter.Decode(c.Cookies(jwt_adapter.DefaultHeaderKey))
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusUnauthorized, err.Error())
|
||||
}
|
||||
|
||||
err = jwt.Validate()
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusUnauthorized, err.Error())
|
||||
}
|
||||
|
||||
if jwt.GetUserID() == "" {
|
||||
return fiber.NewError(fiber.StatusUnauthorized, "empty user")
|
||||
}
|
||||
|
||||
c.Locals("userID", jwt.GetUserID())
|
||||
return c.Next()
|
||||
}
|
||||
}
|
9
test.env
Normal file
9
test.env
Normal file
@ -0,0 +1,9 @@
|
||||
TELEGRAM_TOKEN=6016088135:AAH3KFBfsi5ivoS0bF9f0p6j28HNuwoBNn0
|
||||
TELEGRAM_CHANNEL_ID=799820146
|
||||
MONGO_URI=mongodb://localmongo1:30001,localmongo2:30002,localmongo3:30003/?replicaSet=my-rs
|
||||
MONGO_DATABASE_NAME=verification
|
||||
S3_ENDPOINT=localhost:9000
|
||||
S3_ACCESS_KEY_ID=minioadmin
|
||||
S3_SECRET_KEY=minioadmin
|
||||
HTTP_RATE_LIMIT=30s
|
||||
HTTP_ADDRESS=:80
|
Loading…
Reference in New Issue
Block a user