FIRST COMMIT
This commit is contained in:
commit
e1caf757e7
14
.dir-locals.el
Normal file
14
.dir-locals.el
Normal file
@ -0,0 +1,14 @@
|
||||
((nil (eglot-workspace-configuration . ((gopls . ((staticcheck . t)
|
||||
(matcher . "CaseSensitive")
|
||||
(hints . (
|
||||
(compositeLiteralFields . t)
|
||||
(compositeLiteralTypes . t)
|
||||
(constantValues . t)
|
||||
(functionTypeParameters . t)
|
||||
(parameterNames . t)
|
||||
(rangeVariableTypes . t)
|
||||
(assignVariableTypes . t)
|
||||
))))))
|
||||
(eglot-server-programs
|
||||
((go-mode go-ts-mode) . ("gopls")))
|
||||
))
|
||||
105
.github/workflows/image_creation.yml
vendored
Normal file
105
.github/workflows/image_creation.yml
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
name: ${{ github.actor }} executed Build Push Prod
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+\.[0-9]+\.[0-9]+'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
USERNAME: ${{ vars.USERNAME }}
|
||||
TAG_VERSION: ${{ github.ref_name }}
|
||||
steps:
|
||||
- name: echo repo dir
|
||||
id: repo-url
|
||||
run: |
|
||||
echo "repourl=$(echo ${{ github.server_url }} | sed -e 's;https://;;')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Quemu
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set Up BuildX
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: https://git.maximotejeda.com
|
||||
username: ${{ vars.USERNAME }}
|
||||
password: ${{ secrets.PWD }}
|
||||
|
||||
- name: calculate short sha
|
||||
id: calculate-sha
|
||||
run: |
|
||||
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: "${{ steps.repo-url.outputs.repourl }}/${{ github.repository }}:${{ github.ref_name }}"
|
||||
build-args: |
|
||||
version=${{ github.ref_name }}
|
||||
SHORTSHA=${{ steps.calculate-sha.outputs.shortsha }}
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
PASSWORD: $PWD
|
||||
USERNAME: ${{ vars.USERNAME }}
|
||||
TAG_VERSION: ${{ github.ref_name }}
|
||||
NATS_SERVICE_URL: "${{ vars.NATS_SERVICE_URL }}"
|
||||
ENV: "production"
|
||||
APPLICATION_PORT: "${{ vars.APPLICATION_PORT }}"
|
||||
DATA_SOURCE_URL: "${{ vars.DATA_SOURCE_URL }}"
|
||||
steps:
|
||||
- name: echo repo dir
|
||||
id: repo-url
|
||||
run: |
|
||||
echo "repourl=$(echo ${{ github.server_url }} | sed -e 's;https://;;')" >> $GITHUB_OUTPUT
|
||||
echo "repoName=$(echo ${{ github.repository }} | sed -e 's;${{ github.actor }}/;;')" >> $GITHUB_OUTPUT
|
||||
echo "${{ github.repository }} | sed -e 's;${{ github.actor }}/;;')"
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install envsubst
|
||||
run: |
|
||||
apt update
|
||||
apt install -y gettext-base
|
||||
apt clean
|
||||
|
||||
- name: create deployment files
|
||||
env:
|
||||
IMAGE: "${{ steps.repo-url.outputs.repourl }}/${{ github.repository }}:${{ github.ref_name }}"
|
||||
REPONAME: "${{ steps.repo-url.outputs.repoName }}"
|
||||
run: |
|
||||
envsubst < k8s/deployment.yml.template > k8s/deployment.yml
|
||||
- name: Download kubectl
|
||||
run: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
|
||||
- name: install kubectl
|
||||
run: sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
||||
|
||||
- name: insert kube config
|
||||
run: |
|
||||
mkdir ~/.kube
|
||||
export IMAGE="$( echo ${{ github.server_url }} | sed -e 's;https://;;')/${{ github.repository }}:${{ github.ref_name }}"
|
||||
echo "${{ secrets.KUBECONFIG }}" > ~/.kube/config
|
||||
- name: check pod
|
||||
run: kubectl apply -f k8s/deployment.yml
|
||||
|
||||
- name: scale down deployment
|
||||
continue-on-error: true
|
||||
run: kubectl scale deployment ${{ steps.repo-url.outputs.repoName }}-grpc --replicas=0
|
||||
|
||||
- name: scale up deployment
|
||||
run: kubectl scale deployment ${{ steps.repo-url.outputs.repoName }}-grpc --replicas=1
|
||||
105
.github/workflows/test_project.yml
vendored
Normal file
105
.github/workflows/test_project.yml
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
name: ${{ github.actor }} executed Build Push Prod
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+\.[0-9]+\.[0-9]+'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
USERNAME: ${{ vars.USERNAME }}
|
||||
TAG_VERSION: ${{ github.ref_name }}
|
||||
steps:
|
||||
- name: echo repo dir
|
||||
id: repo-url
|
||||
run: |
|
||||
echo "repourl=$(echo ${{ github.server_url }} | sed -e 's;https://;;')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Quemu
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set Up BuildX
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: https://git.maximotejeda.com
|
||||
username: ${{ vars.USERNAME }}
|
||||
password: ${{ secrets.PWD }}
|
||||
|
||||
- name: calculate short sha
|
||||
id: calculate-sha
|
||||
run: |
|
||||
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: "${{ steps.repo-url.outputs.repourl }}/${{ github.repository }}:${{ github.ref_name }}"
|
||||
build-args: |
|
||||
version=${{ github.ref_name }}
|
||||
SHORTSHA=${{ steps.calculate-sha.outputs.shortsha }}
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
PASSWORD: $PWD
|
||||
USERNAME: ${{ vars.USERNAME }}
|
||||
TAG_VERSION: ${{ github.ref_name }}
|
||||
NATS_SERVICE_URL: "${{ vars.NATS_SERVICE_URL }}"
|
||||
ENV: "production"
|
||||
APPLICATION_PORT: "${{ vars.APPLICATION_PORT }}"
|
||||
DATA_SOURCE_URL: "${{ vars.DATA_SOURCE_URL }}"
|
||||
steps:
|
||||
- name: echo repo dir
|
||||
id: repo-url
|
||||
run: |
|
||||
echo "repourl=$(echo ${{ github.server_url }} | sed -e 's;https://;;')" >> $GITHUB_OUTPUT
|
||||
echo "repoName=$(echo ${{ github.repository }} | sed -e 's;${{ github.actor }}/;;')" >> $GITHUB_OUTPUT
|
||||
echo "${{ github.repository }} | sed -e 's;${{ github.actor }}/;;')"
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install envsubst
|
||||
run: |
|
||||
apt update
|
||||
apt install -y gettext-base
|
||||
apt clean
|
||||
|
||||
- name: create deployment files
|
||||
env:
|
||||
IMAGE: "${{ steps.repo-url.outputs.repourl }}/${{ github.repository }}:${{ github.ref_name }}"
|
||||
REPONAME: "${{ steps.repo-url.outputs.repoName }}"
|
||||
run: |
|
||||
envsubst < k8s/deployment.yml.template > k8s/deployment.yml
|
||||
- name: Download kubectl
|
||||
run: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
|
||||
- name: install kubectl
|
||||
run: sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
||||
|
||||
- name: insert kube config
|
||||
run: |
|
||||
mkdir ~/.kube
|
||||
export IMAGE="$( echo ${{ github.server_url }} | sed -e 's;https://;;')/${{ github.repository }}:${{ github.ref_name }}"
|
||||
echo "${{ secrets.KUBECONFIG }}" > ~/.kube/config
|
||||
- name: check pod
|
||||
run: kubectl apply -f k8s/deployment.yml
|
||||
|
||||
- name: scale down deployment
|
||||
continue-on-error: true
|
||||
run: kubectl scale deployment ${{ steps.repo-url.outputs.repoName }}-grpc --replicas=0
|
||||
|
||||
- name: scale up deployment
|
||||
run: kubectl scale deployment ${{ steps.repo-url.outputs.repoName }}-grpc --replicas=1
|
||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
||||
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM alpine:latest
|
||||
ARG BINAME=tgbuser-grpc-linux-arm64-0.0.0_1
|
||||
COPY ./bin/${BINAME} /usr/bin/tgbuser-grpc
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT tgbuser-grpc
|
||||
66
Makefile
Normal file
66
Makefile
Normal file
@ -0,0 +1,66 @@
|
||||
# must create a .env file with info
|
||||
# must have compose installed
|
||||
include .env
|
||||
export
|
||||
OS:=${shell go env GOOS}
|
||||
ARCH=$(shell go env GOARCH)
|
||||
OOSS="linux"
|
||||
ARRCHS="arm 386"
|
||||
DEBUG=1
|
||||
SERVICE=tgbuser-grpc
|
||||
VERSION=0.0.0_7
|
||||
BINAME=$(SERVICE)-$(OS)-amd64-$(VERSION)
|
||||
BINAMEARM=$(SERVICE)-$(OS)-arm64-$(VERSION)
|
||||
# can be docker or podman or whatever
|
||||
CONTAINERS=docker
|
||||
COMPOSE=$(CONTAINERS)-compose
|
||||
# Configure local registry
|
||||
REGADDR=192.168.0.151:32000
|
||||
K8SRSNAME=$(shell kubectl get rs --no-headers -o custom-columns=":metadata.name" | grep $(SERVICE))
|
||||
.phony: all clean build test clean-image build-image build-image-debug run-image run-image-debug run-local
|
||||
|
||||
|
||||
build-image: build
|
||||
# here we made the images and push to registry with buildx
|
||||
@$(CONTAINERS) buildx build --build-arg="BINAME=$(BINAMEARM)" --platform linux/arm64 --push -t $(REGADDR)/$(SERVICE):latest .
|
||||
|
||||
# Here we upload it to local
|
||||
|
||||
build-test-image:
|
||||
@$(CONTAINERS) buildx build --build-arg="BINAME=$(BINAMEARM)" --platform linux/arm64 --push -t $(REGADDR)/$(SERVICE):latest .
|
||||
|
||||
run-image: build-image
|
||||
@$(CONTAINERS) compose -f docker-compose.yaml up
|
||||
|
||||
build-image-debug: clean
|
||||
@$(CONTAINERS) compose -f docker-compose-debug.yaml build
|
||||
|
||||
run-image-debug: build-image-debug
|
||||
@$(CONTAINERS) compose -f docker-compose-debug.yaml up
|
||||
|
||||
run-local:clean build
|
||||
@bin/$(BINAME)
|
||||
|
||||
build: clean
|
||||
#@mkdir dolardb
|
||||
@protoc -I ./proto --go_out ./proto/golang --go_opt paths=source_relative --go-grpc_out ./proto/golang --go-grpc_opt paths=source_relative ./proto/tgbuser/tgbuser.proto
|
||||
@env CGO_ENABLED=0 GOOS=$(OS) GOARCH=amd64 go build -o ./bin/$(BINAME) ./cmd/.
|
||||
@env CGO_ENABLED=0 GOOS=$(OS) GOARCH=arm64 go build -o ./bin/$(BINAMEARM) ./cmd/.
|
||||
|
||||
create-descriptors:
|
||||
@envsubst < k8s/deployment.yml.template > k8s/deployment.yml
|
||||
|
||||
deploy: build-image create-descriptors
|
||||
@kubectl apply -f k8s/deployment.yml
|
||||
@kubectl scale rs $(K8SRSNAME) --replicas=0
|
||||
@kubectl scale rs $(K8SRSNAME) --replicas=1
|
||||
|
||||
test:
|
||||
@go -count=1 test ./...
|
||||
clean:
|
||||
@rm -rf ./bin
|
||||
|
||||
clean-image:
|
||||
@$(CONTAINERS) system prune -f
|
||||
|
||||
|
||||
4
README.org
Normal file
4
README.org
Normal file
@ -0,0 +1,4 @@
|
||||
#+TITLE: New svc
|
||||
#+AUTHOR: Maximo Tejeda
|
||||
#+DATE: 21/04/2024
|
||||
|
||||
BIN
bin/tgbuser-grpc-linux-amd64-0.0.0_7
Executable file
BIN
bin/tgbuser-grpc-linux-amd64-0.0.0_7
Executable file
Binary file not shown.
BIN
bin/tgbuser-grpc-linux-arm64-0.0.0_7
Executable file
BIN
bin/tgbuser-grpc-linux-arm64-0.0.0_7
Executable file
Binary file not shown.
24
cmd/main.go
Normal file
24
cmd/main.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"git.maximotejeda.com/maximo/tgb-user/config"
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/adapters/db"
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/adapters/grpc"
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/application/core/api"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log := slog.Default()
|
||||
log.With("place", "main")
|
||||
dbAdapter, err := db.NewAdapter(config.GetDataSourceURL())
|
||||
if err != nil {
|
||||
log.Error("creating db connection", "error", err)
|
||||
}
|
||||
app := api.NewApplication(dbAdapter)
|
||||
|
||||
grpcAdapter := grpc.NewAdapter(app, config.GetApplicationPort())
|
||||
log.Info("[tgbuser] service running", "port", config.GetApplicationPort())
|
||||
grpcAdapter.Run()
|
||||
}
|
||||
30
config/config.go
Normal file
30
config/config.go
Normal file
@ -0,0 +1,30 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetEnv() string {
|
||||
return getEnvValue("ENV")
|
||||
}
|
||||
|
||||
func GetDataSourceURL() string {
|
||||
return getEnvValue("DATA_SOURCE_URL")
|
||||
}
|
||||
|
||||
func GetApplicationPort() int {
|
||||
portStr := getEnvValue("APPLICATION_PORT")
|
||||
port, err := strconv.Atoi(portStr)
|
||||
if err != nil {
|
||||
log.Fatalf("port: %s is invalid", portStr)
|
||||
}
|
||||
return port
|
||||
}
|
||||
func getEnvValue(key string) string {
|
||||
if os.Getenv(key) == "" {
|
||||
log.Fatal("env variable not set: " + key)
|
||||
}
|
||||
return os.Getenv(key)
|
||||
}
|
||||
28
go.mod
Normal file
28
go.mod
Normal file
@ -0,0 +1,28 @@
|
||||
module git.maximotejeda.com/maximo/tgb-user
|
||||
|
||||
go 1.22.0
|
||||
|
||||
require (
|
||||
google.golang.org/grpc v1.63.2
|
||||
modernc.org/sqlite v1.29.8
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect
|
||||
google.golang.org/protobuf v1.34.0 // indirect
|
||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
|
||||
modernc.org/libc v1.49.3 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
modernc.org/memory v1.8.0 // indirect
|
||||
modernc.org/strutil v1.2.0 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
||||
73
go.sum
Normal file
73
go.sum
Normal file
@ -0,0 +1,73 @@
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/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.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
|
||||
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
|
||||
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/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
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/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
|
||||
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
|
||||
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 h1:DujSIu+2tC9Ht0aPNA7jgj23Iq8Ewi5sgkQ++wdvonE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
|
||||
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
|
||||
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4=
|
||||
google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
modernc.org/cc/v4 v4.20.0 h1:45Or8mQfbUqJOG9WaxvlFYOAQO0lQ5RvqBcFCXngjxk=
|
||||
modernc.org/cc/v4 v4.20.0/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
|
||||
modernc.org/ccgo/v4 v4.16.0 h1:ofwORa6vx2FMm0916/CkZjpFPSR70VwTjUCe2Eg5BnA=
|
||||
modernc.org/ccgo/v4 v4.16.0/go.mod h1:dkNyWIjFrVIZ68DTo36vHK+6/ShBn4ysU61So6PIqCI=
|
||||
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
|
||||
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
|
||||
modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw=
|
||||
modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU=
|
||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=
|
||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
|
||||
modernc.org/libc v1.49.3 h1:j2MRCRdwJI2ls/sGbeSk0t2bypOG/uvPZUsGQFDulqg=
|
||||
modernc.org/libc v1.49.3/go.mod h1:yMZuGkn7pXbKfoT/M35gFJOAEdSKdxL0q64sF7KqCDo=
|
||||
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
|
||||
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
|
||||
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
|
||||
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
|
||||
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
|
||||
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
||||
modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc=
|
||||
modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss=
|
||||
modernc.org/sqlite v1.29.8 h1:nGKglNx9K5v0As+zF0/Gcl1kMkmaU1XynYyq92PbsC8=
|
||||
modernc.org/sqlite v1.29.8/go.mod h1:lQPm27iqa4UNZpmr4Aor0MH0HkCLbt1huYDfWylLZFk=
|
||||
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
||||
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||
245
internal/adapters/db/access.go
Normal file
245
internal/adapters/db/access.go
Normal file
@ -0,0 +1,245 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type BotAccessRequest struct {
|
||||
db *sql.DB
|
||||
log *slog.Logger
|
||||
ID int64 `json:"id"`
|
||||
TgbID int64 `json:"tgb_id"`
|
||||
BotName string `json:"bot_name"`
|
||||
BotID int64 `json:"bot_id"`
|
||||
Created int64 `json:"edited"`
|
||||
}
|
||||
|
||||
type BotBannedAccess struct {
|
||||
db *sql.DB
|
||||
log *slog.Logger
|
||||
ID int64 `json:"id"`
|
||||
TgbID int64 `json:"tgb_id"`
|
||||
BotName string `json:"bot_name"`
|
||||
Until int64 `json:"until"`
|
||||
Created int64 `json:"edited"`
|
||||
}
|
||||
|
||||
func NewBotAccessRequest(db *sql.DB, log *slog.Logger) *BotAccessRequest {
|
||||
return &BotAccessRequest{
|
||||
db: db,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
func NewBotBannedAccess(db *sql.DB, log *slog.Logger) *BotBannedAccess {
|
||||
return &BotBannedAccess{
|
||||
db: db,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
func (bar *BotAccessRequest) Add(ctx context.Context, tgbID int64, botName string) (bool, error) {
|
||||
|
||||
stmt, err := bar.db.PrepareContext(ctx,
|
||||
`
|
||||
INSERT INTO bot_access_requests
|
||||
(tgb_id, bot_id, created)
|
||||
VALUES(?,(SELECT id FROM bots WHERE bot_name = ?),strftime('%s', 'now'));`)
|
||||
|
||||
if err != nil {
|
||||
bar.log.Error("prepare stmt add bot access request", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, tgbID, botName)
|
||||
if err != nil {
|
||||
bar.log.Error("exec add bot access requests", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Get
|
||||
// Get access request pending for bots
|
||||
func (bar *BotAccessRequest) Get(ctx context.Context, tgbID int64) ([]*BotAccessRequest, error) {
|
||||
stmt, err := bar.db.PrepareContext(ctx,
|
||||
`SELECT bar.id, b.bot_name, bar.created FROM bot_access_requests AS bar
|
||||
JOIN bots AS b ON bar.bot_id = b.id
|
||||
WHERE bar.tgb_id = ?;`)
|
||||
if err != nil {
|
||||
bar.log.Error("prepare stmt getBots", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
rows, err := stmt.QueryContext(ctx, tgbID)
|
||||
if err != nil {
|
||||
bar.log.Error("query get bot_access_request", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
bl := []*BotAccessRequest{}
|
||||
for rows.Next() {
|
||||
ba := &BotAccessRequest{}
|
||||
err := rows.Scan(&ba.ID, &ba.BotName, &ba.Created)
|
||||
if err != nil {
|
||||
bar.log.Error("scanning get bots_access_requests", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
bl = append(bl, ba)
|
||||
|
||||
}
|
||||
return bl, nil
|
||||
}
|
||||
|
||||
// GetAll
|
||||
// GetAll access request pending for bots
|
||||
func (bar *BotAccessRequest) GetAll(ctx context.Context, botName string) ([]*BotAccessRequest, error) {
|
||||
stmt, err := bar.db.PrepareContext(ctx,
|
||||
`SELECT bar.id, b.bot_name, bar.tgb_id, bar.created FROM bot_access_requests AS bar
|
||||
JOIN bots AS b ON bar.bot_id = b.id
|
||||
WHERE b.bot_name = ?;`)
|
||||
if err != nil {
|
||||
bar.log.Error("prepare stmt getBots", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
rows, err := stmt.QueryContext(ctx, botName)
|
||||
if err != nil {
|
||||
bar.log.Error("query get bot_access_request", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
bl := []*BotAccessRequest{}
|
||||
for rows.Next() {
|
||||
ba := &BotAccessRequest{}
|
||||
err := rows.Scan(&ba.ID, &ba.BotName, &ba.TgbID, &ba.Created)
|
||||
if err != nil {
|
||||
bar.log.Error("scanning get bots_access_requests", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
bl = append(bl, ba)
|
||||
|
||||
}
|
||||
return bl, nil
|
||||
}
|
||||
|
||||
func (bar BotAccessRequest) Delete(ctx context.Context, tgbID int64, botName string) (bool, error) {
|
||||
stmt, err := bar.db.PrepareContext(ctx,
|
||||
`
|
||||
DELETE FROM bot_access_requests as bar
|
||||
WHERE bar.bot_id = (SELECT id FROM bots WHERE bot_name = ?) AND bar.tgb_id = ?
|
||||
`)
|
||||
if err != nil {
|
||||
bar.log.Error("prepare stmt delete", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, botName, tgbID)
|
||||
if err != nil {
|
||||
bar.log.Error("exec delete", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (bba *BotBannedAccess) Add(ctx context.Context, tgbID, until int64, botName string) (bool, error) {
|
||||
|
||||
stmt, err := bba.db.PrepareContext(ctx,
|
||||
`
|
||||
INSERT INTO banned_bot_access
|
||||
(tgb_id, until, bot_id, created)
|
||||
VALUES(?,?,(SELECT id FROM bots WHERE bot_name = ?),strftime('%s', 'now'));`)
|
||||
|
||||
if err != nil {
|
||||
bba.log.Error("prepare stmt add bot banned access", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, tgbID, until, botName)
|
||||
if err != nil {
|
||||
bba.log.Error("exec add bot banned Access", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (bba *BotBannedAccess) Get(ctx context.Context, tgbID int64) ([]*BotBannedAccess, error) {
|
||||
stmt, err := bba.db.PrepareContext(ctx,
|
||||
`SELECT bba.id, b.bot_name, bba.until, bba.created FROM banned_bot_access AS bba
|
||||
JOIN bots AS b ON bba.bot_id = b.id
|
||||
WHERE bba.tgb_id = ?;`)
|
||||
if err != nil {
|
||||
bba.log.Error("prepare stmt bots banned access", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
rows, err := stmt.QueryContext(ctx, tgbID)
|
||||
if err != nil {
|
||||
bba.log.Error("query get bot banned access", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
bl := []*BotBannedAccess{}
|
||||
for rows.Next() {
|
||||
ba := &BotBannedAccess{}
|
||||
err := rows.Scan(&ba.ID, &ba.BotName, &ba.Until, &ba.Created)
|
||||
if err != nil {
|
||||
bba.log.Error("scanning get bots banned access", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
bl = append(bl, ba)
|
||||
|
||||
}
|
||||
return bl, nil
|
||||
}
|
||||
|
||||
func (bba *BotBannedAccess) GetAll(ctx context.Context, botName string) ([]*BotBannedAccess, error) {
|
||||
stmt, err := bba.db.PrepareContext(ctx,
|
||||
`SELECT bba.id, b.bot_name, bba.tgb_id, bba.until, bba.created FROM banned_bot_access AS bba
|
||||
JOIN bots AS b ON bba.bot_id = b.id
|
||||
WHERE b.bot_name = ?;`)
|
||||
if err != nil {
|
||||
bba.log.Error("prepare stmt bots banned access", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
rows, err := stmt.QueryContext(ctx, botName)
|
||||
if err != nil {
|
||||
bba.log.Error("query get bot banned access", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
bl := []*BotBannedAccess{}
|
||||
for rows.Next() {
|
||||
ba := &BotBannedAccess{}
|
||||
err := rows.Scan(&ba.ID, &ba.BotName, &ba.TgbID, &ba.Until, &ba.Created)
|
||||
if err != nil {
|
||||
bba.log.Error("scanning get bots banned access", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
bl = append(bl, ba)
|
||||
|
||||
}
|
||||
return bl, nil
|
||||
}
|
||||
|
||||
func (bba *BotBannedAccess) Delete(ctx context.Context, tgbID int64, botName string) (bool, error) {
|
||||
stmt, err := bba.db.PrepareContext(ctx,
|
||||
`
|
||||
DELETE FROM banned_bot_access as bar
|
||||
WHERE bar.bot_id = (SELECT id FROM bots WHERE bot_name = ?) AND bar.tgb_id = ?
|
||||
`)
|
||||
if err != nil {
|
||||
bba.log.Error("prepare stmt delete bot banned access", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, botName, tgbID)
|
||||
if err != nil {
|
||||
bba.log.Error("exec delete bot banned access", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
170
internal/adapters/db/bot_users.go
Normal file
170
internal/adapters/db/bot_users.go
Normal file
@ -0,0 +1,170 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"log/slog"
|
||||
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/application/core/domain"
|
||||
)
|
||||
|
||||
type BotUser struct {
|
||||
db *sql.DB
|
||||
log *slog.Logger
|
||||
ID int64 `json:"id"`
|
||||
Tgb_ID int64 `json:"tgb_id"`
|
||||
Bot_id int64 `json:"bot_id"`
|
||||
Created int64 `json:"edited"`
|
||||
}
|
||||
|
||||
func NewBotUser(db *sql.DB, log *slog.Logger) *BotUser {
|
||||
log = log.With("obj", "BotUsers")
|
||||
return &BotUser{
|
||||
db: db,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
func (bu BotUser) GetUsers(ctx context.Context, botName string) (ul []*domain.User, err error) {
|
||||
smt, err := bu.db.PrepareContext(ctx,
|
||||
`SELECT u.tgb_id, u.username, u.first_name, u.last_name, u.created, u.edited
|
||||
FROM bot_users AS bu
|
||||
JOIN bots as b ON b.id = bu.bot_id
|
||||
JOIN users as u ON bu.tgb_id = u.tgb_id
|
||||
WHERE b.bot_name = ? AND u.deleted IS NULL;`)
|
||||
if err != nil {
|
||||
bu.log.Error("prepare stmt getUsers", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer smt.Close()
|
||||
rows, err := smt.QueryContext(ctx, botName)
|
||||
if err != nil {
|
||||
bu.log.Error("query getUsers", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
u := &domain.User{}
|
||||
err = rows.Scan(&u.TGB_ID, &u.Username, &u.FirstName, &u.LastName, &u.Created, &u.Edited)
|
||||
if err != nil {
|
||||
bu.log.Error("canning getUsers", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
ul = append(ul, u)
|
||||
}
|
||||
return ul, nil
|
||||
}
|
||||
|
||||
func (bu BotUser) GetBots(ctx context.Context, tgb_id int64) (bl []*domain.Bot, err error) {
|
||||
stmt, err := bu.db.PrepareContext(ctx,
|
||||
`SELECT b.id, b.bot_name, b.created FROM bot_users AS bu
|
||||
JOIN bots AS b ON bu.bot_id = b.id
|
||||
WHERE bu.tgb_id = ?;`)
|
||||
if err != nil {
|
||||
bu.log.Error("prepare stmt getBots", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
rows, err := stmt.QueryContext(ctx, tgb_id)
|
||||
if err != nil {
|
||||
bu.log.Error("query get bots", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
bl = []*domain.Bot{}
|
||||
for rows.Next() {
|
||||
bot := &domain.Bot{}
|
||||
err := rows.Scan(&bot.ID, &bot.BotName, &bot.Created)
|
||||
if err != nil {
|
||||
bu.log.Error("scanning get bots", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
bl = append(bl, bot)
|
||||
|
||||
}
|
||||
return bl, nil
|
||||
}
|
||||
|
||||
func (bu BotUser) CreateBot(ctx context.Context, bot_name string) (bool, error) {
|
||||
stmt, err := bu.db.PrepareContext(ctx,
|
||||
`INSERT OR IGNORE INTO bots (bot_name, created) VALUES(?, strftime('%s', 'now'));`)
|
||||
if err != nil {
|
||||
bu.log.Error("prepare stmt add", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, bot_name)
|
||||
|
||||
if err != nil {
|
||||
bu.log.Error("exec context add", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
|
||||
}
|
||||
|
||||
func (bu BotUser) Add(ctx context.Context, tgb_id int64, bot_name string) (bool, error) {
|
||||
|
||||
stmt1, err := bu.db.PrepareContext(ctx,
|
||||
`
|
||||
INSERT INTO bot_users
|
||||
(tgb_id, bot_id, created)
|
||||
VALUES(?,(SELECT id FROM bots WHERE bot_name = ?),strftime('%s', 'now'));`)
|
||||
|
||||
if err != nil {
|
||||
bu.log.Error("prepare stmt add botusers", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt1.Close()
|
||||
_, err = stmt1.ExecContext(ctx, tgb_id, bot_name)
|
||||
if err != nil {
|
||||
bu.log.Error("exec add bot users", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (bu BotUser) Delete(ctx context.Context, tgb_id int64, botname string) (bool, error) {
|
||||
stmt, err := bu.db.PrepareContext(ctx,
|
||||
`
|
||||
DELETE FROM bot_users as u
|
||||
WHERE u.bot_id = (SELECT id FROM bots WHERE bot_name = ?) AND u.tgb_id = ?
|
||||
`)
|
||||
if err != nil {
|
||||
bu.log.Error("prepare stmt delete", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, botname, tgb_id)
|
||||
if err != nil {
|
||||
bu.log.Error("exec delete", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (bu BotUser) GetAllBots(ctx context.Context) ([]*domain.Bot, error) {
|
||||
stmt, err := bu.db.Prepare(`SELECT id, bot_name, created FROM bots`)
|
||||
if err != nil {
|
||||
bu.log.Error("prepare stmt get all bots", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
stmt.Close()
|
||||
rows, err := stmt.Query()
|
||||
if err != nil {
|
||||
bu.log.Error("query get all bots", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
list := []*domain.Bot{}
|
||||
for rows.Next() {
|
||||
bot := &domain.Bot{}
|
||||
err := rows.Scan(&bot.ID, &bot.BotName, &bot.Created)
|
||||
if err != nil {
|
||||
bu.log.Error("scanning get all bots", "error", err)
|
||||
continue
|
||||
}
|
||||
list = append(list, bot)
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
189
internal/adapters/db/db.go
Normal file
189
internal/adapters/db/db.go
Normal file
@ -0,0 +1,189 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/application/core/domain"
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
//go:embed schema.sql
|
||||
var schema string
|
||||
|
||||
type Adapter struct {
|
||||
db *sql.DB
|
||||
log *slog.Logger
|
||||
}
|
||||
|
||||
func NewAdapter(dataSourceURL string) (*Adapter, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
log := slog.Default().With("adapter", "db")
|
||||
pragmas := "cache=shared&_foreign_keys=on&_busy_timeout=3000&_journal_mode=WAL"
|
||||
db, err := sql.Open("sqlite", fmt.Sprintf("file:%s?%s", dataSourceURL, pragmas))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("connecion error: %w", err)
|
||||
}
|
||||
err = db.PingContext(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ping error: %w", err)
|
||||
}
|
||||
db.SetConnMaxIdleTime(10 * time.Second)
|
||||
CreateTables(db)
|
||||
|
||||
return &Adapter{db: db, log: log}, nil
|
||||
}
|
||||
|
||||
// Schema
|
||||
func CreateTables(db *sql.DB) {
|
||||
_, err := db.Exec(schema)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (a Adapter) Create(ctx context.Context, req *domain.User) (bool, error) {
|
||||
user := User{db: a.db, log: a.log}
|
||||
ok, err := user.Create(ctx, req)
|
||||
return ok, err
|
||||
}
|
||||
func (a Adapter) Get(ctx context.Context, id int64) (*domain.User, error) {
|
||||
user := NewUser(a.db, a.log)
|
||||
visit := NewVisits(a.db, a.log)
|
||||
|
||||
us, err := user.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err1 := visit.Add(ctx, id)
|
||||
if err1 != nil {
|
||||
fmt.Println(err1)
|
||||
}
|
||||
return us, err
|
||||
}
|
||||
func (a Adapter) Edit(ctx context.Context, us *domain.User) (bool, error) {
|
||||
user := NewUser(a.db, a.log)
|
||||
ok, err := user.Edit(ctx, *us)
|
||||
return ok, err
|
||||
}
|
||||
func (a Adapter) Delete(ctx context.Context, id int64) (bool, error) {
|
||||
// TODO db work
|
||||
user := NewUser(a.db, a.log)
|
||||
ok, err := user.Delete(ctx, id)
|
||||
|
||||
return ok, err
|
||||
}
|
||||
func (a Adapter) AddBot(ctx context.Context, tgb_id int64, botname string) (bool, error) {
|
||||
bu := NewBotUser(a.db, a.log)
|
||||
ok, err := bu.Add(ctx, tgb_id, botname)
|
||||
return ok, err
|
||||
}
|
||||
func (a Adapter) DeleteBot(ctx context.Context, tgb_id int64, botname string) (bool, error) {
|
||||
bu := NewBotUser(a.db, a.log)
|
||||
ok, err := bu.Delete(ctx, tgb_id, botname)
|
||||
return ok, err
|
||||
}
|
||||
|
||||
func (a Adapter) GetBots(ctx context.Context, tgb_id int64) ([]*domain.Bot, error) {
|
||||
bu := NewBotUser(a.db, a.log)
|
||||
return bu.GetBots(ctx, tgb_id)
|
||||
}
|
||||
|
||||
func (a Adapter) GetAllBotUsers(ctx context.Context, bot_name string) ([]*domain.User, error) {
|
||||
bu := NewBotUser(a.db, a.log)
|
||||
return bu.GetUsers(ctx, bot_name)
|
||||
}
|
||||
|
||||
func (a Adapter) GetAllBots(ctx context.Context) ([]*domain.Bot, error) {
|
||||
bu := NewBotUser(a.db, a.log)
|
||||
return bu.GetAllBots(ctx)
|
||||
}
|
||||
|
||||
// GetAccessRequest
|
||||
// Returns all access request from a user
|
||||
func (a Adapter) GetAccessRequest(ctx context.Context, tgbID int64) ([]*BotAccessRequest, error) {
|
||||
bar := NewBotAccessRequest(a.db, a.log)
|
||||
return bar.Get(ctx, tgbID)
|
||||
}
|
||||
|
||||
// GetAllAccessRequest
|
||||
// Returns all Access request from a bot
|
||||
func (a Adapter) GetAllAccessRequest(ctx context.Context, botName string) ([]*BotAccessRequest, error) {
|
||||
bar := NewBotAccessRequest(a.db, a.log)
|
||||
return bar.GetAll(ctx, botName)
|
||||
}
|
||||
|
||||
// CreateAccessRequest
|
||||
// When user try get access to a restricted bot create a row in here
|
||||
func (a Adapter) CreateAccessRequest(ctx context.Context, tgbID int64, botName string) (bool, error) {
|
||||
bar := NewBotAccessRequest(a.db, a.log)
|
||||
return bar.Add(ctx, tgbID, botName)
|
||||
}
|
||||
|
||||
// GrantAccess
|
||||
//
|
||||
// If a row with user id and bot id is in db returns an object
|
||||
func (a Adapter) GrantAccess(ctx context.Context, tgbID int64, botName string) (bool, error) {
|
||||
bar := NewBotAccessRequest(a.db, a.log)
|
||||
ok, err := bar.Delete(ctx, tgbID, botName)
|
||||
if !ok {
|
||||
return false, err
|
||||
} else {
|
||||
return a.AddBot(ctx, tgbID, botName)
|
||||
}
|
||||
}
|
||||
|
||||
// GetBannedBot
|
||||
// get banned bots for a user
|
||||
func (a Adapter) GetBannedBot(ctx context.Context, tgbID int64) ([]*BotBannedAccess, error) {
|
||||
bba := NewBotBannedAccess(a.db, a.log)
|
||||
return bba.Get(ctx, tgbID)
|
||||
}
|
||||
|
||||
// GetAllBannedUsers
|
||||
// get all users banned from a bot
|
||||
func (a Adapter) GetAllBannedUsers(ctx context.Context, botName string) ([]*BotBannedAccess, error) {
|
||||
bba := NewBotBannedAccess(a.db, a.log)
|
||||
return bba.GetAll(ctx, botName)
|
||||
}
|
||||
|
||||
// BanUser
|
||||
// ban a user creating a row in db ban and removin access request and bot grants
|
||||
func (a Adapter) BanUser(ctx context.Context, tgbID, until int64, botName string) (bool, error) {
|
||||
bba := NewBotBannedAccess(a.db, a.log)
|
||||
bar := NewBotAccessRequest(a.db, a.log)
|
||||
if ok, err := bar.Delete(ctx, tgbID, botName); !ok {
|
||||
a.log.Error("access request not deleted", "error", err)
|
||||
}
|
||||
if ok, err := a.DeleteBot(ctx, tgbID, botName); !ok {
|
||||
a.log.Error("bot access not deleted", "error", err)
|
||||
}
|
||||
|
||||
return bba.Add(ctx, tgbID, until, botName)
|
||||
|
||||
}
|
||||
|
||||
// UnBanUser
|
||||
// Remove restriction from an user and create a access request
|
||||
func (a Adapter) UnBanUser(ctx context.Context, tgbID int64, botName string) (bool, error) {
|
||||
bba := NewBotBannedAccess(a.db, a.log)
|
||||
bar := NewBotAccessRequest(a.db, a.log)
|
||||
|
||||
if ok, err := bba.Delete(ctx, tgbID, botName); !ok {
|
||||
return false, err
|
||||
} else {
|
||||
return bar.Add(ctx, tgbID, botName)
|
||||
}
|
||||
}
|
||||
|
||||
// CreateBot
|
||||
// create a new bot in db
|
||||
func (a Adapter) CreateBot(ctx context.Context, botName string) (bool, error) {
|
||||
bu := NewBotUser(a.db, a.log)
|
||||
return bu.CreateBot(ctx, botName)
|
||||
}
|
||||
69
internal/adapters/db/schema.sql
Normal file
69
internal/adapters/db/schema.sql
Normal file
@ -0,0 +1,69 @@
|
||||
-- sql goes here
|
||||
CREATE TABLE IF NOT EXISTS 'users' (
|
||||
id INTEGER PRIMARY KEY,
|
||||
tgb_id INTEGER NOT NULL UNIQUE,
|
||||
username TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
created INTEGER NOT NULL,
|
||||
edited INTEGER NOT NULL,
|
||||
deleted INTEGER
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS tgb_id_user_index ON 'users' (tgb_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS 'visits' (
|
||||
id INTEGER PRIMARY KEY,
|
||||
tgb_id INTEGER NOT NULL,
|
||||
quantity INTEGER,
|
||||
edited INTEGER,
|
||||
FOREIGN KEY(tgb_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS tgb_id_visit_index ON 'users' (tgb_id);
|
||||
|
||||
CREATE TRIGGER IF NOT EXISTS check_daily_visits
|
||||
BEFORE INSERT ON 'users'
|
||||
BEGIN
|
||||
INSERT OR IGNORE INTO 'visits' (tgb_id, quantity, edited)
|
||||
VALUES (new.tgb_id, 1, strftime('%s', 'now'));
|
||||
END;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS 'bots' (
|
||||
id INTEGER PRIMARY KEY,
|
||||
bot_name TEXT UNIQUE,
|
||||
created INTEGER NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS 'bot_users' (
|
||||
id INTEGER PRIMARY KEY,
|
||||
tgb_id INTEGER NOT NULL,
|
||||
bot_id INTEGER NOT NULL,
|
||||
created INTEGER NOT NULL,
|
||||
UNIQUE(tgb_id, bot_id),
|
||||
FOREIGN KEY(tgb_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(bot_id) REFERENCES bots(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS 'bot_access_requests' (
|
||||
id INTEGER PRIMARY KEY,
|
||||
tgb_id INTEGER NOT NULL,
|
||||
bot_id INTEGER NOT NULL,
|
||||
created INTEGER NOT NULL,
|
||||
UNIQUE(tgb_id, bot_id),
|
||||
FOREIGN KEY(tgb_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(bot_id) REFERENCES bots(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS 'banned_bot_access' (
|
||||
id INTEGER PRIMARY KEY,
|
||||
tgb_id INTEGER NOT NULL,
|
||||
bot_id INTEGER NOT NULL,
|
||||
created INTEGER NOT NULL,
|
||||
until INTEGER NOT NULL,
|
||||
UNIQUE(tgb_id, bot_id),
|
||||
FOREIGN KEY(tgb_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(bot_id) REFERENCES bots(id) ON DELETE CASCADE
|
||||
);
|
||||
157
internal/adapters/db/users.go
Normal file
157
internal/adapters/db/users.go
Normal file
@ -0,0 +1,157 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/application/core/domain"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
db *sql.DB
|
||||
log *slog.Logger
|
||||
ID int64 `json:"id"`
|
||||
Tgb_ID int64 `json:"tgb_id"`
|
||||
Username string `json:"username"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Created int64 `json:"created"`
|
||||
Edited int64 `json:"edited"`
|
||||
Deleted int64 `json:"deleted"`
|
||||
}
|
||||
|
||||
func NewUser(db *sql.DB, log *slog.Logger) *User {
|
||||
log = log.With("obj", "User")
|
||||
return &User{
|
||||
db: db,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
func (u User) Get(ctx context.Context, tgb_id int64) (*domain.User, error) {
|
||||
stmt, err := u.db.PrepareContext(ctx,
|
||||
`
|
||||
SELECT u.id, u.tgb_id, u.username, u.first_name, u.last_name, u.created, u.edited
|
||||
FROM users AS u
|
||||
WHERE u.tgb_id = ? AND deleted IS NULL;
|
||||
`)
|
||||
if err != nil {
|
||||
u.log.Error("prepare stmt get", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
us := &domain.User{}
|
||||
if err := stmt.QueryRowContext(ctx, tgb_id).Scan(&us.ID, &us.TGB_ID, &us.Username, &us.FirstName, &us.LastName, &us.Created, &us.Edited); err != nil {
|
||||
u.log.Error("query row context get", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
bu := NewBotUser(u.db, u.log)
|
||||
bul, err := bu.GetBots(ctx, us.TGB_ID)
|
||||
if err != nil {
|
||||
u.log.Error("getting bots", "error", err)
|
||||
}
|
||||
for _, i := range bul {
|
||||
us.TGBOT = us.TGBOT + "," + i.BotName
|
||||
}
|
||||
us.TGBOT, _ = strings.CutPrefix(us.TGBOT, ",")
|
||||
return us, nil
|
||||
}
|
||||
|
||||
func (u User) Create(ctx context.Context, user *domain.User) (bool, error) {
|
||||
stmt, err := u.db.PrepareContext(ctx,
|
||||
`
|
||||
INSERT INTO users (tgb_id, username, first_name, last_name, created, edited)
|
||||
VALUES(?,?,?,?,strftime('%s', 'now'),strftime('%s', 'now'));
|
||||
`)
|
||||
if err != nil {
|
||||
u.log.Error("prepare stmt create", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, user.TGB_ID, user.Username, user.FirstName, user.LastName)
|
||||
if err != nil {
|
||||
u.log.Error("exec context create", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
|
||||
}
|
||||
func (u User) Edit(ctx context.Context, user domain.User) (bool, error) {
|
||||
stmt, err := u.db.PrepareContext(ctx,
|
||||
`
|
||||
UPDATE users
|
||||
SET username = ?,
|
||||
first_name = ?,
|
||||
last_name = ?,
|
||||
edited = strftime('%s', 'now')
|
||||
WHERE
|
||||
tgb_id = ? AND deleted IS NULL;
|
||||
`)
|
||||
if err != nil {
|
||||
u.log.Error("prepare stmt edit", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
row, err := stmt.ExecContext(ctx, user.Username, user.FirstName, user.LastName, user.TGB_ID)
|
||||
if err != nil {
|
||||
u.log.Error("exec context edit", "error", err)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
num, _ := row.RowsAffected()
|
||||
if num < 1 {
|
||||
return false, fmt.Errorf("no rows affected with tgb_id: %d", user.TGB_ID)
|
||||
}
|
||||
return true, nil
|
||||
|
||||
}
|
||||
func (u User) Delete(ctx context.Context, tgb_id int64) (bool, error) {
|
||||
stmt, err := u.db.PrepareContext(ctx, `
|
||||
UPDATE users
|
||||
SET deleted = strftime('%s', 'now'),
|
||||
edited = strftime('%s', 'now')
|
||||
WHERE tgb_id = ?;
|
||||
`)
|
||||
if err != nil {
|
||||
u.log.Error("prepare stmt delete", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, tgb_id)
|
||||
if err != nil {
|
||||
u.log.Error("exec context delete", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (u User) HardDelete(ctx context.Context, tgb_id int64) (bool, error) {
|
||||
stmt, err := u.db.PrepareContext(ctx, `
|
||||
DELETE FROM users
|
||||
WHERE tgb_id = ?;
|
||||
`)
|
||||
if err != nil {
|
||||
u.log.Error("prepare stmt hard delete", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, tgb_id)
|
||||
if err != nil {
|
||||
u.log.Error("exec context hard delete", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
func (u User) AddBot(ctx context.Context, tgb_id int64, bot_name string) (bool, error) {
|
||||
bu := BotUser{db: u.db}
|
||||
ok, err := bu.Add(ctx, tgb_id, bot_name)
|
||||
return ok, err
|
||||
}
|
||||
func (u User) DeleteBot(ctx context.Context, tgb_id int64, bot_name string) (bool, error) {
|
||||
bu := BotUser{db: u.db}
|
||||
ok, err := bu.Delete(ctx, tgb_id, bot_name)
|
||||
return ok, err
|
||||
}
|
||||
56
internal/adapters/db/visits.go
Normal file
56
internal/adapters/db/visits.go
Normal file
@ -0,0 +1,56 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type Visit struct {
|
||||
db *sql.DB
|
||||
log *slog.Logger
|
||||
ID int64 `json:"id"`
|
||||
Tgb_ID int64 `json:"tgb_id"`
|
||||
Quantity int `json:"quantity"`
|
||||
Edited int64 `json:"edited"`
|
||||
}
|
||||
|
||||
func NewVisits(db *sql.DB, log *slog.Logger) *Visit {
|
||||
log = log.With("obj", "Visits")
|
||||
return &Visit{db: db, log: log}
|
||||
}
|
||||
|
||||
func (v Visit) Add(ctx context.Context, tgb_id int64) (bool, error) {
|
||||
stmt, err := v.db.PrepareContext(ctx,
|
||||
`
|
||||
UPDATE visits
|
||||
SET quantity = quantity + 1,
|
||||
edited = strftime('%s','now')
|
||||
WHERE tgb_id = ?;`)
|
||||
if err != nil {
|
||||
v.log.Error("prepare stmt", "error", err)
|
||||
return false, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
_, err = stmt.ExecContext(ctx, tgb_id)
|
||||
if err != nil {
|
||||
v.log.Error("exec content", "error", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
func (v Visit) Get(ctx context.Context, tgb_id int64) (*Visit, error) {
|
||||
stmt, err := v.db.PrepareContext(ctx, "SELECT id, tgb_id, quantity, edited FROM visits WHERE tgb_id = ?;")
|
||||
if err != nil {
|
||||
v.log.Error("prepare stmt", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
vi := &Visit{}
|
||||
if err := stmt.QueryRowContext(ctx, tgb_id).Scan(&v.ID, &v.Tgb_ID, &v.Quantity, &v.Edited); err != nil {
|
||||
v.log.Error("Query row", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vi, nil
|
||||
}
|
||||
223
internal/adapters/grpc/grpc.go
Normal file
223
internal/adapters/grpc/grpc.go
Normal file
@ -0,0 +1,223 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.maximotejeda.com/maximo/tgb-user/proto/golang/tgbuser"
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/application/core/domain"
|
||||
)
|
||||
|
||||
// TODO: Methods to map to api <-> grpc
|
||||
|
||||
func (a Adapter) Create(ctx context.Context, req *tgbuser.CreateTGBUserRequest) (*tgbuser.CreateTGBUserResponse, error) {
|
||||
// TODO db work
|
||||
user := &domain.User{
|
||||
ID: req.User.Id,
|
||||
TGB_ID: req.User.TgbId,
|
||||
Username: req.User.Username,
|
||||
FirstName: req.User.FirstName,
|
||||
LastName: req.User.LastName,
|
||||
TGBOT: req.User.TgBot,
|
||||
}
|
||||
_, err := a.api.Create(ctx, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &tgbuser.CreateTGBUserResponse{Id: req.User.Id}, nil
|
||||
}
|
||||
func (a Adapter) Get(ctx context.Context, req *tgbuser.GetTGBUserRequest) (*tgbuser.GetTGBUserResponse, error) {
|
||||
// TODO db work
|
||||
user, err := a.api.Get(ctx, req.TgbId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
us := &tgbuser.User{
|
||||
Id: user.ID,
|
||||
TgbId: user.TGB_ID,
|
||||
Username: user.Username,
|
||||
FirstName: user.FirstName,
|
||||
LastName: user.LastName,
|
||||
TgBot: user.TGBOT,
|
||||
Created: user.Created,
|
||||
Edited: user.Edited,
|
||||
}
|
||||
return &tgbuser.GetTGBUserResponse{User: us}, err
|
||||
}
|
||||
func (a Adapter) Edit(ctx context.Context, req *tgbuser.EditTGBUserRequest) (*tgbuser.EditTGBUserResponse, error) {
|
||||
// TODO db work
|
||||
user := &domain.User{
|
||||
ID: req.User.Id,
|
||||
TGB_ID: req.User.TgbId,
|
||||
Username: req.User.Username,
|
||||
FirstName: req.User.FirstName,
|
||||
LastName: req.User.LastName,
|
||||
TGBOT: req.User.TgBot,
|
||||
}
|
||||
|
||||
ok, err := a.api.Edit(ctx, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &tgbuser.EditTGBUserResponse{Response: ok}, nil
|
||||
}
|
||||
func (a Adapter) Delete(ctx context.Context, req *tgbuser.DeleteTGBUserRequest) (*tgbuser.DeleteTGBUserResponse, error) {
|
||||
ok, err := a.api.Delete(ctx, req.TgbId)
|
||||
// TODO db work
|
||||
return &tgbuser.DeleteTGBUserResponse{Response: ok}, err
|
||||
}
|
||||
func (a Adapter) AddBot(ctx context.Context, req *tgbuser.AddBotTGBUserRequest) (*tgbuser.AddBotTGBUserResponse, error) {
|
||||
// TODO db work
|
||||
ok, err := a.api.AddBot(ctx, req.TgbId, req.BotName)
|
||||
return &tgbuser.AddBotTGBUserResponse{Response: ok}, err
|
||||
}
|
||||
func (a Adapter) DeleteBot(ctx context.Context, req *tgbuser.DeleteBotTGBUserRequest) (*tgbuser.DeleteBotTGBUserResponse, error) {
|
||||
// TODO db work
|
||||
ok, err := a.api.DeleteBot(ctx, req.TgbId, req.BotName)
|
||||
return &tgbuser.DeleteBotTGBUserResponse{Response: ok}, err
|
||||
}
|
||||
|
||||
func (a Adapter) GetBots(ctx context.Context, req *tgbuser.GetBotsTGBUserRequest) (*tgbuser.GetBotsTGBUserResponse, error) {
|
||||
bl, err := a.api.GetBots(ctx, req.TgbId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
botList := []*tgbuser.Bot{}
|
||||
for _, v := range bl {
|
||||
b := &tgbuser.Bot{
|
||||
Id: v.ID,
|
||||
BotName: v.BotName,
|
||||
Created: v.Created,
|
||||
}
|
||||
botList = append(botList, b)
|
||||
}
|
||||
return &tgbuser.GetBotsTGBUserResponse{Bots: botList}, nil
|
||||
}
|
||||
|
||||
func (a Adapter) GetAllBotsUsers(ctx context.Context, req *tgbuser.GetAllBotsUsersRequest) (*tgbuser.GetAllBotsUsersResponse, error) {
|
||||
users, err := a.api.GetAllBotsUsers(ctx, req.BotName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
userList := []*tgbuser.User{}
|
||||
for _, v := range users {
|
||||
user := &tgbuser.User{
|
||||
Id: v.ID,
|
||||
TgbId: v.TGB_ID,
|
||||
Username: v.Username,
|
||||
FirstName: v.FirstName,
|
||||
LastName: v.LastName,
|
||||
Created: v.Created,
|
||||
Edited: v.Edited,
|
||||
}
|
||||
userList = append(userList, user)
|
||||
}
|
||||
return &tgbuser.GetAllBotsUsersResponse{Users: userList}, err
|
||||
}
|
||||
|
||||
func (a Adapter) GetAllBots(ctx context.Context, req *tgbuser.GetAllBotsRequest) (*tgbuser.GetAllBotsResponse, error) {
|
||||
bots, err := a.api.GetAllBots(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
botList := []*tgbuser.Bot{}
|
||||
for _, v := range bots {
|
||||
bot := &tgbuser.Bot{
|
||||
Id: v.ID,
|
||||
BotName: v.BotName,
|
||||
Created: v.Created,
|
||||
}
|
||||
botList = append(botList, bot)
|
||||
}
|
||||
return &tgbuser.GetAllBotsResponse{Bots: botList}, nil
|
||||
}
|
||||
|
||||
func (a Adapter) CreateBot(ctx context.Context, req *tgbuser.TGBBotNameRequest) (*tgbuser.TGBGenericResponse, error) {
|
||||
ok, err := a.api.CreateBot(ctx, req.BotName)
|
||||
return &tgbuser.TGBGenericResponse{Response: ok}, err
|
||||
}
|
||||
func (a Adapter) CreateAccessRequest(ctx context.Context, req *tgbuser.TGBUserBotNameRequest) (*tgbuser.TGBGenericResponse, error) {
|
||||
ok, err := a.api.CreateAccessRequest(ctx, req.TgbId, req.BotName)
|
||||
return &tgbuser.TGBGenericResponse{Response: ok}, err
|
||||
}
|
||||
func (a Adapter) GrantAccess(ctx context.Context, req *tgbuser.TGBUserBotNameRequest) (*tgbuser.TGBGenericResponse, error) {
|
||||
ok, err := a.api.GrantAccess(ctx, req.TgbId, req.BotName)
|
||||
return &tgbuser.TGBGenericResponse{Response: ok}, err
|
||||
}
|
||||
func (a Adapter) BanUser(ctx context.Context, req *tgbuser.TGBBanUserRequest) (*tgbuser.TGBGenericResponse, error) {
|
||||
|
||||
ok, err := a.api.BanUser(ctx, req.TgbId, req.Until, req.BotName)
|
||||
return &tgbuser.TGBGenericResponse{Response: ok}, err
|
||||
}
|
||||
func (a Adapter) UnBanUser(ctx context.Context, req *tgbuser.TGBUserBotNameRequest) (*tgbuser.TGBGenericResponse, error) {
|
||||
|
||||
ok, err := a.api.UnBanUser(ctx, req.TgbId, req.BotName)
|
||||
return &tgbuser.TGBGenericResponse{Response: ok}, err
|
||||
}
|
||||
func (a Adapter) GetAllAccessRequest(ctx context.Context, req *tgbuser.TGBBotNameRequest) (*tgbuser.GetAccessResponse, error) {
|
||||
ar, err := a.api.GetAllAccessRequest(ctx, req.BotName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tgbARL := []*tgbuser.AccessRq{}
|
||||
for _, it := range ar {
|
||||
tgbAr := &tgbuser.AccessRq{
|
||||
TgbId: it.TgbID,
|
||||
BotName: it.BotName,
|
||||
Created: it.Created,
|
||||
}
|
||||
tgbARL = append(tgbARL, tgbAr)
|
||||
}
|
||||
return &tgbuser.GetAccessResponse{Access: tgbARL}, err
|
||||
}
|
||||
func (a Adapter) GetAllBannedUsers(ctx context.Context, req *tgbuser.TGBBotNameRequest) (*tgbuser.GetBanResponse, error) {
|
||||
br, err := a.api.GetAllBannedUsers(ctx, req.BotName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
brL := []*tgbuser.Ban{}
|
||||
for _, it := range br {
|
||||
b := &tgbuser.Ban{
|
||||
TgbId: it.TgbID,
|
||||
BotName: it.BotName,
|
||||
Until: it.Until,
|
||||
Created: it.Created,
|
||||
}
|
||||
brL = append(brL, b)
|
||||
}
|
||||
return &tgbuser.GetBanResponse{Bans: brL}, err
|
||||
}
|
||||
|
||||
func (a Adapter) GetBannedBot(ctx context.Context, req *tgbuser.TGBUserRequest) (*tgbuser.GetBanResponse, error) {
|
||||
br, err := a.api.GetBannedBot(ctx, req.TgbId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
brL := []*tgbuser.Ban{}
|
||||
for _, it := range br {
|
||||
b := &tgbuser.Ban{
|
||||
TgbId: it.TgbID,
|
||||
BotName: it.BotName,
|
||||
Until: it.Until,
|
||||
Created: it.Created,
|
||||
}
|
||||
brL = append(brL, b)
|
||||
}
|
||||
return &tgbuser.GetBanResponse{Bans: brL}, err
|
||||
}
|
||||
func (a Adapter) GetAccessRequest(ctx context.Context, req *tgbuser.TGBUserRequest) (*tgbuser.GetAccessResponse, error) {
|
||||
ar, err := a.api.GetAccessRequest(ctx, req.TgbId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tgbARL := []*tgbuser.AccessRq{}
|
||||
for _, it := range ar {
|
||||
tgbAr := &tgbuser.AccessRq{
|
||||
TgbId: it.TgbID,
|
||||
BotName: it.BotName,
|
||||
Created: it.Created,
|
||||
}
|
||||
tgbARL = append(tgbARL, tgbAr)
|
||||
}
|
||||
return &tgbuser.GetAccessResponse{Access: tgbARL}, err
|
||||
}
|
||||
48
internal/adapters/grpc/server.go
Normal file
48
internal/adapters/grpc/server.go
Normal file
@ -0,0 +1,48 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net"
|
||||
|
||||
"git.maximotejeda.com/maximo/tgb-user/config"
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/ports"
|
||||
"git.maximotejeda.com/maximo/tgb-user/proto/golang/tgbuser"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
||||
type Adapter struct {
|
||||
api ports.APIPort
|
||||
port int
|
||||
log *slog.Logger
|
||||
tgbuser.UnimplementedUserManagerServer
|
||||
|
||||
}
|
||||
|
||||
func NewAdapter(api ports.APIPort, port int) *Adapter {
|
||||
log := slog.Default()
|
||||
log = log.With("adapter", "dolar-grpc")
|
||||
return &Adapter{api: api, port: port, log: log}
|
||||
}
|
||||
|
||||
func (a Adapter) Run() {
|
||||
var err error
|
||||
|
||||
listen, err := net.Listen("tcp", fmt.Sprintf(":%d", a.port))
|
||||
if err != nil {
|
||||
a.log.Error("failed to listen", "port", a.port, "error", err)
|
||||
panic(err)
|
||||
}
|
||||
grpcServer := grpc.NewServer()
|
||||
|
||||
tgbuser.RegisterUserManagerServer(grpcServer, a)
|
||||
|
||||
if config.GetEnv() == "development" {
|
||||
// This is to use GRPCurl to test services
|
||||
reflection.Register(grpcServer)
|
||||
}
|
||||
if err := grpcServer.Serve(listen); err != nil {
|
||||
a.log.Error("failed to serve grpc on port", "port", a.port)
|
||||
}
|
||||
}
|
||||
94
internal/application/core/api/api.go
Normal file
94
internal/application/core/api/api.go
Normal file
@ -0,0 +1,94 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/adapters/db"
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/application/core/domain"
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/ports"
|
||||
)
|
||||
|
||||
type Application struct {
|
||||
db ports.DBPort
|
||||
log *slog.Logger
|
||||
}
|
||||
|
||||
func NewApplication(db ports.DBPort) *Application {
|
||||
log := slog.Default()
|
||||
log = log.With("adapter", "application")
|
||||
return &Application{
|
||||
db: db,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
// todo Export differents Methods to map to grpc contracts
|
||||
func (a Application) Create(ctx context.Context, user *domain.User) (bool, error) {
|
||||
ok, err := a.db.Create(ctx, user)
|
||||
return ok, err
|
||||
}
|
||||
func (a Application) Get(ctx context.Context, tgb_id int64) (*domain.User, error) {
|
||||
user, err := a.db.Get(ctx, tgb_id)
|
||||
return user, err
|
||||
}
|
||||
func (a Application) Edit(ctx context.Context, user *domain.User) (bool, error) {
|
||||
ok, err := a.db.Edit(ctx, user)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return ok, err
|
||||
}
|
||||
func (a Application) Delete(ctx context.Context, id int64) (bool, error) {
|
||||
ok, err := a.db.Delete(ctx, id)
|
||||
return ok, err
|
||||
}
|
||||
func (a Application) AddBot(ctx context.Context, tgb_id int64, botname string) (bool, error) {
|
||||
ok, err := a.db.AddBot(ctx, tgb_id, botname)
|
||||
return ok, err
|
||||
}
|
||||
|
||||
func (a Application) DeleteBot(ctx context.Context, tgb_id int64, botname string) (bool, error) {
|
||||
ok, err := a.db.DeleteBot(ctx, tgb_id, botname)
|
||||
return ok, err
|
||||
}
|
||||
|
||||
func (a Application) GetBots(ctx context.Context, tgb_id int64) ([]*domain.Bot, error) {
|
||||
return a.db.GetBots(ctx, tgb_id)
|
||||
}
|
||||
|
||||
func (a Application) GetAllBotsUsers(ctx context.Context, bot_name string) ([]*domain.User, error) {
|
||||
return a.db.GetAllBotUsers(ctx, bot_name)
|
||||
}
|
||||
func (a Application) GetAllBots(ctx context.Context) ([]*domain.Bot, error) {
|
||||
return a.db.GetAllBots(ctx)
|
||||
}
|
||||
|
||||
func (a Application) CreateBot(ctx context.Context, botName string) (bool, error) {
|
||||
return a.db.CreateBot(ctx, botName)
|
||||
}
|
||||
func (a Application) CreateAccessRequest(ctx context.Context, tgbID int64, botName string) (bool, error) {
|
||||
return a.db.CreateAccessRequest(ctx, tgbID, botName)
|
||||
}
|
||||
func (a Application) GrantAccess(ctx context.Context, tgbID int64, botName string) (bool, error) {
|
||||
return a.db.GrantAccess(ctx, tgbID, botName)
|
||||
}
|
||||
func (a Application) BanUser(ctx context.Context, tgbID, until int64, botName string) (bool, error) {
|
||||
return a.db.BanUser(ctx, tgbID, until, botName)
|
||||
}
|
||||
func (a Application) UnBanUser(ctx context.Context, tgbID int64, botName string) (bool, error) {
|
||||
return a.db.UnBanUser(ctx, tgbID, botName)
|
||||
}
|
||||
|
||||
func (a Application) GetAllAccessRequest(ctx context.Context, botName string) ([]*db.BotAccessRequest, error) {
|
||||
return a.db.GetAllAccessRequest(ctx, botName)
|
||||
}
|
||||
func (a Application) GetAllBannedUsers(ctx context.Context, botName string) ([]*db.BotBannedAccess, error) {
|
||||
return a.db.GetAllBannedUsers(ctx, botName)
|
||||
}
|
||||
func (a Application) GetAccessRequest(ctx context.Context, tgbID int64) ([]*db.BotAccessRequest, error) {
|
||||
return a.db.GetAccessRequest(ctx, tgbID)
|
||||
}
|
||||
func (a Application) GetBannedBot(ctx context.Context, tgbID int64) ([]*db.BotBannedAccess, error) {
|
||||
return a.db.GetBannedBot(ctx, tgbID)
|
||||
}
|
||||
7
internal/application/core/domain/bot.go
Normal file
7
internal/application/core/domain/bot.go
Normal file
@ -0,0 +1,7 @@
|
||||
package domain
|
||||
|
||||
type Bot struct {
|
||||
ID int64 `json:"id"`
|
||||
BotName string `json:"bot_name"`
|
||||
Created int64 `json:"created"`
|
||||
}
|
||||
1
internal/application/core/domain/domain.go
Normal file
1
internal/application/core/domain/domain.go
Normal file
@ -0,0 +1 @@
|
||||
package domain
|
||||
13
internal/application/core/domain/user.go
Normal file
13
internal/application/core/domain/user.go
Normal file
@ -0,0 +1,13 @@
|
||||
package domain
|
||||
|
||||
type User struct {
|
||||
ID int64 `json:"id"`
|
||||
TGB_ID int64 `json:"tgb_id"`
|
||||
Username string `json:"username"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
TGBOT string `json:"tg_bot"`
|
||||
Created int64 `json:"created"`
|
||||
Edited int64 `json:"edited"`
|
||||
Deleted int64 `json:"deleted"`
|
||||
}
|
||||
29
internal/ports/api.go
Normal file
29
internal/ports/api.go
Normal file
@ -0,0 +1,29 @@
|
||||
package ports
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/adapters/db"
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/application/core/domain"
|
||||
)
|
||||
|
||||
type APIPort interface {
|
||||
Create(context.Context, *domain.User) (bool, error)
|
||||
Get(context.Context, int64) (*domain.User, error)
|
||||
Edit(context.Context, *domain.User) (bool, error)
|
||||
Delete(context.Context, int64) (bool, error)
|
||||
AddBot(context.Context, int64, string) (bool, error)
|
||||
DeleteBot(context.Context, int64, string) (bool, error)
|
||||
GetBots(context.Context, int64) ([]*domain.Bot, error)
|
||||
GetAllBotsUsers(context.Context, string) ([]*domain.User, error)
|
||||
GetAllBots(context.Context) ([]*domain.Bot, error)
|
||||
CreateBot(context.Context, string) (bool, error)
|
||||
CreateAccessRequest(context.Context, int64, string) (bool, error)
|
||||
GrantAccess(context.Context, int64, string) (bool, error)
|
||||
BanUser(context.Context, int64, int64, string) (bool, error)
|
||||
UnBanUser(context.Context, int64, string) (bool, error)
|
||||
GetAllAccessRequest(context.Context, string) ([]*db.BotAccessRequest, error)
|
||||
GetAllBannedUsers(context.Context, string) ([]*db.BotBannedAccess, error)
|
||||
GetAccessRequest(context.Context, int64) ([]*db.BotAccessRequest, error)
|
||||
GetBannedBot(context.Context, int64) ([]*db.BotBannedAccess, error)
|
||||
}
|
||||
29
internal/ports/db.go
Normal file
29
internal/ports/db.go
Normal file
@ -0,0 +1,29 @@
|
||||
package ports
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/adapters/db"
|
||||
"git.maximotejeda.com/maximo/tgb-user/internal/application/core/domain"
|
||||
)
|
||||
|
||||
type DBPort interface {
|
||||
Create(context.Context, *domain.User) (bool, error)
|
||||
Get(context.Context, int64) (*domain.User, error)
|
||||
Edit(context.Context, *domain.User) (bool, error)
|
||||
Delete(context.Context, int64) (bool, error)
|
||||
AddBot(context.Context, int64, string) (bool, error)
|
||||
DeleteBot(context.Context, int64, string) (bool, error)
|
||||
GetBots(context.Context, int64) ([]*domain.Bot, error)
|
||||
GetAllBotUsers(context.Context, string) ([]*domain.User, error)
|
||||
GetAllBots(context.Context) ([]*domain.Bot, error)
|
||||
CreateBot(context.Context, string) (bool, error)
|
||||
CreateAccessRequest(context.Context, int64, string) (bool, error)
|
||||
GrantAccess(context.Context, int64, string) (bool, error)
|
||||
BanUser(context.Context, int64, int64, string) (bool, error)
|
||||
UnBanUser(context.Context, int64, string) (bool, error)
|
||||
GetAllAccessRequest(context.Context, string) ([]*db.BotAccessRequest, error)
|
||||
GetAllBannedUsers(context.Context, string) ([]*db.BotBannedAccess, error)
|
||||
GetAccessRequest(context.Context, int64) ([]*db.BotAccessRequest, error)
|
||||
GetBannedBot(context.Context, int64) ([]*db.BotBannedAccess, error)
|
||||
}
|
||||
62
k8s/deployment.yml
Normal file
62
k8s/deployment.yml
Normal file
@ -0,0 +1,62 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: tgbuser-grpc
|
||||
labels:
|
||||
app: tgbuser-grpc
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: tgbuser-grpc
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: tgbuser-grpc
|
||||
name: tgbuser-grpc
|
||||
spec:
|
||||
containers:
|
||||
- name: tgbuser-grpc
|
||||
image: localhost:32000/tgbuser-grpc:latest
|
||||
env:
|
||||
- name: ENV
|
||||
value: "production"
|
||||
- name: NATS_SERVICE_URL
|
||||
value: "nats://nats-svc:4222"
|
||||
- name: DATA_SOURCE_URL
|
||||
value: "tgbdb/data.db"
|
||||
- name: APPLICATION_PORT
|
||||
value: "8080"
|
||||
volumeMounts:
|
||||
- name: db
|
||||
mountPath: "/app/tgbdb"
|
||||
volumes:
|
||||
- name: db
|
||||
persistentVolumeClaim:
|
||||
claimName: tgbuser-grpc-pvc
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: tgbuser-grpc-pvc
|
||||
spec:
|
||||
storageClassName: nfs-csi
|
||||
accessModes: [ReadWriteMany]
|
||||
resources:
|
||||
requests:
|
||||
storage: 30Mi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: tgbuser-grpc-svc
|
||||
spec:
|
||||
selector:
|
||||
app: tgbuser-grpc
|
||||
ports:
|
||||
- port: 80
|
||||
protocol: TCP
|
||||
targetPort: 8080
|
||||
name: grpc
|
||||
type: LoadBalancer
|
||||
62
k8s/deployment.yml.template
Normal file
62
k8s/deployment.yml.template
Normal file
@ -0,0 +1,62 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: $REPONAME
|
||||
labels:
|
||||
app: $REPONAME
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: $REPONAME
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: $REPONAME
|
||||
name: $REPONAME
|
||||
spec:
|
||||
containers:
|
||||
- name: $REPONAME
|
||||
image: $IMAGE
|
||||
env:
|
||||
- name: ENV
|
||||
value: "$ENVIRONMET"
|
||||
- name: NATS_SERVICE_URL
|
||||
value: "$NATS_SERVICE_URL"
|
||||
- name: DATA_SOURCE_URL
|
||||
value: "$DATA_SOURCE_URL"
|
||||
- name: APPLICATION_PORT
|
||||
value: "$APPLICATION_PORT"
|
||||
volumeMounts:
|
||||
- name: db
|
||||
mountPath: "$DATA_SOURCE_URL"
|
||||
volumes:
|
||||
- name: db
|
||||
persistentVolumeClaim:
|
||||
claimName: $REPONAME-pvc
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: $REPONAME-pvc
|
||||
spec:
|
||||
storageClassName: nfs-csi
|
||||
accessModes: [ReadWriteMany]
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: $REPONAME-svc
|
||||
spec:
|
||||
selector:
|
||||
app: $REPONAME
|
||||
ports:
|
||||
- port: 80
|
||||
protocol: TCP
|
||||
targetPort: $APPLICATION_PORT
|
||||
name: grpc
|
||||
type: LoadBalancer
|
||||
2200
proto/golang/tgbuser/tgbuser.pb.go
Normal file
2200
proto/golang/tgbuser/tgbuser.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
738
proto/golang/tgbuser/tgbuser_grpc.pb.go
Normal file
738
proto/golang/tgbuser/tgbuser_grpc.pb.go
Normal file
@ -0,0 +1,738 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v4.25.1
|
||||
// source: tgbuser/tgbuser.proto
|
||||
|
||||
package tgbuser
|
||||
|
||||
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.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
UserManager_Create_FullMethodName = "/UserManager/Create"
|
||||
UserManager_Get_FullMethodName = "/UserManager/Get"
|
||||
UserManager_Edit_FullMethodName = "/UserManager/Edit"
|
||||
UserManager_Delete_FullMethodName = "/UserManager/Delete"
|
||||
UserManager_AddBot_FullMethodName = "/UserManager/AddBot"
|
||||
UserManager_DeleteBot_FullMethodName = "/UserManager/DeleteBot"
|
||||
UserManager_GetBots_FullMethodName = "/UserManager/GetBots"
|
||||
UserManager_GetAllBotsUsers_FullMethodName = "/UserManager/GetAllBotsUsers"
|
||||
UserManager_GetAllBots_FullMethodName = "/UserManager/GetAllBots"
|
||||
UserManager_CreateBot_FullMethodName = "/UserManager/CreateBot"
|
||||
UserManager_CreateAccessRequest_FullMethodName = "/UserManager/CreateAccessRequest"
|
||||
UserManager_GrantAccess_FullMethodName = "/UserManager/GrantAccess"
|
||||
UserManager_BanUser_FullMethodName = "/UserManager/BanUser"
|
||||
UserManager_UnBanUser_FullMethodName = "/UserManager/UnBanUser"
|
||||
UserManager_GetAllAccessRequest_FullMethodName = "/UserManager/GetAllAccessRequest"
|
||||
UserManager_GetAllBannedUsers_FullMethodName = "/UserManager/GetAllBannedUsers"
|
||||
UserManager_GetAccessRequest_FullMethodName = "/UserManager/GetAccessRequest"
|
||||
UserManager_GetBannedBot_FullMethodName = "/UserManager/GetBannedBot"
|
||||
)
|
||||
|
||||
// UserManagerClient is the client API for UserManager 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 UserManagerClient interface {
|
||||
Create(ctx context.Context, in *CreateTGBUserRequest, opts ...grpc.CallOption) (*CreateTGBUserResponse, error)
|
||||
Get(ctx context.Context, in *GetTGBUserRequest, opts ...grpc.CallOption) (*GetTGBUserResponse, error)
|
||||
Edit(ctx context.Context, in *EditTGBUserRequest, opts ...grpc.CallOption) (*EditTGBUserResponse, error)
|
||||
Delete(ctx context.Context, in *DeleteTGBUserRequest, opts ...grpc.CallOption) (*DeleteTGBUserResponse, error)
|
||||
AddBot(ctx context.Context, in *AddBotTGBUserRequest, opts ...grpc.CallOption) (*AddBotTGBUserResponse, error)
|
||||
DeleteBot(ctx context.Context, in *DeleteBotTGBUserRequest, opts ...grpc.CallOption) (*DeleteBotTGBUserResponse, error)
|
||||
GetBots(ctx context.Context, in *GetBotsTGBUserRequest, opts ...grpc.CallOption) (*GetBotsTGBUserResponse, error)
|
||||
GetAllBotsUsers(ctx context.Context, in *GetAllBotsUsersRequest, opts ...grpc.CallOption) (*GetAllBotsUsersResponse, error)
|
||||
GetAllBots(ctx context.Context, in *GetAllBotsRequest, opts ...grpc.CallOption) (*GetAllBotsResponse, error)
|
||||
CreateBot(ctx context.Context, in *TGBBotNameRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error)
|
||||
CreateAccessRequest(ctx context.Context, in *TGBUserBotNameRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error)
|
||||
GrantAccess(ctx context.Context, in *TGBUserBotNameRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error)
|
||||
BanUser(ctx context.Context, in *TGBBanUserRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error)
|
||||
UnBanUser(ctx context.Context, in *TGBUserBotNameRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error)
|
||||
GetAllAccessRequest(ctx context.Context, in *TGBBotNameRequest, opts ...grpc.CallOption) (*GetAccessResponse, error)
|
||||
GetAllBannedUsers(ctx context.Context, in *TGBBotNameRequest, opts ...grpc.CallOption) (*GetBanResponse, error)
|
||||
GetAccessRequest(ctx context.Context, in *TGBUserRequest, opts ...grpc.CallOption) (*GetAccessResponse, error)
|
||||
GetBannedBot(ctx context.Context, in *TGBUserRequest, opts ...grpc.CallOption) (*GetBanResponse, error)
|
||||
}
|
||||
|
||||
type userManagerClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewUserManagerClient(cc grpc.ClientConnInterface) UserManagerClient {
|
||||
return &userManagerClient{cc}
|
||||
}
|
||||
|
||||
func (c *userManagerClient) Create(ctx context.Context, in *CreateTGBUserRequest, opts ...grpc.CallOption) (*CreateTGBUserResponse, error) {
|
||||
out := new(CreateTGBUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_Create_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) Get(ctx context.Context, in *GetTGBUserRequest, opts ...grpc.CallOption) (*GetTGBUserResponse, error) {
|
||||
out := new(GetTGBUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_Get_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) Edit(ctx context.Context, in *EditTGBUserRequest, opts ...grpc.CallOption) (*EditTGBUserResponse, error) {
|
||||
out := new(EditTGBUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_Edit_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) Delete(ctx context.Context, in *DeleteTGBUserRequest, opts ...grpc.CallOption) (*DeleteTGBUserResponse, error) {
|
||||
out := new(DeleteTGBUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_Delete_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) AddBot(ctx context.Context, in *AddBotTGBUserRequest, opts ...grpc.CallOption) (*AddBotTGBUserResponse, error) {
|
||||
out := new(AddBotTGBUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_AddBot_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) DeleteBot(ctx context.Context, in *DeleteBotTGBUserRequest, opts ...grpc.CallOption) (*DeleteBotTGBUserResponse, error) {
|
||||
out := new(DeleteBotTGBUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_DeleteBot_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) GetBots(ctx context.Context, in *GetBotsTGBUserRequest, opts ...grpc.CallOption) (*GetBotsTGBUserResponse, error) {
|
||||
out := new(GetBotsTGBUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_GetBots_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) GetAllBotsUsers(ctx context.Context, in *GetAllBotsUsersRequest, opts ...grpc.CallOption) (*GetAllBotsUsersResponse, error) {
|
||||
out := new(GetAllBotsUsersResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_GetAllBotsUsers_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) GetAllBots(ctx context.Context, in *GetAllBotsRequest, opts ...grpc.CallOption) (*GetAllBotsResponse, error) {
|
||||
out := new(GetAllBotsResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_GetAllBots_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) CreateBot(ctx context.Context, in *TGBBotNameRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error) {
|
||||
out := new(TGBGenericResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_CreateBot_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) CreateAccessRequest(ctx context.Context, in *TGBUserBotNameRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error) {
|
||||
out := new(TGBGenericResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_CreateAccessRequest_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) GrantAccess(ctx context.Context, in *TGBUserBotNameRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error) {
|
||||
out := new(TGBGenericResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_GrantAccess_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) BanUser(ctx context.Context, in *TGBBanUserRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error) {
|
||||
out := new(TGBGenericResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_BanUser_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) UnBanUser(ctx context.Context, in *TGBUserBotNameRequest, opts ...grpc.CallOption) (*TGBGenericResponse, error) {
|
||||
out := new(TGBGenericResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_UnBanUser_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) GetAllAccessRequest(ctx context.Context, in *TGBBotNameRequest, opts ...grpc.CallOption) (*GetAccessResponse, error) {
|
||||
out := new(GetAccessResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_GetAllAccessRequest_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) GetAllBannedUsers(ctx context.Context, in *TGBBotNameRequest, opts ...grpc.CallOption) (*GetBanResponse, error) {
|
||||
out := new(GetBanResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_GetAllBannedUsers_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) GetAccessRequest(ctx context.Context, in *TGBUserRequest, opts ...grpc.CallOption) (*GetAccessResponse, error) {
|
||||
out := new(GetAccessResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_GetAccessRequest_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userManagerClient) GetBannedBot(ctx context.Context, in *TGBUserRequest, opts ...grpc.CallOption) (*GetBanResponse, error) {
|
||||
out := new(GetBanResponse)
|
||||
err := c.cc.Invoke(ctx, UserManager_GetBannedBot_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// UserManagerServer is the server API for UserManager service.
|
||||
// All implementations must embed UnimplementedUserManagerServer
|
||||
// for forward compatibility
|
||||
type UserManagerServer interface {
|
||||
Create(context.Context, *CreateTGBUserRequest) (*CreateTGBUserResponse, error)
|
||||
Get(context.Context, *GetTGBUserRequest) (*GetTGBUserResponse, error)
|
||||
Edit(context.Context, *EditTGBUserRequest) (*EditTGBUserResponse, error)
|
||||
Delete(context.Context, *DeleteTGBUserRequest) (*DeleteTGBUserResponse, error)
|
||||
AddBot(context.Context, *AddBotTGBUserRequest) (*AddBotTGBUserResponse, error)
|
||||
DeleteBot(context.Context, *DeleteBotTGBUserRequest) (*DeleteBotTGBUserResponse, error)
|
||||
GetBots(context.Context, *GetBotsTGBUserRequest) (*GetBotsTGBUserResponse, error)
|
||||
GetAllBotsUsers(context.Context, *GetAllBotsUsersRequest) (*GetAllBotsUsersResponse, error)
|
||||
GetAllBots(context.Context, *GetAllBotsRequest) (*GetAllBotsResponse, error)
|
||||
CreateBot(context.Context, *TGBBotNameRequest) (*TGBGenericResponse, error)
|
||||
CreateAccessRequest(context.Context, *TGBUserBotNameRequest) (*TGBGenericResponse, error)
|
||||
GrantAccess(context.Context, *TGBUserBotNameRequest) (*TGBGenericResponse, error)
|
||||
BanUser(context.Context, *TGBBanUserRequest) (*TGBGenericResponse, error)
|
||||
UnBanUser(context.Context, *TGBUserBotNameRequest) (*TGBGenericResponse, error)
|
||||
GetAllAccessRequest(context.Context, *TGBBotNameRequest) (*GetAccessResponse, error)
|
||||
GetAllBannedUsers(context.Context, *TGBBotNameRequest) (*GetBanResponse, error)
|
||||
GetAccessRequest(context.Context, *TGBUserRequest) (*GetAccessResponse, error)
|
||||
GetBannedBot(context.Context, *TGBUserRequest) (*GetBanResponse, error)
|
||||
mustEmbedUnimplementedUserManagerServer()
|
||||
}
|
||||
|
||||
// UnimplementedUserManagerServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserManagerServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserManagerServer) Create(context.Context, *CreateTGBUserRequest) (*CreateTGBUserResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) Get(context.Context, *GetTGBUserRequest) (*GetTGBUserResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Get not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) Edit(context.Context, *EditTGBUserRequest) (*EditTGBUserResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Edit not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) Delete(context.Context, *DeleteTGBUserRequest) (*DeleteTGBUserResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) AddBot(context.Context, *AddBotTGBUserRequest) (*AddBotTGBUserResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddBot not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) DeleteBot(context.Context, *DeleteBotTGBUserRequest) (*DeleteBotTGBUserResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteBot not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) GetBots(context.Context, *GetBotsTGBUserRequest) (*GetBotsTGBUserResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBots not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) GetAllBotsUsers(context.Context, *GetAllBotsUsersRequest) (*GetAllBotsUsersResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetAllBotsUsers not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) GetAllBots(context.Context, *GetAllBotsRequest) (*GetAllBotsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetAllBots not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) CreateBot(context.Context, *TGBBotNameRequest) (*TGBGenericResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateBot not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) CreateAccessRequest(context.Context, *TGBUserBotNameRequest) (*TGBGenericResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateAccessRequest not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) GrantAccess(context.Context, *TGBUserBotNameRequest) (*TGBGenericResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GrantAccess not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) BanUser(context.Context, *TGBBanUserRequest) (*TGBGenericResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method BanUser not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) UnBanUser(context.Context, *TGBUserBotNameRequest) (*TGBGenericResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnBanUser not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) GetAllAccessRequest(context.Context, *TGBBotNameRequest) (*GetAccessResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetAllAccessRequest not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) GetAllBannedUsers(context.Context, *TGBBotNameRequest) (*GetBanResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetAllBannedUsers not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) GetAccessRequest(context.Context, *TGBUserRequest) (*GetAccessResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetAccessRequest not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) GetBannedBot(context.Context, *TGBUserRequest) (*GetBanResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBannedBot not implemented")
|
||||
}
|
||||
func (UnimplementedUserManagerServer) mustEmbedUnimplementedUserManagerServer() {}
|
||||
|
||||
// UnsafeUserManagerServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to UserManagerServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeUserManagerServer interface {
|
||||
mustEmbedUnimplementedUserManagerServer()
|
||||
}
|
||||
|
||||
func RegisterUserManagerServer(s grpc.ServiceRegistrar, srv UserManagerServer) {
|
||||
s.RegisterService(&UserManager_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _UserManager_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateTGBUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).Create(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_Create_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).Create(ctx, req.(*CreateTGBUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetTGBUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).Get(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_Get_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).Get(ctx, req.(*GetTGBUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_Edit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EditTGBUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).Edit(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_Edit_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).Edit(ctx, req.(*EditTGBUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteTGBUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).Delete(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_Delete_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).Delete(ctx, req.(*DeleteTGBUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_AddBot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AddBotTGBUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).AddBot(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_AddBot_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).AddBot(ctx, req.(*AddBotTGBUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_DeleteBot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteBotTGBUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).DeleteBot(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_DeleteBot_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).DeleteBot(ctx, req.(*DeleteBotTGBUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_GetBots_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetBotsTGBUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).GetBots(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_GetBots_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).GetBots(ctx, req.(*GetBotsTGBUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_GetAllBotsUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetAllBotsUsersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).GetAllBotsUsers(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_GetAllBotsUsers_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).GetAllBotsUsers(ctx, req.(*GetAllBotsUsersRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_GetAllBots_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetAllBotsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).GetAllBots(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_GetAllBots_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).GetAllBots(ctx, req.(*GetAllBotsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_CreateBot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TGBBotNameRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).CreateBot(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_CreateBot_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).CreateBot(ctx, req.(*TGBBotNameRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_CreateAccessRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TGBUserBotNameRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).CreateAccessRequest(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_CreateAccessRequest_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).CreateAccessRequest(ctx, req.(*TGBUserBotNameRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_GrantAccess_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TGBUserBotNameRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).GrantAccess(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_GrantAccess_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).GrantAccess(ctx, req.(*TGBUserBotNameRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_BanUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TGBBanUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).BanUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_BanUser_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).BanUser(ctx, req.(*TGBBanUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_UnBanUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TGBUserBotNameRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).UnBanUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_UnBanUser_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).UnBanUser(ctx, req.(*TGBUserBotNameRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_GetAllAccessRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TGBBotNameRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).GetAllAccessRequest(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_GetAllAccessRequest_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).GetAllAccessRequest(ctx, req.(*TGBBotNameRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_GetAllBannedUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TGBBotNameRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).GetAllBannedUsers(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_GetAllBannedUsers_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).GetAllBannedUsers(ctx, req.(*TGBBotNameRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_GetAccessRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TGBUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).GetAccessRequest(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_GetAccessRequest_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).GetAccessRequest(ctx, req.(*TGBUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserManager_GetBannedBot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TGBUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserManagerServer).GetBannedBot(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserManager_GetBannedBot_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserManagerServer).GetBannedBot(ctx, req.(*TGBUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// UserManager_ServiceDesc is the grpc.ServiceDesc for UserManager service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var UserManager_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "UserManager",
|
||||
HandlerType: (*UserManagerServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Create",
|
||||
Handler: _UserManager_Create_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Get",
|
||||
Handler: _UserManager_Get_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Edit",
|
||||
Handler: _UserManager_Edit_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Delete",
|
||||
Handler: _UserManager_Delete_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AddBot",
|
||||
Handler: _UserManager_AddBot_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteBot",
|
||||
Handler: _UserManager_DeleteBot_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBots",
|
||||
Handler: _UserManager_GetBots_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAllBotsUsers",
|
||||
Handler: _UserManager_GetAllBotsUsers_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAllBots",
|
||||
Handler: _UserManager_GetAllBots_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateBot",
|
||||
Handler: _UserManager_CreateBot_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateAccessRequest",
|
||||
Handler: _UserManager_CreateAccessRequest_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GrantAccess",
|
||||
Handler: _UserManager_GrantAccess_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "BanUser",
|
||||
Handler: _UserManager_BanUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UnBanUser",
|
||||
Handler: _UserManager_UnBanUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAllAccessRequest",
|
||||
Handler: _UserManager_GetAllAccessRequest_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAllBannedUsers",
|
||||
Handler: _UserManager_GetAllBannedUsers_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAccessRequest",
|
||||
Handler: _UserManager_GetAccessRequest_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBannedBot",
|
||||
Handler: _UserManager_GetBannedBot_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "tgbuser/tgbuser.proto",
|
||||
}
|
||||
152
proto/tgbuser/tgbuser.proto
Normal file
152
proto/tgbuser/tgbuser.proto
Normal file
@ -0,0 +1,152 @@
|
||||
syntax = "proto3";
|
||||
option go_package="github.com/maximotejeda/msvc-proto/golang/tgbuser";
|
||||
|
||||
message User {
|
||||
int64 id = 1;
|
||||
int64 tgb_id = 2;
|
||||
string username = 3;
|
||||
string first_name = 4;
|
||||
string last_name = 5;
|
||||
string tg_bot = 6;
|
||||
int64 created = 7;
|
||||
int64 edited = 8;
|
||||
int64 deleted = 9;
|
||||
}
|
||||
message Bot {
|
||||
int64 id = 1;
|
||||
string bot_name = 2;
|
||||
int64 created = 3;
|
||||
}
|
||||
message Ban {
|
||||
int64 tgb_id = 1;
|
||||
string bot_name = 2;
|
||||
int64 until = 3;
|
||||
int64 created = 4;
|
||||
}
|
||||
message AccessRq {
|
||||
int64 tgb_id = 1;
|
||||
string bot_name = 2;
|
||||
int64 created = 3;
|
||||
}
|
||||
message GetTGBUserRequest {
|
||||
int64 tgb_id = 1;
|
||||
}
|
||||
message GetTGBUserResponse {
|
||||
User user = 1;
|
||||
}
|
||||
message CreateTGBUserRequest {
|
||||
User user = 1;
|
||||
}
|
||||
message CreateTGBUserResponse {
|
||||
int64 id = 1;
|
||||
}
|
||||
message EditTGBUserRequest {
|
||||
User user = 1;
|
||||
}
|
||||
message EditTGBUserResponse {
|
||||
bool response = 1;
|
||||
}
|
||||
message DeleteTGBUserRequest {
|
||||
int64 tgb_id = 1 ;
|
||||
}
|
||||
message DeleteTGBUserResponse {
|
||||
bool response = 1;
|
||||
}
|
||||
message AddBotTGBUserRequest{
|
||||
int64 tgb_id = 1;
|
||||
string bot_name = 2;
|
||||
}
|
||||
|
||||
message AddBotTGBUserResponse {
|
||||
bool response = 1;
|
||||
}
|
||||
message DeleteBotTGBUserRequest{
|
||||
int64 tgb_id = 1;
|
||||
string bot_name = 2;
|
||||
}
|
||||
message DeleteBotTGBUserResponse {
|
||||
bool response = 1;
|
||||
}
|
||||
message GetBotsTGBUserRequest {
|
||||
int64 tgb_id = 1;
|
||||
}
|
||||
message GetBotsTGBUserResponse {
|
||||
repeated Bot bots = 1;
|
||||
}
|
||||
|
||||
message GetAllBotsUsersRequest{
|
||||
string bot_name = 1;
|
||||
}
|
||||
message GetAllBotsUsersResponse{
|
||||
repeated User users = 1;
|
||||
}
|
||||
|
||||
message GetAllBotsRequest{}
|
||||
message GetAllBotsResponse{
|
||||
repeated Bot bots = 1;
|
||||
}
|
||||
|
||||
message TGBGenericResponse{
|
||||
bool response = 1;
|
||||
}
|
||||
message TGBUserRequest{
|
||||
int64 tgb_id = 1;
|
||||
}
|
||||
message TGBBotNameRequest {
|
||||
string bot_name = 1;
|
||||
}
|
||||
message TGBUserBotNameRequest {
|
||||
int64 tgb_id = 1;
|
||||
string bot_name =2;
|
||||
}
|
||||
message TGBBanUserRequest{
|
||||
int64 tgb_id = 1;
|
||||
string bot_name = 2;
|
||||
int64 until = 3;
|
||||
}
|
||||
message GetAccessResponse{
|
||||
repeated AccessRq access = 1;
|
||||
}
|
||||
message GetBanResponse {
|
||||
repeated Ban bans = 1;
|
||||
}
|
||||
|
||||
|
||||
service UserManager {
|
||||
rpc Create(CreateTGBUserRequest)
|
||||
returns (CreateTGBUserResponse){}
|
||||
rpc Get(GetTGBUserRequest)
|
||||
returns (GetTGBUserResponse){}
|
||||
rpc Edit(EditTGBUserRequest)
|
||||
returns (EditTGBUserResponse){}
|
||||
rpc Delete(DeleteTGBUserRequest)
|
||||
returns (DeleteTGBUserResponse){}
|
||||
rpc AddBot(AddBotTGBUserRequest)
|
||||
returns (AddBotTGBUserResponse){}
|
||||
rpc DeleteBot(DeleteBotTGBUserRequest)
|
||||
returns (DeleteBotTGBUserResponse){}
|
||||
rpc GetBots(GetBotsTGBUserRequest)
|
||||
returns (GetBotsTGBUserResponse){}
|
||||
rpc GetAllBotsUsers(GetAllBotsUsersRequest)
|
||||
returns(GetAllBotsUsersResponse){}
|
||||
rpc GetAllBots(GetAllBotsRequest)
|
||||
returns(GetAllBotsResponse){}
|
||||
rpc CreateBot(TGBBotNameRequest)
|
||||
returns (TGBGenericResponse){}
|
||||
rpc CreateAccessRequest(TGBUserBotNameRequest)
|
||||
returns (TGBGenericResponse){}
|
||||
rpc GrantAccess(TGBUserBotNameRequest)
|
||||
returns (TGBGenericResponse){}
|
||||
rpc BanUser(TGBBanUserRequest)
|
||||
returns (TGBGenericResponse){}
|
||||
rpc UnBanUser(TGBUserBotNameRequest)
|
||||
returns (TGBGenericResponse){}
|
||||
rpc GetAllAccessRequest(TGBBotNameRequest)
|
||||
returns (GetAccessResponse){}
|
||||
rpc GetAllBannedUsers(TGBBotNameRequest)
|
||||
returns (GetBanResponse){}
|
||||
rpc GetAccessRequest(TGBUserRequest)
|
||||
returns (GetAccessResponse){}
|
||||
rpc GetBannedBot(TGBUserRequest)
|
||||
returns (GetBanResponse){}
|
||||
}
|
||||
BIN
tgbdb/data.db
Normal file
BIN
tgbdb/data.db
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user