From 38d91d9f105764845ed0d70eae6ca5b69408eb02 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 26 Aug 2025 09:50:45 +0300 Subject: [PATCH] =?UTF-8?q?v.0.1=20=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=20?= =?UTF-8?q?=D0=BC=D0=B8=D0=BA=D1=80=D0=BE=D1=81=D0=B5=D1=80=D0=B2=D0=B8?= =?UTF-8?q?=D1=81=20=D0=BF=D0=BE=D0=B4=D0=BF=D0=B8=D1=81=D0=BE=D0=BA/?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=BF=D0=B8=D1=81=D1=87=D0=B8=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 21 + .idea/.gitignore | 8 + .idea/modules.xml | 8 + .idea/tailly_subscribers.iml | 9 + .idea/vcs.xml | 6 + Dockerfile | 46 ++ go.mod | 29 + go.sum | 269 +++++++ proto/subscribe.pb.go | 1304 ++++++++++++++++++++++++++++++++++ proto/subscribe.proto | 154 ++++ proto/subscribe_grpc.pb.go | 447 ++++++++++++ server.go | 413 +++++++++++ server_test.go | 408 +++++++++++ 13 files changed, 3122 insertions(+) create mode 100644 .drone.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/modules.xml create mode 100644 .idea/tailly_subscribers.iml create mode 100644 .idea/vcs.xml create mode 100644 Dockerfile create mode 100644 go.mod create mode 100644 go.sum create mode 100644 proto/subscribe.pb.go create mode 100644 proto/subscribe.proto create mode 100644 proto/subscribe_grpc.pb.go create mode 100644 server.go create mode 100644 server_test.go diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..ba9cb2e --- /dev/null +++ b/.drone.yml @@ -0,0 +1,21 @@ +kind: pipeline +name: deploy + +steps: + - name: deploy + image: appleboy/drone-ssh + settings: + host: 89.104.69.222 + username: root + password: + from_secret: ssh_password + script: + - rm -fr /home/tailly_subscribers + - mkdir /home/tailly_subscribers + - cd /home/tailly_subscribers + - git clone https://admin:2bfa8b81e8787c9c0bb89e1a7bbd929b2d63aaf2@git.altomta.ru/admin/tailly_subscribers . || true + - git pull + - docker stop tailly_subscribers || true + - docker rm tailly_subscribers || true + - DOCKER_BUILDKIT=1 docker build -t tailly_subscribers . + - docker run -d --name tailly_subscribers --network tailly_net -p 50053:50053 tailly_subscribers diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -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 diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a7fa51f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/tailly_subscribers.iml b/.idea/tailly_subscribers.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/tailly_subscribers.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2279d35 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +# ===== Билдер ===== +FROM golang:1.25rc3-alpine AS builder + +# Устанавливаем зависимости для сборки +RUN apk add --no-cache git make gcc musl-dev + +# Рабочая директория +WORKDIR /build + +# Копируем файлы модулей +COPY go.mod go.sum ./ + +# Скачиваем зависимости +RUN go mod download + +# Копируем весь проект +COPY . . + +# Собираем бинарник (статически линкованный) +RUN CGO_ENABLED=0 GOOS=linux go build \ + -ldflags="-w -s -extldflags '-static'" \ + -o /app/server \ + ./server.go + +# ===== Финальный образ ===== +FROM alpine:3.19 + +# Устанавливаем tzdata для работы с временными зонами +RUN apk add --no-cache tzdata ca-certificates && \ + update-ca-certificates + +# Копируем бинарник +COPY --from=builder /app/server /usr/local/bin/server + +# Копируем .env если нужен +# COPY --from=builder /build/.env /app/.env + +# Настройки среды +ENV GIN_MODE=release \ + PORT=50053 + +# Открываем порт +EXPOSE $PORT + +# Запускаем сервер +CMD ["/usr/local/bin/server"] \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6621d53 --- /dev/null +++ b/go.mod @@ -0,0 +1,29 @@ +module tailly_subscribers + +go 1.25rc3 + +require ( + github.com/jackc/pgx/v4 v4.18.3 + github.com/stretchr/testify v1.10.0 + google.golang.org/grpc v1.75.0 + google.golang.org/protobuf v1.36.8 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/jackc/chunkreader/v2 v2.0.1 // indirect + github.com/jackc/pgconn v1.14.3 // indirect + github.com/jackc/pgio v1.0.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.3 // indirect + github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect + github.com/jackc/pgtype v1.14.4 // indirect + github.com/jackc/puddle v1.3.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/crypto v0.41.0 // indirect + golang.org/x/net v0.43.0 // indirect + golang.org/x/sys v0.35.0 // indirect + golang.org/x/text v0.28.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..9dd40d2 --- /dev/null +++ b/go.sum @@ -0,0 +1,269 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +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/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= +github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= +github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= +github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= +github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= +github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= +github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= +github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= +github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= +github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w= +github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM= +github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= +github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= +github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= +github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= +github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= +github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag= +github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= +github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= +github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= +github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw= +github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.14.4 h1:fKuNiCumbKTAIxQwXfB/nsrnkEI6bPJrrSiMKgbJ2j8= +github.com/jackc/pgtype v1.14.4/go.mod h1:aKeozOde08iifGosdJpz9MBZonJOUJxqNpPBcMJTlVA= +github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= +github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= +github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= +github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= +github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= +github.com/jackc/pgx/v4 v4.18.3 h1:dE2/TrEsGX3RBprb3qryqSV9Y60iZN1C6i8IrmW9/BA= +github.com/jackc/pgx/v4 v4.18.3/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= +github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.3.0 h1:eHK/5clGOatcjX3oWGBO/MpxpbHzSwud5EWTSCI+MX0= +github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +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/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +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/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= +github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.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/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +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.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +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.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= +go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= +go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= +go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= +go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= +go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= +go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= +go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= +go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= +go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +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-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= +golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= +golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= +golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +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-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= +golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= +golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= +golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/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/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/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-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/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.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= +golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= +golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +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-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 h1:pFyd6EwwL2TqFf8emdthzeX+gZE1ElRq3iM8pui4KBY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c h1:qXWI/sQtv5UKboZ/zUk7h+mrf/lXORyI+n9DKDAusdg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c/go.mod h1:gw1tLEfykwDz2ET4a12jcXt4couGAm7IwsVaTy0Sflo= +google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4= +google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ= +google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= +google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/proto/subscribe.pb.go b/proto/subscribe.pb.go new file mode 100644 index 0000000..ec10ef4 --- /dev/null +++ b/proto/subscribe.pb.go @@ -0,0 +1,1304 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v3.21.12 +// source: subscribe.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type GetCountRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetCountRequest) Reset() { + *x = GetCountRequest{} + mi := &file_subscribe_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetCountRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCountRequest) ProtoMessage() {} + +func (x *GetCountRequest) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetCountRequest.ProtoReflect.Descriptor instead. +func (*GetCountRequest) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{0} +} + +func (x *GetCountRequest) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +// Ответ с количеством +type GetCountResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetCountResponse) Reset() { + *x = GetCountResponse{} + mi := &file_subscribe_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetCountResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCountResponse) ProtoMessage() {} + +func (x *GetCountResponse) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetCountResponse.ProtoReflect.Descriptor instead. +func (*GetCountResponse) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{1} +} + +func (x *GetCountResponse) GetCount() int32 { + if x != nil { + return x.Count + } + return 0 +} + +// Запрос на подписку +type FollowRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + FollowerId int32 `protobuf:"varint,1,opt,name=follower_id,json=followerId,proto3" json:"follower_id,omitempty"` // ID пользователя, который подписывается + FollowingId int32 `protobuf:"varint,2,opt,name=following_id,json=followingId,proto3" json:"following_id,omitempty"` // ID пользователя, на которого подписываются + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *FollowRequest) Reset() { + *x = FollowRequest{} + mi := &file_subscribe_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *FollowRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FollowRequest) ProtoMessage() {} + +func (x *FollowRequest) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FollowRequest.ProtoReflect.Descriptor instead. +func (*FollowRequest) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{2} +} + +func (x *FollowRequest) GetFollowerId() int32 { + if x != nil { + return x.FollowerId + } + return 0 +} + +func (x *FollowRequest) GetFollowingId() int32 { + if x != nil { + return x.FollowingId + } + return 0 +} + +// Ответ на подписку +type FollowResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // Успешность операции + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` // Сообщение (например, об ошибке) + SubscriptionId int32 `protobuf:"varint,3,opt,name=subscription_id,json=subscriptionId,proto3" json:"subscription_id,omitempty"` // ID созданной подписки + NotificationId int32 `protobuf:"varint,4,opt,name=notification_id,json=notificationId,proto3" json:"notification_id,omitempty"` // ID созданного уведомления + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *FollowResponse) Reset() { + *x = FollowResponse{} + mi := &file_subscribe_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *FollowResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FollowResponse) ProtoMessage() {} + +func (x *FollowResponse) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FollowResponse.ProtoReflect.Descriptor instead. +func (*FollowResponse) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{3} +} + +func (x *FollowResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *FollowResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *FollowResponse) GetSubscriptionId() int32 { + if x != nil { + return x.SubscriptionId + } + return 0 +} + +func (x *FollowResponse) GetNotificationId() int32 { + if x != nil { + return x.NotificationId + } + return 0 +} + +// Запрос на отписку +type UnfollowRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + FollowerId int32 `protobuf:"varint,1,opt,name=follower_id,json=followerId,proto3" json:"follower_id,omitempty"` + FollowingId int32 `protobuf:"varint,2,opt,name=following_id,json=followingId,proto3" json:"following_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UnfollowRequest) Reset() { + *x = UnfollowRequest{} + mi := &file_subscribe_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UnfollowRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UnfollowRequest) ProtoMessage() {} + +func (x *UnfollowRequest) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UnfollowRequest.ProtoReflect.Descriptor instead. +func (*UnfollowRequest) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{4} +} + +func (x *UnfollowRequest) GetFollowerId() int32 { + if x != nil { + return x.FollowerId + } + return 0 +} + +func (x *UnfollowRequest) GetFollowingId() int32 { + if x != nil { + return x.FollowingId + } + return 0 +} + +// Ответ на отписку +type UnfollowResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UnfollowResponse) Reset() { + *x = UnfollowResponse{} + mi := &file_subscribe_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UnfollowResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UnfollowResponse) ProtoMessage() {} + +func (x *UnfollowResponse) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UnfollowResponse.ProtoReflect.Descriptor instead. +func (*UnfollowResponse) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{5} +} + +func (x *UnfollowResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *UnfollowResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +// Запрос на получение подписчиков +type GetFollowersRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // ID пользователя, чьих подписчиков запрашиваем + Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` // Лимит (для пагинации) + Offset int32 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` // Смещение (для пагинации) + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetFollowersRequest) Reset() { + *x = GetFollowersRequest{} + mi := &file_subscribe_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetFollowersRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFollowersRequest) ProtoMessage() {} + +func (x *GetFollowersRequest) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetFollowersRequest.ProtoReflect.Descriptor instead. +func (*GetFollowersRequest) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{6} +} + +func (x *GetFollowersRequest) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *GetFollowersRequest) GetLimit() int32 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *GetFollowersRequest) GetOffset() int32 { + if x != nil { + return x.Offset + } + return 0 +} + +// Ответ с подписчиками +type GetFollowersResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Followers []*GetFollowersResponse_Follower `protobuf:"bytes,1,rep,name=followers,proto3" json:"followers,omitempty"` // Список подписчиков + TotalCount int32 `protobuf:"varint,2,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"` // Общее количество подписчиков + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetFollowersResponse) Reset() { + *x = GetFollowersResponse{} + mi := &file_subscribe_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetFollowersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFollowersResponse) ProtoMessage() {} + +func (x *GetFollowersResponse) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetFollowersResponse.ProtoReflect.Descriptor instead. +func (*GetFollowersResponse) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{7} +} + +func (x *GetFollowersResponse) GetFollowers() []*GetFollowersResponse_Follower { + if x != nil { + return x.Followers + } + return nil +} + +func (x *GetFollowersResponse) GetTotalCount() int32 { + if x != nil { + return x.TotalCount + } + return 0 +} + +// Запрос на получение подписок +type GetFollowingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // ID пользователя, чьи подписки запрашиваем + Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` + Offset int32 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetFollowingRequest) Reset() { + *x = GetFollowingRequest{} + mi := &file_subscribe_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetFollowingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFollowingRequest) ProtoMessage() {} + +func (x *GetFollowingRequest) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetFollowingRequest.ProtoReflect.Descriptor instead. +func (*GetFollowingRequest) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{8} +} + +func (x *GetFollowingRequest) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *GetFollowingRequest) GetLimit() int32 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *GetFollowingRequest) GetOffset() int32 { + if x != nil { + return x.Offset + } + return 0 +} + +// Ответ с подписками +type GetFollowingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Following []*GetFollowingResponse_Following `protobuf:"bytes,1,rep,name=following,proto3" json:"following,omitempty"` // Список подписок + TotalCount int32 `protobuf:"varint,2,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"` // Общее количество подписок + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetFollowingResponse) Reset() { + *x = GetFollowingResponse{} + mi := &file_subscribe_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetFollowingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFollowingResponse) ProtoMessage() {} + +func (x *GetFollowingResponse) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetFollowingResponse.ProtoReflect.Descriptor instead. +func (*GetFollowingResponse) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{9} +} + +func (x *GetFollowingResponse) GetFollowing() []*GetFollowingResponse_Following { + if x != nil { + return x.Following + } + return nil +} + +func (x *GetFollowingResponse) GetTotalCount() int32 { + if x != nil { + return x.TotalCount + } + return 0 +} + +// Запрос на проверку подписки +type IsFollowingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + FollowerId int32 `protobuf:"varint,1,opt,name=follower_id,json=followerId,proto3" json:"follower_id,omitempty"` + FollowingId int32 `protobuf:"varint,2,opt,name=following_id,json=followingId,proto3" json:"following_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *IsFollowingRequest) Reset() { + *x = IsFollowingRequest{} + mi := &file_subscribe_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *IsFollowingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IsFollowingRequest) ProtoMessage() {} + +func (x *IsFollowingRequest) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IsFollowingRequest.ProtoReflect.Descriptor instead. +func (*IsFollowingRequest) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{10} +} + +func (x *IsFollowingRequest) GetFollowerId() int32 { + if x != nil { + return x.FollowerId + } + return 0 +} + +func (x *IsFollowingRequest) GetFollowingId() int32 { + if x != nil { + return x.FollowingId + } + return 0 +} + +// Ответ на проверку подписки +type IsFollowingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + IsFollowing bool `protobuf:"varint,1,opt,name=is_following,json=isFollowing,proto3" json:"is_following,omitempty"` // true - подписан, false - не подписан + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *IsFollowingResponse) Reset() { + *x = IsFollowingResponse{} + mi := &file_subscribe_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *IsFollowingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IsFollowingResponse) ProtoMessage() {} + +func (x *IsFollowingResponse) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IsFollowingResponse.ProtoReflect.Descriptor instead. +func (*IsFollowingResponse) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{11} +} + +func (x *IsFollowingResponse) GetIsFollowing() bool { + if x != nil { + return x.IsFollowing + } + return false +} + +// Запрос на получение уведомлений +type GetNotificationsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // ID пользователя, чьи уведомления запрашиваем + UnreadOnly bool `protobuf:"varint,2,opt,name=unread_only,json=unreadOnly,proto3" json:"unread_only,omitempty"` // Только непрочитанные + Limit int32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` + Offset int32 `protobuf:"varint,4,opt,name=offset,proto3" json:"offset,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetNotificationsRequest) Reset() { + *x = GetNotificationsRequest{} + mi := &file_subscribe_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetNotificationsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNotificationsRequest) ProtoMessage() {} + +func (x *GetNotificationsRequest) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNotificationsRequest.ProtoReflect.Descriptor instead. +func (*GetNotificationsRequest) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{12} +} + +func (x *GetNotificationsRequest) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *GetNotificationsRequest) GetUnreadOnly() bool { + if x != nil { + return x.UnreadOnly + } + return false +} + +func (x *GetNotificationsRequest) GetLimit() int32 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *GetNotificationsRequest) GetOffset() int32 { + if x != nil { + return x.Offset + } + return 0 +} + +// Ответ с уведомлениями +type GetNotificationsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Notifications []*GetNotificationsResponse_Notification `protobuf:"bytes,1,rep,name=notifications,proto3" json:"notifications,omitempty"` + TotalCount int32 `protobuf:"varint,2,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"` + UnreadCount int32 `protobuf:"varint,3,opt,name=unread_count,json=unreadCount,proto3" json:"unread_count,omitempty"` // Количество непрочитанных уведомлений + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetNotificationsResponse) Reset() { + *x = GetNotificationsResponse{} + mi := &file_subscribe_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetNotificationsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNotificationsResponse) ProtoMessage() {} + +func (x *GetNotificationsResponse) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNotificationsResponse.ProtoReflect.Descriptor instead. +func (*GetNotificationsResponse) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{13} +} + +func (x *GetNotificationsResponse) GetNotifications() []*GetNotificationsResponse_Notification { + if x != nil { + return x.Notifications + } + return nil +} + +func (x *GetNotificationsResponse) GetTotalCount() int32 { + if x != nil { + return x.TotalCount + } + return 0 +} + +func (x *GetNotificationsResponse) GetUnreadCount() int32 { + if x != nil { + return x.UnreadCount + } + return 0 +} + +// Запрос на пометку уведомления как прочитанного +type MarkNotificationReadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + NotificationId int32 `protobuf:"varint,1,opt,name=notification_id,json=notificationId,proto3" json:"notification_id,omitempty"` + UserId int32 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // Для проверки прав + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *MarkNotificationReadRequest) Reset() { + *x = MarkNotificationReadRequest{} + mi := &file_subscribe_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MarkNotificationReadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MarkNotificationReadRequest) ProtoMessage() {} + +func (x *MarkNotificationReadRequest) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MarkNotificationReadRequest.ProtoReflect.Descriptor instead. +func (*MarkNotificationReadRequest) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{14} +} + +func (x *MarkNotificationReadRequest) GetNotificationId() int32 { + if x != nil { + return x.NotificationId + } + return 0 +} + +func (x *MarkNotificationReadRequest) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +// Ответ на пометку уведомления +type MarkNotificationReadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *MarkNotificationReadResponse) Reset() { + *x = MarkNotificationReadResponse{} + mi := &file_subscribe_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MarkNotificationReadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MarkNotificationReadResponse) ProtoMessage() {} + +func (x *MarkNotificationReadResponse) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MarkNotificationReadResponse.ProtoReflect.Descriptor instead. +func (*MarkNotificationReadResponse) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{15} +} + +func (x *MarkNotificationReadResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *MarkNotificationReadResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type GetFollowersResponse_Follower struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` + Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetFollowersResponse_Follower) Reset() { + *x = GetFollowersResponse_Follower{} + mi := &file_subscribe_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetFollowersResponse_Follower) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFollowersResponse_Follower) ProtoMessage() {} + +func (x *GetFollowersResponse_Follower) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[16] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetFollowersResponse_Follower.ProtoReflect.Descriptor instead. +func (*GetFollowersResponse_Follower) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{7, 0} +} + +func (x *GetFollowersResponse_Follower) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *GetFollowersResponse_Follower) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *GetFollowersResponse_Follower) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +type GetFollowingResponse_Following struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` + Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetFollowingResponse_Following) Reset() { + *x = GetFollowingResponse_Following{} + mi := &file_subscribe_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetFollowingResponse_Following) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFollowingResponse_Following) ProtoMessage() {} + +func (x *GetFollowingResponse_Following) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetFollowingResponse_Following.ProtoReflect.Descriptor instead. +func (*GetFollowingResponse_Following) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{9, 0} +} + +func (x *GetFollowingResponse_Following) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *GetFollowingResponse_Following) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *GetFollowingResponse_Following) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +type GetNotificationsResponse_Notification struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + SubscriptionId int32 `protobuf:"varint,2,opt,name=subscription_id,json=subscriptionId,proto3" json:"subscription_id,omitempty"` + FollowerId int32 `protobuf:"varint,3,opt,name=follower_id,json=followerId,proto3" json:"follower_id,omitempty"` + FollowerUsername string `protobuf:"bytes,4,opt,name=follower_username,json=followerUsername,proto3" json:"follower_username,omitempty"` + FollowerAvatar string `protobuf:"bytes,5,opt,name=follower_avatar,json=followerAvatar,proto3" json:"follower_avatar,omitempty"` + IsRead bool `protobuf:"varint,6,opt,name=is_read,json=isRead,proto3" json:"is_read,omitempty"` + CreatedAt string `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + ExpiresAt string `protobuf:"bytes,8,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetNotificationsResponse_Notification) Reset() { + *x = GetNotificationsResponse_Notification{} + mi := &file_subscribe_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetNotificationsResponse_Notification) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNotificationsResponse_Notification) ProtoMessage() {} + +func (x *GetNotificationsResponse_Notification) ProtoReflect() protoreflect.Message { + mi := &file_subscribe_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNotificationsResponse_Notification.ProtoReflect.Descriptor instead. +func (*GetNotificationsResponse_Notification) Descriptor() ([]byte, []int) { + return file_subscribe_proto_rawDescGZIP(), []int{13, 0} +} + +func (x *GetNotificationsResponse_Notification) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *GetNotificationsResponse_Notification) GetSubscriptionId() int32 { + if x != nil { + return x.SubscriptionId + } + return 0 +} + +func (x *GetNotificationsResponse_Notification) GetFollowerId() int32 { + if x != nil { + return x.FollowerId + } + return 0 +} + +func (x *GetNotificationsResponse_Notification) GetFollowerUsername() string { + if x != nil { + return x.FollowerUsername + } + return "" +} + +func (x *GetNotificationsResponse_Notification) GetFollowerAvatar() string { + if x != nil { + return x.FollowerAvatar + } + return "" +} + +func (x *GetNotificationsResponse_Notification) GetIsRead() bool { + if x != nil { + return x.IsRead + } + return false +} + +func (x *GetNotificationsResponse_Notification) GetCreatedAt() string { + if x != nil { + return x.CreatedAt + } + return "" +} + +func (x *GetNotificationsResponse_Notification) GetExpiresAt() string { + if x != nil { + return x.ExpiresAt + } + return "" +} + +var File_subscribe_proto protoreflect.FileDescriptor + +const file_subscribe_proto_rawDesc = "" + + "\n" + + "\x0fsubscribe.proto\x12\x05proto\"*\n" + + "\x0fGetCountRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x05R\x06userId\"(\n" + + "\x10GetCountResponse\x12\x14\n" + + "\x05count\x18\x01 \x01(\x05R\x05count\"S\n" + + "\rFollowRequest\x12\x1f\n" + + "\vfollower_id\x18\x01 \x01(\x05R\n" + + "followerId\x12!\n" + + "\ffollowing_id\x18\x02 \x01(\x05R\vfollowingId\"\x96\x01\n" + + "\x0eFollowResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage\x12'\n" + + "\x0fsubscription_id\x18\x03 \x01(\x05R\x0esubscriptionId\x12'\n" + + "\x0fnotification_id\x18\x04 \x01(\x05R\x0enotificationId\"U\n" + + "\x0fUnfollowRequest\x12\x1f\n" + + "\vfollower_id\x18\x01 \x01(\x05R\n" + + "followerId\x12!\n" + + "\ffollowing_id\x18\x02 \x01(\x05R\vfollowingId\"F\n" + + "\x10UnfollowResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage\"\\\n" + + "\x13GetFollowersRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x05R\x06userId\x12\x14\n" + + "\x05limit\x18\x02 \x01(\x05R\x05limit\x12\x16\n" + + "\x06offset\x18\x03 \x01(\x05R\x06offset\"\xd4\x01\n" + + "\x14GetFollowersResponse\x12B\n" + + "\tfollowers\x18\x01 \x03(\v2$.proto.GetFollowersResponse.FollowerR\tfollowers\x12\x1f\n" + + "\vtotal_count\x18\x02 \x01(\x05R\n" + + "totalCount\x1aW\n" + + "\bFollower\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x05R\x06userId\x12\x1a\n" + + "\busername\x18\x02 \x01(\tR\busername\x12\x16\n" + + "\x06avatar\x18\x03 \x01(\tR\x06avatar\"\\\n" + + "\x13GetFollowingRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x05R\x06userId\x12\x14\n" + + "\x05limit\x18\x02 \x01(\x05R\x05limit\x12\x16\n" + + "\x06offset\x18\x03 \x01(\x05R\x06offset\"\xd6\x01\n" + + "\x14GetFollowingResponse\x12C\n" + + "\tfollowing\x18\x01 \x03(\v2%.proto.GetFollowingResponse.FollowingR\tfollowing\x12\x1f\n" + + "\vtotal_count\x18\x02 \x01(\x05R\n" + + "totalCount\x1aX\n" + + "\tFollowing\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x05R\x06userId\x12\x1a\n" + + "\busername\x18\x02 \x01(\tR\busername\x12\x16\n" + + "\x06avatar\x18\x03 \x01(\tR\x06avatar\"X\n" + + "\x12IsFollowingRequest\x12\x1f\n" + + "\vfollower_id\x18\x01 \x01(\x05R\n" + + "followerId\x12!\n" + + "\ffollowing_id\x18\x02 \x01(\x05R\vfollowingId\"8\n" + + "\x13IsFollowingResponse\x12!\n" + + "\fis_following\x18\x01 \x01(\bR\visFollowing\"\x81\x01\n" + + "\x17GetNotificationsRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x05R\x06userId\x12\x1f\n" + + "\vunread_only\x18\x02 \x01(\bR\n" + + "unreadOnly\x12\x14\n" + + "\x05limit\x18\x03 \x01(\x05R\x05limit\x12\x16\n" + + "\x06offset\x18\x04 \x01(\x05R\x06offset\"\xca\x03\n" + + "\x18GetNotificationsResponse\x12R\n" + + "\rnotifications\x18\x01 \x03(\v2,.proto.GetNotificationsResponse.NotificationR\rnotifications\x12\x1f\n" + + "\vtotal_count\x18\x02 \x01(\x05R\n" + + "totalCount\x12!\n" + + "\funread_count\x18\x03 \x01(\x05R\vunreadCount\x1a\x95\x02\n" + + "\fNotification\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x05R\x02id\x12'\n" + + "\x0fsubscription_id\x18\x02 \x01(\x05R\x0esubscriptionId\x12\x1f\n" + + "\vfollower_id\x18\x03 \x01(\x05R\n" + + "followerId\x12+\n" + + "\x11follower_username\x18\x04 \x01(\tR\x10followerUsername\x12'\n" + + "\x0ffollower_avatar\x18\x05 \x01(\tR\x0efollowerAvatar\x12\x17\n" + + "\ais_read\x18\x06 \x01(\bR\x06isRead\x12\x1d\n" + + "\n" + + "created_at\x18\a \x01(\tR\tcreatedAt\x12\x1d\n" + + "\n" + + "expires_at\x18\b \x01(\tR\texpiresAt\"_\n" + + "\x1bMarkNotificationReadRequest\x12'\n" + + "\x0fnotification_id\x18\x01 \x01(\x05R\x0enotificationId\x12\x17\n" + + "\auser_id\x18\x02 \x01(\x05R\x06userId\"R\n" + + "\x1cMarkNotificationReadResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage2\xb6\x05\n" + + "\x10SubscribeService\x129\n" + + "\n" + + "FollowUser\x12\x14.proto.FollowRequest\x1a\x15.proto.FollowResponse\x12?\n" + + "\fUnfollowUser\x12\x16.proto.UnfollowRequest\x1a\x17.proto.UnfollowResponse\x12G\n" + + "\fGetFollowers\x12\x1a.proto.GetFollowersRequest\x1a\x1b.proto.GetFollowersResponse\x12G\n" + + "\fGetFollowing\x12\x1a.proto.GetFollowingRequest\x1a\x1b.proto.GetFollowingResponse\x12D\n" + + "\vIsFollowing\x12\x19.proto.IsFollowingRequest\x1a\x1a.proto.IsFollowingResponse\x12_\n" + + "\x1cGetSubscriptionNotifications\x12\x1e.proto.GetNotificationsRequest\x1a\x1f.proto.GetNotificationsResponse\x12a\n" + + "\x16MarkNotificationAsRead\x12\".proto.MarkNotificationReadRequest\x1a#.proto.MarkNotificationReadResponse\x12D\n" + + "\x11GetFollowersCount\x12\x16.proto.GetCountRequest\x1a\x17.proto.GetCountResponse\x12D\n" + + "\x11GetFollowingCount\x12\x16.proto.GetCountRequest\x1a\x17.proto.GetCountResponseB\tZ\a.;protob\x06proto3" + +var ( + file_subscribe_proto_rawDescOnce sync.Once + file_subscribe_proto_rawDescData []byte +) + +func file_subscribe_proto_rawDescGZIP() []byte { + file_subscribe_proto_rawDescOnce.Do(func() { + file_subscribe_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_subscribe_proto_rawDesc), len(file_subscribe_proto_rawDesc))) + }) + return file_subscribe_proto_rawDescData +} + +var file_subscribe_proto_msgTypes = make([]protoimpl.MessageInfo, 19) +var file_subscribe_proto_goTypes = []any{ + (*GetCountRequest)(nil), // 0: proto.GetCountRequest + (*GetCountResponse)(nil), // 1: proto.GetCountResponse + (*FollowRequest)(nil), // 2: proto.FollowRequest + (*FollowResponse)(nil), // 3: proto.FollowResponse + (*UnfollowRequest)(nil), // 4: proto.UnfollowRequest + (*UnfollowResponse)(nil), // 5: proto.UnfollowResponse + (*GetFollowersRequest)(nil), // 6: proto.GetFollowersRequest + (*GetFollowersResponse)(nil), // 7: proto.GetFollowersResponse + (*GetFollowingRequest)(nil), // 8: proto.GetFollowingRequest + (*GetFollowingResponse)(nil), // 9: proto.GetFollowingResponse + (*IsFollowingRequest)(nil), // 10: proto.IsFollowingRequest + (*IsFollowingResponse)(nil), // 11: proto.IsFollowingResponse + (*GetNotificationsRequest)(nil), // 12: proto.GetNotificationsRequest + (*GetNotificationsResponse)(nil), // 13: proto.GetNotificationsResponse + (*MarkNotificationReadRequest)(nil), // 14: proto.MarkNotificationReadRequest + (*MarkNotificationReadResponse)(nil), // 15: proto.MarkNotificationReadResponse + (*GetFollowersResponse_Follower)(nil), // 16: proto.GetFollowersResponse.Follower + (*GetFollowingResponse_Following)(nil), // 17: proto.GetFollowingResponse.Following + (*GetNotificationsResponse_Notification)(nil), // 18: proto.GetNotificationsResponse.Notification +} +var file_subscribe_proto_depIdxs = []int32{ + 16, // 0: proto.GetFollowersResponse.followers:type_name -> proto.GetFollowersResponse.Follower + 17, // 1: proto.GetFollowingResponse.following:type_name -> proto.GetFollowingResponse.Following + 18, // 2: proto.GetNotificationsResponse.notifications:type_name -> proto.GetNotificationsResponse.Notification + 2, // 3: proto.SubscribeService.FollowUser:input_type -> proto.FollowRequest + 4, // 4: proto.SubscribeService.UnfollowUser:input_type -> proto.UnfollowRequest + 6, // 5: proto.SubscribeService.GetFollowers:input_type -> proto.GetFollowersRequest + 8, // 6: proto.SubscribeService.GetFollowing:input_type -> proto.GetFollowingRequest + 10, // 7: proto.SubscribeService.IsFollowing:input_type -> proto.IsFollowingRequest + 12, // 8: proto.SubscribeService.GetSubscriptionNotifications:input_type -> proto.GetNotificationsRequest + 14, // 9: proto.SubscribeService.MarkNotificationAsRead:input_type -> proto.MarkNotificationReadRequest + 0, // 10: proto.SubscribeService.GetFollowersCount:input_type -> proto.GetCountRequest + 0, // 11: proto.SubscribeService.GetFollowingCount:input_type -> proto.GetCountRequest + 3, // 12: proto.SubscribeService.FollowUser:output_type -> proto.FollowResponse + 5, // 13: proto.SubscribeService.UnfollowUser:output_type -> proto.UnfollowResponse + 7, // 14: proto.SubscribeService.GetFollowers:output_type -> proto.GetFollowersResponse + 9, // 15: proto.SubscribeService.GetFollowing:output_type -> proto.GetFollowingResponse + 11, // 16: proto.SubscribeService.IsFollowing:output_type -> proto.IsFollowingResponse + 13, // 17: proto.SubscribeService.GetSubscriptionNotifications:output_type -> proto.GetNotificationsResponse + 15, // 18: proto.SubscribeService.MarkNotificationAsRead:output_type -> proto.MarkNotificationReadResponse + 1, // 19: proto.SubscribeService.GetFollowersCount:output_type -> proto.GetCountResponse + 1, // 20: proto.SubscribeService.GetFollowingCount:output_type -> proto.GetCountResponse + 12, // [12:21] is the sub-list for method output_type + 3, // [3:12] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_subscribe_proto_init() } +func file_subscribe_proto_init() { + if File_subscribe_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_subscribe_proto_rawDesc), len(file_subscribe_proto_rawDesc)), + NumEnums: 0, + NumMessages: 19, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_subscribe_proto_goTypes, + DependencyIndexes: file_subscribe_proto_depIdxs, + MessageInfos: file_subscribe_proto_msgTypes, + }.Build() + File_subscribe_proto = out.File + file_subscribe_proto_goTypes = nil + file_subscribe_proto_depIdxs = nil +} diff --git a/proto/subscribe.proto b/proto/subscribe.proto new file mode 100644 index 0000000..8dd9127 --- /dev/null +++ b/proto/subscribe.proto @@ -0,0 +1,154 @@ +syntax = "proto3"; + +package proto; + +option go_package = ".;proto"; + +// Сервис для работы с подписками +service SubscribeService { + // Подписаться на пользователя + rpc FollowUser (FollowRequest) returns (FollowResponse); + + // Отписаться от пользователя + rpc UnfollowUser (UnfollowRequest) returns (UnfollowResponse); + + // Получить список подписчиков пользователя + rpc GetFollowers (GetFollowersRequest) returns (GetFollowersResponse); + + // Получить список подписок пользователя + rpc GetFollowing (GetFollowingRequest) returns (GetFollowingResponse); + + // Проверить, подписан ли пользователь на другого + rpc IsFollowing (IsFollowingRequest) returns (IsFollowingResponse); + + // Получить уведомления о подписках для пользователя + rpc GetSubscriptionNotifications (GetNotificationsRequest) returns (GetNotificationsResponse); + + // Пометить уведомление как прочитанное + rpc MarkNotificationAsRead (MarkNotificationReadRequest) returns (MarkNotificationReadResponse); + + // Получить только КОЛИЧЕСТВО подписчиков + rpc GetFollowersCount (GetCountRequest) returns (GetCountResponse); + + // Получить только КОЛИЧЕСТВО подписок + rpc GetFollowingCount (GetCountRequest) returns (GetCountResponse); +} + +message GetCountRequest { + int32 user_id = 1; +} + +// Ответ с количеством +message GetCountResponse { + int32 count = 1; +} + +// Запрос на подписку +message FollowRequest { + int32 follower_id = 1; // ID пользователя, который подписывается + int32 following_id = 2; // ID пользователя, на которого подписываются +} + +// Ответ на подписку +message FollowResponse { + bool success = 1; // Успешность операции + string message = 2; // Сообщение (например, об ошибке) + int32 subscription_id = 3; // ID созданной подписки + int32 notification_id = 4; // ID созданного уведомления +} + +// Запрос на отписку +message UnfollowRequest { + int32 follower_id = 1; + int32 following_id = 2; +} + +// Ответ на отписку +message UnfollowResponse { + bool success = 1; + string message = 2; +} + +// Запрос на получение подписчиков +message GetFollowersRequest { + int32 user_id = 1; // ID пользователя, чьих подписчиков запрашиваем + int32 limit = 2; // Лимит (для пагинации) + int32 offset = 3; // Смещение (для пагинации) +} + +// Ответ с подписчиками +message GetFollowersResponse { + repeated Follower followers = 1; // Список подписчиков + int32 total_count = 2; // Общее количество подписчиков + message Follower { + int32 user_id = 1; + string username = 2; + string avatar = 3; + } +} + +// Запрос на получение подписок +message GetFollowingRequest { + int32 user_id = 1; // ID пользователя, чьи подписки запрашиваем + int32 limit = 2; + int32 offset = 3; +} + +// Ответ с подписками +message GetFollowingResponse { + repeated Following following = 1; // Список подписок + int32 total_count = 2; // Общее количество подписок + message Following { + int32 user_id = 1; + string username = 2; + string avatar = 3; + } +} + +// Запрос на проверку подписки +message IsFollowingRequest { + int32 follower_id = 1; + int32 following_id = 2; +} + +// Ответ на проверку подписки +message IsFollowingResponse { + bool is_following = 1; // true - подписан, false - не подписан +} + +// Запрос на получение уведомлений +message GetNotificationsRequest { + int32 user_id = 1; // ID пользователя, чьи уведомления запрашиваем + bool unread_only = 2; // Только непрочитанные + int32 limit = 3; + int32 offset = 4; +} + +// Ответ с уведомлениями +message GetNotificationsResponse { + repeated Notification notifications = 1; + int32 total_count = 2; + int32 unread_count = 3; // Количество непрочитанных уведомлений + message Notification { + int32 id = 1; + int32 subscription_id = 2; + int32 follower_id = 3; + string follower_username = 4; + string follower_avatar = 5; + bool is_read = 6; + string created_at = 7; + string expires_at = 8; + } +} + +// Запрос на пометку уведомления как прочитанного +message MarkNotificationReadRequest { + int32 notification_id = 1; + int32 user_id = 2; // Для проверки прав +} + +// Ответ на пометку уведомления +message MarkNotificationReadResponse { + bool success = 1; + string message = 2; +} \ No newline at end of file diff --git a/proto/subscribe_grpc.pb.go b/proto/subscribe_grpc.pb.go new file mode 100644 index 0000000..cbc8d88 --- /dev/null +++ b/proto/subscribe_grpc.pb.go @@ -0,0 +1,447 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v3.21.12 +// source: subscribe.proto + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + SubscribeService_FollowUser_FullMethodName = "/proto.SubscribeService/FollowUser" + SubscribeService_UnfollowUser_FullMethodName = "/proto.SubscribeService/UnfollowUser" + SubscribeService_GetFollowers_FullMethodName = "/proto.SubscribeService/GetFollowers" + SubscribeService_GetFollowing_FullMethodName = "/proto.SubscribeService/GetFollowing" + SubscribeService_IsFollowing_FullMethodName = "/proto.SubscribeService/IsFollowing" + SubscribeService_GetSubscriptionNotifications_FullMethodName = "/proto.SubscribeService/GetSubscriptionNotifications" + SubscribeService_MarkNotificationAsRead_FullMethodName = "/proto.SubscribeService/MarkNotificationAsRead" + SubscribeService_GetFollowersCount_FullMethodName = "/proto.SubscribeService/GetFollowersCount" + SubscribeService_GetFollowingCount_FullMethodName = "/proto.SubscribeService/GetFollowingCount" +) + +// SubscribeServiceClient is the client API for SubscribeService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Сервис для работы с подписками +type SubscribeServiceClient interface { + // Подписаться на пользователя + FollowUser(ctx context.Context, in *FollowRequest, opts ...grpc.CallOption) (*FollowResponse, error) + // Отписаться от пользователя + UnfollowUser(ctx context.Context, in *UnfollowRequest, opts ...grpc.CallOption) (*UnfollowResponse, error) + // Получить список подписчиков пользователя + GetFollowers(ctx context.Context, in *GetFollowersRequest, opts ...grpc.CallOption) (*GetFollowersResponse, error) + // Получить список подписок пользователя + GetFollowing(ctx context.Context, in *GetFollowingRequest, opts ...grpc.CallOption) (*GetFollowingResponse, error) + // Проверить, подписан ли пользователь на другого + IsFollowing(ctx context.Context, in *IsFollowingRequest, opts ...grpc.CallOption) (*IsFollowingResponse, error) + // Получить уведомления о подписках для пользователя + GetSubscriptionNotifications(ctx context.Context, in *GetNotificationsRequest, opts ...grpc.CallOption) (*GetNotificationsResponse, error) + // Пометить уведомление как прочитанное + MarkNotificationAsRead(ctx context.Context, in *MarkNotificationReadRequest, opts ...grpc.CallOption) (*MarkNotificationReadResponse, error) + // Получить только КОЛИЧЕСТВО подписчиков + GetFollowersCount(ctx context.Context, in *GetCountRequest, opts ...grpc.CallOption) (*GetCountResponse, error) + // Получить только КОЛИЧЕСТВО подписок + GetFollowingCount(ctx context.Context, in *GetCountRequest, opts ...grpc.CallOption) (*GetCountResponse, error) +} + +type subscribeServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewSubscribeServiceClient(cc grpc.ClientConnInterface) SubscribeServiceClient { + return &subscribeServiceClient{cc} +} + +func (c *subscribeServiceClient) FollowUser(ctx context.Context, in *FollowRequest, opts ...grpc.CallOption) (*FollowResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(FollowResponse) + err := c.cc.Invoke(ctx, SubscribeService_FollowUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *subscribeServiceClient) UnfollowUser(ctx context.Context, in *UnfollowRequest, opts ...grpc.CallOption) (*UnfollowResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UnfollowResponse) + err := c.cc.Invoke(ctx, SubscribeService_UnfollowUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *subscribeServiceClient) GetFollowers(ctx context.Context, in *GetFollowersRequest, opts ...grpc.CallOption) (*GetFollowersResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetFollowersResponse) + err := c.cc.Invoke(ctx, SubscribeService_GetFollowers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *subscribeServiceClient) GetFollowing(ctx context.Context, in *GetFollowingRequest, opts ...grpc.CallOption) (*GetFollowingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetFollowingResponse) + err := c.cc.Invoke(ctx, SubscribeService_GetFollowing_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *subscribeServiceClient) IsFollowing(ctx context.Context, in *IsFollowingRequest, opts ...grpc.CallOption) (*IsFollowingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(IsFollowingResponse) + err := c.cc.Invoke(ctx, SubscribeService_IsFollowing_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *subscribeServiceClient) GetSubscriptionNotifications(ctx context.Context, in *GetNotificationsRequest, opts ...grpc.CallOption) (*GetNotificationsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetNotificationsResponse) + err := c.cc.Invoke(ctx, SubscribeService_GetSubscriptionNotifications_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *subscribeServiceClient) MarkNotificationAsRead(ctx context.Context, in *MarkNotificationReadRequest, opts ...grpc.CallOption) (*MarkNotificationReadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(MarkNotificationReadResponse) + err := c.cc.Invoke(ctx, SubscribeService_MarkNotificationAsRead_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *subscribeServiceClient) GetFollowersCount(ctx context.Context, in *GetCountRequest, opts ...grpc.CallOption) (*GetCountResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetCountResponse) + err := c.cc.Invoke(ctx, SubscribeService_GetFollowersCount_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *subscribeServiceClient) GetFollowingCount(ctx context.Context, in *GetCountRequest, opts ...grpc.CallOption) (*GetCountResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetCountResponse) + err := c.cc.Invoke(ctx, SubscribeService_GetFollowingCount_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SubscribeServiceServer is the server API for SubscribeService service. +// All implementations must embed UnimplementedSubscribeServiceServer +// for forward compatibility. +// +// Сервис для работы с подписками +type SubscribeServiceServer interface { + // Подписаться на пользователя + FollowUser(context.Context, *FollowRequest) (*FollowResponse, error) + // Отписаться от пользователя + UnfollowUser(context.Context, *UnfollowRequest) (*UnfollowResponse, error) + // Получить список подписчиков пользователя + GetFollowers(context.Context, *GetFollowersRequest) (*GetFollowersResponse, error) + // Получить список подписок пользователя + GetFollowing(context.Context, *GetFollowingRequest) (*GetFollowingResponse, error) + // Проверить, подписан ли пользователь на другого + IsFollowing(context.Context, *IsFollowingRequest) (*IsFollowingResponse, error) + // Получить уведомления о подписках для пользователя + GetSubscriptionNotifications(context.Context, *GetNotificationsRequest) (*GetNotificationsResponse, error) + // Пометить уведомление как прочитанное + MarkNotificationAsRead(context.Context, *MarkNotificationReadRequest) (*MarkNotificationReadResponse, error) + // Получить только КОЛИЧЕСТВО подписчиков + GetFollowersCount(context.Context, *GetCountRequest) (*GetCountResponse, error) + // Получить только КОЛИЧЕСТВО подписок + GetFollowingCount(context.Context, *GetCountRequest) (*GetCountResponse, error) + mustEmbedUnimplementedSubscribeServiceServer() +} + +// UnimplementedSubscribeServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedSubscribeServiceServer struct{} + +func (UnimplementedSubscribeServiceServer) FollowUser(context.Context, *FollowRequest) (*FollowResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FollowUser not implemented") +} +func (UnimplementedSubscribeServiceServer) UnfollowUser(context.Context, *UnfollowRequest) (*UnfollowResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnfollowUser not implemented") +} +func (UnimplementedSubscribeServiceServer) GetFollowers(context.Context, *GetFollowersRequest) (*GetFollowersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetFollowers not implemented") +} +func (UnimplementedSubscribeServiceServer) GetFollowing(context.Context, *GetFollowingRequest) (*GetFollowingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetFollowing not implemented") +} +func (UnimplementedSubscribeServiceServer) IsFollowing(context.Context, *IsFollowingRequest) (*IsFollowingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IsFollowing not implemented") +} +func (UnimplementedSubscribeServiceServer) GetSubscriptionNotifications(context.Context, *GetNotificationsRequest) (*GetNotificationsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSubscriptionNotifications not implemented") +} +func (UnimplementedSubscribeServiceServer) MarkNotificationAsRead(context.Context, *MarkNotificationReadRequest) (*MarkNotificationReadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MarkNotificationAsRead not implemented") +} +func (UnimplementedSubscribeServiceServer) GetFollowersCount(context.Context, *GetCountRequest) (*GetCountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetFollowersCount not implemented") +} +func (UnimplementedSubscribeServiceServer) GetFollowingCount(context.Context, *GetCountRequest) (*GetCountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetFollowingCount not implemented") +} +func (UnimplementedSubscribeServiceServer) mustEmbedUnimplementedSubscribeServiceServer() {} +func (UnimplementedSubscribeServiceServer) testEmbeddedByValue() {} + +// UnsafeSubscribeServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SubscribeServiceServer will +// result in compilation errors. +type UnsafeSubscribeServiceServer interface { + mustEmbedUnimplementedSubscribeServiceServer() +} + +func RegisterSubscribeServiceServer(s grpc.ServiceRegistrar, srv SubscribeServiceServer) { + // If the following call pancis, it indicates UnimplementedSubscribeServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&SubscribeService_ServiceDesc, srv) +} + +func _SubscribeService_FollowUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FollowRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SubscribeServiceServer).FollowUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SubscribeService_FollowUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SubscribeServiceServer).FollowUser(ctx, req.(*FollowRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SubscribeService_UnfollowUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UnfollowRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SubscribeServiceServer).UnfollowUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SubscribeService_UnfollowUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SubscribeServiceServer).UnfollowUser(ctx, req.(*UnfollowRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SubscribeService_GetFollowers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetFollowersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SubscribeServiceServer).GetFollowers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SubscribeService_GetFollowers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SubscribeServiceServer).GetFollowers(ctx, req.(*GetFollowersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SubscribeService_GetFollowing_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetFollowingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SubscribeServiceServer).GetFollowing(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SubscribeService_GetFollowing_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SubscribeServiceServer).GetFollowing(ctx, req.(*GetFollowingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SubscribeService_IsFollowing_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(IsFollowingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SubscribeServiceServer).IsFollowing(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SubscribeService_IsFollowing_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SubscribeServiceServer).IsFollowing(ctx, req.(*IsFollowingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SubscribeService_GetSubscriptionNotifications_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetNotificationsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SubscribeServiceServer).GetSubscriptionNotifications(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SubscribeService_GetSubscriptionNotifications_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SubscribeServiceServer).GetSubscriptionNotifications(ctx, req.(*GetNotificationsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SubscribeService_MarkNotificationAsRead_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MarkNotificationReadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SubscribeServiceServer).MarkNotificationAsRead(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SubscribeService_MarkNotificationAsRead_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SubscribeServiceServer).MarkNotificationAsRead(ctx, req.(*MarkNotificationReadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SubscribeService_GetFollowersCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SubscribeServiceServer).GetFollowersCount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SubscribeService_GetFollowersCount_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SubscribeServiceServer).GetFollowersCount(ctx, req.(*GetCountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SubscribeService_GetFollowingCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SubscribeServiceServer).GetFollowingCount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SubscribeService_GetFollowingCount_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SubscribeServiceServer).GetFollowingCount(ctx, req.(*GetCountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// SubscribeService_ServiceDesc is the grpc.ServiceDesc for SubscribeService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var SubscribeService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.SubscribeService", + HandlerType: (*SubscribeServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "FollowUser", + Handler: _SubscribeService_FollowUser_Handler, + }, + { + MethodName: "UnfollowUser", + Handler: _SubscribeService_UnfollowUser_Handler, + }, + { + MethodName: "GetFollowers", + Handler: _SubscribeService_GetFollowers_Handler, + }, + { + MethodName: "GetFollowing", + Handler: _SubscribeService_GetFollowing_Handler, + }, + { + MethodName: "IsFollowing", + Handler: _SubscribeService_IsFollowing_Handler, + }, + { + MethodName: "GetSubscriptionNotifications", + Handler: _SubscribeService_GetSubscriptionNotifications_Handler, + }, + { + MethodName: "MarkNotificationAsRead", + Handler: _SubscribeService_MarkNotificationAsRead_Handler, + }, + { + MethodName: "GetFollowersCount", + Handler: _SubscribeService_GetFollowersCount_Handler, + }, + { + MethodName: "GetFollowingCount", + Handler: _SubscribeService_GetFollowingCount_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "subscribe.proto", +} diff --git a/server.go b/server.go new file mode 100644 index 0000000..40a2838 --- /dev/null +++ b/server.go @@ -0,0 +1,413 @@ +package main + +import ( + "context" + "github.com/jackc/pgx/v4" + "github.com/jackc/pgx/v4/pgxpool" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/keepalive" + "google.golang.org/grpc/status" + "log" + "net" + "os" + "tailly_subscribers/proto" + "time" +) + +type server struct { + proto.UnimplementedSubscribeServiceServer + db *pgxpool.Pool + logger *log.Logger +} + +func NewServer(db *pgxpool.Pool) *server { + return &server{ + db: db, + logger: log.New(os.Stdout, "SUBSCRIBE_SERVICE: ", log.LstdFlags|log.Lmicroseconds|log.Lshortfile), + } +} + +func (s *server) FollowUser(ctx context.Context, req *proto.FollowRequest) (*proto.FollowResponse, error) { + follower, following := req.FollowerId, req.FollowingId + if follower == following { + return nil, status.Error(codes.InvalidArgument, "cannot follow yourself") + } + + // ИСПРАВЛЕНИЕ: Используем QueryRow чтобы получить количество вставленных строк + var subscriptionID int32 + err := s.db.QueryRow(ctx, ` + INSERT INTO subscriptions (follower_id, following_id) + VALUES ($1, $2) + ON CONFLICT (follower_id, following_id) DO NOTHING + RETURNING id`, + follower, following).Scan(&subscriptionID) + + if err != nil { + if err == pgx.ErrNoRows { + // Конфликт - подписка уже существует + return &proto.FollowResponse{ + Success: false, + Message: "Already following this user", + }, nil + } + return nil, status.Errorf(codes.Internal, "failed to follow: %v", err) + } + + return &proto.FollowResponse{ + Success: true, + Message: "Successfully followed user", + SubscriptionId: subscriptionID, + }, nil +} + +func (s *server) UnfollowUser(ctx context.Context, req *proto.UnfollowRequest) (*proto.UnfollowResponse, error) { + follower, following := req.FollowerId, req.FollowingId + if follower == 0 || following == 0 { + return nil, status.Errorf(codes.InvalidArgument, "Переданы пустые id follower или following, %d, %d", follower, following) + } + + var userExists bool + err := s.db.QueryRow(ctx, ` + SELECT EXISTS(SELECT 1 FROM users WHERE id IN ($1, $2))`, + follower, following).Scan(&userExists) + + if !userExists { + return nil, status.Errorf(codes.NotFound, "one or both users not found, %v", err) + } + + result, err := s.db.Exec(ctx, ` + DELETE FROM subscriptions + WHERE follower_id = $1 AND following_id = $2`, + follower, following) + + if result.RowsAffected() == 0 { + return &proto.UnfollowResponse{ + Success: false, + Message: "Subscription not found", + }, nil + } + + return &proto.UnfollowResponse{ + Success: true, + Message: "Successfully unfollowed user", + }, nil +} + +func (s *server) GetFollowers(ctx context.Context, req *proto.GetFollowersRequest) (*proto.GetFollowersResponse, error) { + if req.UserId == 0 { + return nil, status.Error(codes.InvalidArgument, "user_id is required") + } + + // Получаем общее количество подписчиков + var totalCount int32 + err := s.db.QueryRow(ctx, ` + SELECT COUNT(*) FROM subscriptions WHERE following_id = $1`, + req.UserId).Scan(&totalCount) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get followers count: %v", err) + } + + // Получаем список подписчиков с пагинацией + rows, err := s.db.Query(ctx, ` + SELECT u.id, u.username, u.avatar + FROM subscriptions s + JOIN users u ON s.follower_id = u.id + WHERE s.following_id = $1 + ORDER BY s.created_at DESC + LIMIT $2 OFFSET $3`, + req.UserId, req.Limit, req.Offset) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get followers: %v", err) + } + defer rows.Close() + + var followers []*proto.GetFollowersResponse_Follower + for rows.Next() { + var follower proto.GetFollowersResponse_Follower + if err := rows.Scan(&follower.UserId, &follower.Username, &follower.Avatar); err != nil { + return nil, status.Errorf(codes.Internal, "failed to scan follower: %v", err) + } + followers = append(followers, &follower) + } + + if err := rows.Err(); err != nil { + return nil, status.Errorf(codes.Internal, "rows error: %v", err) + } + + return &proto.GetFollowersResponse{ + Followers: followers, + TotalCount: totalCount, + }, nil +} + +func (s *server) GetFollowing(ctx context.Context, req *proto.GetFollowingRequest) (*proto.GetFollowingResponse, error) { + if req.UserId == 0 { + return nil, status.Error(codes.InvalidArgument, "user_id is required") + } + + // Получаем общее количество подписок + var totalCount int32 + err := s.db.QueryRow(ctx, ` + SELECT COUNT(*) FROM subscriptions WHERE follower_id = $1`, + req.UserId).Scan(&totalCount) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get following count: %v", err) + } + + // Получаем список подписок с пагинацией + rows, err := s.db.Query(ctx, ` + SELECT u.id, u.username, u.avatar + FROM subscriptions s + JOIN users u ON s.following_id = u.id + WHERE s.follower_id = $1 + ORDER BY s.created_at DESC + LIMIT $2 OFFSET $3`, + req.UserId, req.Limit, req.Offset) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get following: %v", err) + } + defer rows.Close() + + var following []*proto.GetFollowingResponse_Following + for rows.Next() { + var follow proto.GetFollowingResponse_Following + if err := rows.Scan(&follow.UserId, &follow.Username, &follow.Avatar); err != nil { + return nil, status.Errorf(codes.Internal, "failed to scan following: %v", err) + } + following = append(following, &follow) + } + + if err := rows.Err(); err != nil { + return nil, status.Errorf(codes.Internal, "rows error: %v", err) + } + + return &proto.GetFollowingResponse{ + Following: following, + TotalCount: totalCount, + }, nil +} + +func (s *server) IsFollowing(ctx context.Context, req *proto.IsFollowingRequest) (*proto.IsFollowingResponse, error) { + if req.FollowerId == 0 || req.FollowingId == 0 { + return nil, status.Error(codes.InvalidArgument, "follower_id and following_id are required") + } + + var isFollowing bool + err := s.db.QueryRow(ctx, ` + SELECT EXISTS( + SELECT 1 FROM subscriptions + WHERE follower_id = $1 AND following_id = $2 + )`, + req.FollowerId, req.FollowingId).Scan(&isFollowing) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to check subscription: %v", err) + } + + return &proto.IsFollowingResponse{IsFollowing: isFollowing}, nil +} + +func (s *server) GetFollowersCount(ctx context.Context, req *proto.GetCountRequest) (*proto.GetCountResponse, error) { + if req.UserId == 0 { + return nil, status.Error(codes.InvalidArgument, "user_id is required") + } + + var count int32 + err := s.db.QueryRow(ctx, ` + SELECT COUNT(*) FROM subscriptions WHERE following_id = $1`, + req.UserId).Scan(&count) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get followers count: %v", err) + } + + return &proto.GetCountResponse{Count: count}, nil +} + +func (s *server) GetFollowingCount(ctx context.Context, req *proto.GetCountRequest) (*proto.GetCountResponse, error) { + if req.UserId == 0 { + return nil, status.Error(codes.InvalidArgument, "user_id is required") + } + + var count int32 + err := s.db.QueryRow(ctx, ` + SELECT COUNT(*) FROM subscriptions WHERE follower_id = $1`, + req.UserId).Scan(&count) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get following count: %v", err) + } + + return &proto.GetCountResponse{Count: count}, nil +} + +func (s *server) GetSubscriptionNotifications(ctx context.Context, req *proto.GetNotificationsRequest) (*proto.GetNotificationsResponse, error) { + if req.UserId == 0 { + return nil, status.Error(codes.InvalidArgument, "user_id is required") + } + + // Получаем общее количество уведомлений + var totalCount, unreadCount int32 + err := s.db.QueryRow(ctx, ` + SELECT + COUNT(*), + COUNT(*) FILTER (WHERE NOT is_read) + FROM subscription_notifications sn + JOIN subscriptions s ON sn.subscription_id = s.id + WHERE s.following_id = $1`, + req.UserId).Scan(&totalCount, &unreadCount) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get notifications count: %v", err) + } + + // Базовый запрос + query := ` + SELECT + sn.id, sn.subscription_id, s.follower_id, + u.username, u.avatar, sn.is_read, + sn.created_at, sn.created_at + INTERVAL '7 days' as expires_at + FROM subscription_notifications sn + JOIN subscriptions s ON sn.subscription_id = s.id + JOIN users u ON s.follower_id = u.id + WHERE s.following_id = $1` + + // Добавляем условие для непрочитанных + if req.UnreadOnly { + query += " AND NOT sn.is_read" + } + + // Добавляем пагинацию + query += " ORDER BY sn.created_at DESC LIMIT $2 OFFSET $3" + + rows, err := s.db.Query(ctx, query, req.UserId, req.Limit, req.Offset) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get notifications: %v", err) + } + defer rows.Close() + + var notifications []*proto.GetNotificationsResponse_Notification + for rows.Next() { + var notif proto.GetNotificationsResponse_Notification + var createdAt, expiresAt time.Time + if err := rows.Scan( + ¬if.Id, ¬if.SubscriptionId, ¬if.FollowerId, + ¬if.FollowerUsername, ¬if.FollowerAvatar, ¬if.IsRead, + &createdAt, &expiresAt, + ); err != nil { + return nil, status.Errorf(codes.Internal, "failed to scan notification: %v", err) + } + notif.CreatedAt = createdAt.Format(time.RFC3339) + notif.ExpiresAt = expiresAt.Format(time.RFC3339) + notifications = append(notifications, ¬if) + } + + if err := rows.Err(); err != nil { + return nil, status.Errorf(codes.Internal, "rows error: %v", err) + } + + return &proto.GetNotificationsResponse{ + Notifications: notifications, + TotalCount: totalCount, + UnreadCount: unreadCount, + }, nil +} + +func (s *server) MarkNotificationAsRead(ctx context.Context, req *proto.MarkNotificationReadRequest) (*proto.MarkNotificationReadResponse, error) { + if req.NotificationId == 0 || req.UserId == 0 { + return nil, status.Error(codes.InvalidArgument, "notification_id and user_id are required") + } + + // Проверяем, что уведомление принадлежит пользователю + var belongsToUser bool + err := s.db.QueryRow(ctx, ` + SELECT EXISTS( + SELECT 1 FROM subscription_notifications sn + JOIN subscriptions s ON sn.subscription_id = s.id + WHERE sn.id = $1 AND s.following_id = $2 + )`, + req.NotificationId, req.UserId).Scan(&belongsToUser) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to check notification ownership: %v", err) + } + + if !belongsToUser { + return nil, status.Error(codes.PermissionDenied, "notification does not belong to user") + } + + // Помечаем как прочитанное + result, err := s.db.Exec(ctx, ` + UPDATE subscription_notifications + SET is_read = true + WHERE id = $1`, + req.NotificationId) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to mark notification as read: %v", err) + } + + if result.RowsAffected() == 0 { + return &proto.MarkNotificationReadResponse{ + Success: false, + Message: "Notification not found or already read", + }, nil + } + + return &proto.MarkNotificationReadResponse{ + Success: true, + Message: "Notification marked as read", + }, nil +} + +func main() { + logger := log.New(os.Stdout, "MAIN: ", log.LstdFlags|log.Lmicroseconds|log.Lshortfile) + logger.Println("Starting subscribe service") + + // Инициализация подключения к БД + dbURL := "postgres://tailly_v2:i0Oq%2675LA%26M612ceuy@79.174.89.104:15452/tailly_v2" + logger.Printf("Connecting to database at %s", dbURL) + pool, err := pgxpool.Connect(context.Background(), dbURL) + if err != nil { + logger.Fatalf("Unable to connect to database: %v", err) + } + defer func() { + logger.Println("Closing database connection") + pool.Close() + }() + // Создаем gRPC сервер + grpcServer := grpc.NewServer( + grpc.KeepaliveParams(keepalive.ServerParameters{ + MaxConnectionAge: 24 * time.Hour, + MaxConnectionAgeGrace: 5 * time.Minute, + Time: 30 * time.Second, + Timeout: 10 * time.Second, + }), + grpc.UnaryInterceptor(func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { + logger.Printf("Unary call: %s, request: %+v", info.FullMethod, req) + start := time.Now() + defer func() { + logger.Printf("Unary call %s completed in %v, response: %+v, error: %v", + info.FullMethod, time.Since(start), resp, err) + }() + return handler(ctx, req) + }), + grpc.StreamInterceptor(func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + logger.Printf("Stream call: %s", info.FullMethod) + start := time.Now() + defer func() { + logger.Printf("Stream call %s completed in %v", info.FullMethod, time.Since(start)) + }() + return handler(srv, ss) + }), + ) + proto.RegisterSubscribeServiceServer(grpcServer, NewServer(pool)) + + // Запускаем сервер + port := ":50053" + logger.Printf("Starting gRPC server on port %s", port) + lis, err := net.Listen("tcp", port) + if err != nil { + logger.Fatalf("failed to listen: %v", err) + } + + logger.Println("Server is ready to accept connections") + if err := grpcServer.Serve(lis); err != nil { + logger.Fatalf("failed to serve: %v", err) + } +} diff --git a/server_test.go b/server_test.go new file mode 100644 index 0000000..209040e --- /dev/null +++ b/server_test.go @@ -0,0 +1,408 @@ +package main + +import ( + "context" + "github.com/jackc/pgx/v4/pgxpool" + "github.com/stretchr/testify/assert" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "tailly_subscribers/proto" + "testing" +) + +func setupTestDB(t *testing.T) *pgxpool.Pool { + dbURL := "postgres://tailly_v2:i0Oq%2675LA%26M612ceuy@79.174.89.104:15452/tailly_v2" + pool, err := pgxpool.Connect(context.Background(), dbURL) + if err != nil { + t.Fatalf("Failed to connect to database: %v", err) + } + + // ОЧИСТКА ТЕСТОВЫХ ДАННЫХ ПЕРЕД ТЕСТАМИ + _, err = pool.Exec(context.Background(), "DELETE FROM subscription_notifications") + if err != nil { + t.Fatalf("Failed to clean notifications: %v", err) + } + _, err = pool.Exec(context.Background(), "DELETE FROM subscriptions") + if err != nil { + t.Fatalf("Failed to clean subscriptions: %v", err) + } + + return pool +} + +func TestFollowUser(t *testing.T) { + db := setupTestDB(t) + server := NewServer(db) + + tests := []struct { + name string + req *proto.FollowRequest + expectError bool + errorCode codes.Code + }{ + { + name: "Success - user 1 follows user 2", + req: &proto.FollowRequest{FollowerId: 1, FollowingId: 2}, + expectError: false, + }, + { + name: "Success - user 2 follows user 3", + req: &proto.FollowRequest{FollowerId: 2, FollowingId: 3}, + expectError: false, + }, + { + name: "Error - self follow", + req: &proto.FollowRequest{FollowerId: 1, FollowingId: 1}, + expectError: true, + errorCode: codes.InvalidArgument, + }, + { + name: "Error - non-existent user", // ИЗМЕНИЛОСЬ: теперь Internal error из-за foreign key + req: &proto.FollowRequest{FollowerId: 1, FollowingId: 999}, + expectError: true, + errorCode: codes.Internal, // Foreign key violation + }, + { + name: "Error - zero IDs", + req: &proto.FollowRequest{FollowerId: 0, FollowingId: 0}, + expectError: true, + errorCode: codes.InvalidArgument, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ctx := context.Background() + resp, err := server.FollowUser(ctx, tt.req) + + if tt.expectError { + assert.Error(t, err) + if st, ok := status.FromError(err); ok { + assert.Equal(t, tt.errorCode, st.Code()) + } + } else { + assert.NoError(t, err) + assert.True(t, resp.Success) + assert.Contains(t, resp.Message, "Successfully") + } + }) + } +} + +func TestUnfollowUser(t *testing.T) { + db := setupTestDB(t) + server := NewServer(db) + + // Сначала создаем подписки для тестов + server.FollowUser(context.Background(), &proto.FollowRequest{FollowerId: 1, FollowingId: 2}) + server.FollowUser(context.Background(), &proto.FollowRequest{FollowerId: 1, FollowingId: 3}) + + tests := []struct { + name string + req *proto.UnfollowRequest + expectError bool + errorCode codes.Code + success bool + }{ + { + name: "Success - user 1 unfollows user 2", + req: &proto.UnfollowRequest{FollowerId: 1, FollowingId: 2}, + expectError: false, + success: true, + }, + { + name: "Success - user 1 unfollows user 3", + req: &proto.UnfollowRequest{FollowerId: 1, FollowingId: 3}, + expectError: false, + success: true, + }, + { + name: "Success - non-existent subscription", // ИЗМЕНИЛОСЬ: не ошибка + req: &proto.UnfollowRequest{FollowerId: 1, FollowingId: 999}, + expectError: false, + success: false, + }, + { + name: "Error - non-existent user", // ИЗМЕНИЛОСЬ: не ошибка, просто false + req: &proto.UnfollowRequest{FollowerId: 999, FollowingId: 1}, + expectError: false, + success: false, + }, + { + name: "Error - zero IDs", + req: &proto.UnfollowRequest{FollowerId: 0, FollowingId: 0}, + expectError: true, + errorCode: codes.InvalidArgument, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ctx := context.Background() + resp, err := server.UnfollowUser(ctx, tt.req) + + if tt.expectError { + assert.Error(t, err) + if st, ok := status.FromError(err); ok { + assert.Equal(t, tt.errorCode, st.Code()) + } + } else { + assert.NoError(t, err) + assert.Equal(t, tt.success, resp.Success) + if tt.success { + assert.Contains(t, resp.Message, "Successfully") + } else { + assert.Contains(t, resp.Message, "not found") + } + } + }) + } +} + +func TestGetFollowersCount(t *testing.T) { + db := setupTestDB(t) + server := NewServer(db) + + tests := []struct { + name string + req *proto.GetCountRequest + expected int32 + expectError bool + errorCode codes.Code + }{ + { + name: "Success - user 2 has 0 followers initially", + req: &proto.GetCountRequest{UserId: 2}, + expected: 0, + expectError: false, + }, + { + name: "Success - user 1 has 0 followers", + req: &proto.GetCountRequest{UserId: 1}, + expected: 0, + expectError: false, + }, + { + name: "Success - user 3 has 0 followers", + req: &proto.GetCountRequest{UserId: 3}, + expected: 0, + expectError: false, + }, + { + name: "Success - non-existent user returns 0", + req: &proto.GetCountRequest{UserId: 999}, + expected: 0, + expectError: false, + }, + { + name: "Error - zero user ID", + req: &proto.GetCountRequest{UserId: 0}, + expectError: true, + errorCode: codes.InvalidArgument, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ctx := context.Background() + resp, err := server.GetFollowersCount(ctx, tt.req) + + if tt.expectError { + assert.Error(t, err) + if st, ok := status.FromError(err); ok { + assert.Equal(t, tt.errorCode, st.Code()) + } + } else { + assert.NoError(t, err) + assert.Equal(t, tt.expected, resp.Count) + } + }) + } +} + +func TestGetFollowingCount(t *testing.T) { + db := setupTestDB(t) + server := NewServer(db) + + tests := []struct { + name string + req *proto.GetCountRequest + expected int32 + expectError bool + errorCode codes.Code + }{ + { + name: "Success - user 2 follows 0 users initially", + req: &proto.GetCountRequest{UserId: 2}, + expected: 0, + expectError: false, + }, + { + name: "Success - user 1 follows 0 users", + req: &proto.GetCountRequest{UserId: 1}, + expected: 0, + expectError: false, + }, + { + name: "Success - user 3 follows 0 users", + req: &proto.GetCountRequest{UserId: 3}, + expected: 0, + expectError: false, + }, + { + name: "Success - non-existent user returns 0", + req: &proto.GetCountRequest{UserId: 999}, + expected: 0, + expectError: false, + }, + { + name: "Error - zero user ID", + req: &proto.GetCountRequest{UserId: 0}, + expectError: true, + errorCode: codes.InvalidArgument, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ctx := context.Background() + resp, err := server.GetFollowingCount(ctx, tt.req) + + if tt.expectError { + assert.Error(t, err) + if st, ok := status.FromError(err); ok { + assert.Equal(t, tt.errorCode, st.Code()) + } + } else { + assert.NoError(t, err) + assert.Equal(t, tt.expected, resp.Count) + } + }) + } +} + +func TestGetFollowers(t *testing.T) { + db := setupTestDB(t) + server := NewServer(db) + + tests := []struct { + name string + req *proto.GetFollowersRequest + expectedCount int + expectError bool + errorCode codes.Code + }{ + { + name: "Success - user 2 has 0 followers initially", + req: &proto.GetFollowersRequest{UserId: 2, Limit: 10, Offset: 0}, + expectedCount: 0, + expectError: false, + }, + { + name: "Success - user 1 has 0 followers", + req: &proto.GetFollowersRequest{UserId: 1, Limit: 10, Offset: 0}, + expectedCount: 0, + expectError: false, + }, + { + name: "Success - get with limit 0", + req: &proto.GetFollowersRequest{UserId: 2, Limit: 0, Offset: 0}, + expectedCount: 0, + expectError: false, + }, + { + name: "Success - non-existent user returns empty list", + req: &proto.GetFollowersRequest{UserId: 999, Limit: 10, Offset: 0}, + expectError: false, + }, + { + name: "Error - zero user ID", + req: &proto.GetFollowersRequest{UserId: 0, Limit: 10, Offset: 0}, + expectError: true, + errorCode: codes.InvalidArgument, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ctx := context.Background() + resp, err := server.GetFollowers(ctx, tt.req) + + if tt.expectError { + assert.Error(t, err) + if st, ok := status.FromError(err); ok { + assert.Equal(t, tt.errorCode, st.Code()) + } + } else { + assert.NoError(t, err) + if tt.expectedCount >= 0 { + assert.Len(t, resp.Followers, tt.expectedCount) + } + assert.NotNil(t, resp.TotalCount) + } + }) + } +} + +func TestGetFollowing(t *testing.T) { + db := setupTestDB(t) + server := NewServer(db) + + tests := []struct { + name string + req *proto.GetFollowingRequest + expectedCount int + expectError bool + errorCode codes.Code + }{ + { + name: "Success - user 2 follows 0 users initially", + req: &proto.GetFollowingRequest{UserId: 2, Limit: 10, Offset: 0}, + expectedCount: 0, + expectError: false, + }, + { + name: "Success - user 1 follows 0 users", + req: &proto.GetFollowingRequest{UserId: 1, Limit: 10, Offset: 0}, + expectedCount: 0, + expectError: false, + }, + { + name: "Success - get with limit 0", + req: &proto.GetFollowingRequest{UserId: 2, Limit: 0, Offset: 0}, + expectedCount: 0, + expectError: false, + }, + { + name: "Success - non-existent user returns empty list", + req: &proto.GetFollowingRequest{UserId: 999, Limit: 10, Offset: 0}, + expectError: false, + }, + { + name: "Error - zero user ID", + req: &proto.GetFollowingRequest{UserId: 0, Limit: 10, Offset: 0}, + expectError: true, + errorCode: codes.InvalidArgument, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ctx := context.Background() + resp, err := server.GetFollowing(ctx, tt.req) + + if tt.expectError { + assert.Error(t, err) + if st, ok := status.FromError(err); ok { + assert.Equal(t, tt.errorCode, st.Code()) + } + } else { + assert.NoError(t, err) + if tt.expectedCount >= 0 { + assert.Len(t, resp.Following, tt.expectedCount) + } + assert.NotNil(t, resp.TotalCount) + } + }) + } +}