cleaned up the old dto and starting to add the internal queue system
This commit is contained in:
parent
43a086cc02
commit
fbed111fbb
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,7 +2,6 @@
|
||||
dev.session.sql
|
||||
__debug_bin
|
||||
server
|
||||
.vscode
|
||||
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
@ -11,6 +10,7 @@ server
|
||||
*.so
|
||||
*.dylib
|
||||
collector
|
||||
*.db
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
@ -10,8 +10,7 @@ import (
|
||||
"github.com/pressly/goose/v3"
|
||||
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/docs"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/database"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/handler/v1"
|
||||
v1 "git.jamestombleson.com/jtom38/newsbot-api/internal/handler/v1"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/services"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/services/cron"
|
||||
)
|
||||
@ -42,12 +41,15 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
queries := database.New(db)
|
||||
//queues := services.NewQueues(db)
|
||||
//queues.RssIndex.Send(ctx, goqite.Message{
|
||||
// Body: []byte("hello world"),
|
||||
//})
|
||||
|
||||
c := cron.NewScheduler(ctx)
|
||||
c := cron.NewScheduler(ctx, db)
|
||||
c.Start()
|
||||
|
||||
server := v1.NewServer(ctx, queries, configs, db)
|
||||
server := v1.NewServer(ctx, configs, db)
|
||||
|
||||
fmt.Println("API is online and waiting for requests.")
|
||||
fmt.Printf("API: http://%v:8081/api\r\n", configs.ServerAddress)
|
||||
|
386
docs/docs.go
386
docs/docs.go
@ -449,25 +449,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/queue/discord/webhooks": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Queue"
|
||||
],
|
||||
"summary": "Returns the top 100 entries from the queue to be processed.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListDiscordWebHooksQueueResults"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/{key}": {
|
||||
"get": {
|
||||
"produces": [
|
||||
@ -875,167 +856,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Returns the top 100 entries from the queue to be processed.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListSubscriptions"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Unable to reach SQL.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ApiError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to process data from SQL.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ApiError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions/by/SourceId": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Returns the top 100 entries from the queue to be processed.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListSubscriptions"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions/by/discordId": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Returns the top 100 entries from the queue to be processed.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListSubscriptions"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Unable to reach SQL or Data problems",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ApiError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Data problems",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ApiError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions/details": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Returns the top 50 entries with full deatils on the source and output.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListSubscriptionDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions/discord/webhook/delete": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Removes a Discord WebHook Subscription based on the Subscription ID.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/subscriptions/discord/webhook/new": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Creates a new subscription to link a post from a Source to a DiscordWebHook.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "discordWebHookId",
|
||||
"name": "discordWebHookId",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "sourceId",
|
||||
"name": "sourceId",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
@ -1192,212 +1012,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.ArticleDetailsDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"authorImage": {
|
||||
"type": "string"
|
||||
},
|
||||
"authorName": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"pubdate": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/models.SourceDto"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"thumbnail": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"video": {
|
||||
"type": "string"
|
||||
},
|
||||
"videoHeight": {
|
||||
"type": "integer"
|
||||
},
|
||||
"videoWidth": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.DiscordQueueDetailsDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"article": {
|
||||
"$ref": "#/definitions/models.ArticleDetailsDto"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.DiscordWebHooksDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ID": {
|
||||
"type": "string"
|
||||
},
|
||||
"channel": {
|
||||
"type": "string"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"server": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.SourceDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"deleted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"site": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"type": "string"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.SubscriptionDetailsDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"discordwebhook": {
|
||||
"$ref": "#/definitions/models.DiscordWebHooksDto"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/models.SourceDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.SubscriptionDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"discordwebhookid": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"sourceid": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ApiError": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ListDiscordWebHooksQueueResults": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"payload": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.DiscordQueueDetailsDto"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ListSubscriptionDetails": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"payload": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.SubscriptionDetailsDto"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ListSubscriptions": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"payload": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.SubscriptionDto"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
@ -440,25 +440,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/queue/discord/webhooks": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Queue"
|
||||
],
|
||||
"summary": "Returns the top 100 entries from the queue to be processed.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListDiscordWebHooksQueueResults"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/{key}": {
|
||||
"get": {
|
||||
"produces": [
|
||||
@ -866,167 +847,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Returns the top 100 entries from the queue to be processed.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListSubscriptions"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Unable to reach SQL.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ApiError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to process data from SQL.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ApiError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions/by/SourceId": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Returns the top 100 entries from the queue to be processed.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListSubscriptions"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions/by/discordId": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Returns the top 100 entries from the queue to be processed.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListSubscriptions"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Unable to reach SQL or Data problems",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ApiError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Data problems",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ApiError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions/details": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Returns the top 50 entries with full deatils on the source and output.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ListSubscriptionDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/subscriptions/discord/webhook/delete": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Removes a Discord WebHook Subscription based on the Subscription ID.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "id",
|
||||
"name": "id",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/subscriptions/discord/webhook/new": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Subscription"
|
||||
],
|
||||
"summary": "Creates a new subscription to link a post from a Source to a DiscordWebHook.",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "discordWebHookId",
|
||||
"name": "discordWebHookId",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "sourceId",
|
||||
"name": "sourceId",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
@ -1183,212 +1003,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.ArticleDetailsDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"authorImage": {
|
||||
"type": "string"
|
||||
},
|
||||
"authorName": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"pubdate": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/models.SourceDto"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"thumbnail": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"video": {
|
||||
"type": "string"
|
||||
},
|
||||
"videoHeight": {
|
||||
"type": "integer"
|
||||
},
|
||||
"videoWidth": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.DiscordQueueDetailsDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"article": {
|
||||
"$ref": "#/definitions/models.ArticleDetailsDto"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.DiscordWebHooksDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ID": {
|
||||
"type": "string"
|
||||
},
|
||||
"channel": {
|
||||
"type": "string"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"server": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.SourceDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"deleted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"site": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"type": "string"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.SubscriptionDetailsDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"discordwebhook": {
|
||||
"$ref": "#/definitions/models.DiscordWebHooksDto"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/models.SourceDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.SubscriptionDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"discordwebhookid": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"sourceid": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ApiError": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ListDiscordWebHooksQueueResults": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"payload": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.DiscordQueueDetailsDto"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ListSubscriptionDetails": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"payload": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.SubscriptionDetailsDto"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ListSubscriptions": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"payload": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/models.SubscriptionDto"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -102,140 +102,6 @@ definitions:
|
||||
$ref: '#/definitions/domain.SourceDto'
|
||||
type: array
|
||||
type: object
|
||||
models.ArticleDetailsDto:
|
||||
properties:
|
||||
authorImage:
|
||||
type: string
|
||||
authorName:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
pubdate:
|
||||
type: string
|
||||
source:
|
||||
$ref: '#/definitions/models.SourceDto'
|
||||
tags:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
thumbnail:
|
||||
type: string
|
||||
title:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
video:
|
||||
type: string
|
||||
videoHeight:
|
||||
type: integer
|
||||
videoWidth:
|
||||
type: integer
|
||||
type: object
|
||||
models.DiscordQueueDetailsDto:
|
||||
properties:
|
||||
article:
|
||||
$ref: '#/definitions/models.ArticleDetailsDto'
|
||||
id:
|
||||
type: string
|
||||
type: object
|
||||
models.DiscordWebHooksDto:
|
||||
properties:
|
||||
ID:
|
||||
type: string
|
||||
channel:
|
||||
type: string
|
||||
enabled:
|
||||
type: boolean
|
||||
server:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
type: object
|
||||
models.SourceDto:
|
||||
properties:
|
||||
deleted:
|
||||
type: boolean
|
||||
enabled:
|
||||
type: boolean
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
site:
|
||||
type: string
|
||||
source:
|
||||
type: string
|
||||
tags:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
value:
|
||||
type: string
|
||||
type: object
|
||||
models.SubscriptionDetailsDto:
|
||||
properties:
|
||||
discordwebhook:
|
||||
$ref: '#/definitions/models.DiscordWebHooksDto'
|
||||
id:
|
||||
type: string
|
||||
source:
|
||||
$ref: '#/definitions/models.SourceDto'
|
||||
type: object
|
||||
models.SubscriptionDto:
|
||||
properties:
|
||||
discordwebhookid:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
sourceid:
|
||||
type: string
|
||||
type: object
|
||||
v1.ApiError:
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
status:
|
||||
type: integer
|
||||
type: object
|
||||
v1.ListDiscordWebHooksQueueResults:
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
payload:
|
||||
items:
|
||||
$ref: '#/definitions/models.DiscordQueueDetailsDto'
|
||||
type: array
|
||||
status:
|
||||
type: integer
|
||||
type: object
|
||||
v1.ListSubscriptionDetails:
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
payload:
|
||||
items:
|
||||
$ref: '#/definitions/models.SubscriptionDetailsDto'
|
||||
type: array
|
||||
status:
|
||||
type: integer
|
||||
type: object
|
||||
v1.ListSubscriptions:
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
payload:
|
||||
items:
|
||||
$ref: '#/definitions/models.SubscriptionDto'
|
||||
type: array
|
||||
status:
|
||||
type: integer
|
||||
type: object
|
||||
info:
|
||||
contact: {}
|
||||
title: NewsBot collector
|
||||
@ -527,18 +393,6 @@ paths:
|
||||
tags:
|
||||
- Discord
|
||||
- Webhook
|
||||
/queue/discord/webhooks:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ListDiscordWebHooksQueueResults'
|
||||
summary: Returns the top 100 entries from the queue to be processed.
|
||||
tags:
|
||||
- Queue
|
||||
/settings/{key}:
|
||||
get:
|
||||
parameters:
|
||||
@ -807,109 +661,4 @@ paths:
|
||||
summary: Creates a new youtube source to monitor.
|
||||
tags:
|
||||
- Source
|
||||
/subscriptions:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ListSubscriptions'
|
||||
"400":
|
||||
description: Unable to reach SQL.
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ApiError'
|
||||
"500":
|
||||
description: Failed to process data from SQL.
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ApiError'
|
||||
summary: Returns the top 100 entries from the queue to be processed.
|
||||
tags:
|
||||
- Subscription
|
||||
/subscriptions/by/SourceId:
|
||||
get:
|
||||
parameters:
|
||||
- description: id
|
||||
in: query
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ListSubscriptions'
|
||||
summary: Returns the top 100 entries from the queue to be processed.
|
||||
tags:
|
||||
- Subscription
|
||||
/subscriptions/by/discordId:
|
||||
get:
|
||||
parameters:
|
||||
- description: id
|
||||
in: query
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ListSubscriptions'
|
||||
"400":
|
||||
description: Unable to reach SQL or Data problems
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ApiError'
|
||||
"500":
|
||||
description: Data problems
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ApiError'
|
||||
summary: Returns the top 100 entries from the queue to be processed.
|
||||
tags:
|
||||
- Subscription
|
||||
/subscriptions/details:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ListSubscriptionDetails'
|
||||
summary: Returns the top 50 entries with full deatils on the source and output.
|
||||
tags:
|
||||
- Subscription
|
||||
/subscriptions/discord/webhook/delete:
|
||||
delete:
|
||||
parameters:
|
||||
- description: id
|
||||
in: query
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
responses: {}
|
||||
summary: Removes a Discord WebHook Subscription based on the Subscription ID.
|
||||
tags:
|
||||
- Subscription
|
||||
/subscriptions/discord/webhook/new:
|
||||
post:
|
||||
parameters:
|
||||
- description: discordWebHookId
|
||||
in: query
|
||||
name: discordWebHookId
|
||||
required: true
|
||||
type: string
|
||||
- description: sourceId
|
||||
in: query
|
||||
name: sourceId
|
||||
required: true
|
||||
type: string
|
||||
responses: {}
|
||||
summary: Creates a new subscription to link a post from a Source to a DiscordWebHook.
|
||||
tags:
|
||||
- Subscription
|
||||
swagger: "2.0"
|
||||
|
9
internal/domain/events.go
Normal file
9
internal/domain/events.go
Normal file
@ -0,0 +1,9 @@
|
||||
package domain
|
||||
|
||||
const (
|
||||
QueueRssCollection = "RssCollection"
|
||||
)
|
||||
|
||||
type RssCollectionEvent struct {
|
||||
|
||||
}
|
@ -11,13 +11,12 @@ import (
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/database"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/services"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/services/dto"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
Router *echo.Echo
|
||||
Db *database.Queries
|
||||
dto *dto.DtoClient
|
||||
//dto *dto.DtoClient
|
||||
config services.Configs
|
||||
repo services.RepositoryService
|
||||
}
|
||||
@ -39,10 +38,10 @@ var (
|
||||
ErrUnableToConvertToJson string = "Unable to convert to json"
|
||||
)
|
||||
|
||||
func NewServer(ctx context.Context, db *database.Queries, configs services.Configs, conn *sql.DB) *Handler {
|
||||
func NewServer(ctx context.Context, configs services.Configs, conn *sql.DB) *Handler {
|
||||
s := &Handler{
|
||||
Db: db,
|
||||
dto: dto.NewDtoClient(db),
|
||||
//Db: db,
|
||||
//dto: dto.NewDtoClient(db),
|
||||
config: configs,
|
||||
repo: services.NewRepositoryService(conn),
|
||||
}
|
||||
@ -85,13 +84,13 @@ func NewServer(ctx context.Context, db *database.Queries, configs services.Confi
|
||||
sources.POST("/:ID/disable", s.disableSource)
|
||||
sources.POST("/:ID/enable", s.enableSource)
|
||||
|
||||
subs := v1.Group("/subscriptions")
|
||||
subs.GET("/", s.ListSubscriptions)
|
||||
subs.GET("/details", s.ListSubscriptionDetails)
|
||||
subs.GET("/by/discordId", s.GetSubscriptionsByDiscordId)
|
||||
subs.GET("/by/sourceId", s.GetSubscriptionsBySourceId)
|
||||
subs.POST("/discord/webhook/new", s.newDiscordWebHookSubscription)
|
||||
subs.DELETE("/discord/webhook/delete", s.DeleteDiscordWebHookSubscription)
|
||||
//subs := v1.Group("/subscriptions")
|
||||
//subs.GET("/", s.ListSubscriptions)
|
||||
//subs.GET("/details", s.ListSubscriptionDetails)
|
||||
//subs.GET("/by/discordId", s.GetSubscriptionsByDiscordId)
|
||||
//subs.GET("/by/sourceId", s.GetSubscriptionsBySourceId)
|
||||
//subs.POST("/discord/webhook/new", s.newDiscordWebHookSubscription)
|
||||
//subs.DELETE("/discord/webhook/delete", s.DeleteDiscordWebHookSubscription)
|
||||
|
||||
return s
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain/models"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type ListDiscordWebHooksQueueResults struct {
|
||||
@ -19,22 +15,22 @@ type ListDiscordWebHooksQueueResults struct {
|
||||
// @Tags Queue
|
||||
// @Router /queue/discord/webhooks [get]
|
||||
// @Success 200 {object} ListDiscordWebHooksQueueResults "ok"
|
||||
func (s *Handler) ListDiscordWebhookQueue(c echo.Context) error {
|
||||
p := ListDiscordWebHooksQueueResults{
|
||||
ApiStatusModel: ApiStatusModel{
|
||||
Message: "OK",
|
||||
StatusCode: http.StatusOK,
|
||||
},
|
||||
}
|
||||
|
||||
// Get the raw resp from sql
|
||||
res, err := s.dto.ListDiscordWebhookQueueDetails(c.Request().Context(), 50)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, domain.BaseResponse{
|
||||
Message: err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
p.Payload = res
|
||||
return c.JSON(http.StatusOK, p)
|
||||
}
|
||||
//func (s *Handler) ListDiscordWebhookQueue(c echo.Context) error {
|
||||
// p := ListDiscordWebHooksQueueResults{
|
||||
// ApiStatusModel: ApiStatusModel{
|
||||
// Message: "OK",
|
||||
// StatusCode: http.StatusOK,
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// // Get the raw resp from sql
|
||||
// res, err := s.dto.ListDiscordWebhookQueueDetails(c.Request().Context(), 50)
|
||||
// if err != nil {
|
||||
// return c.JSON(http.StatusInternalServerError, domain.BaseResponse{
|
||||
// Message: err.Error(),
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// p.Payload = res
|
||||
// return c.JSON(http.StatusOK, p)
|
||||
//}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package v1
|
||||
|
||||
/*
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
@ -228,3 +229,4 @@ func (s *Handler) DeleteDiscordWebHookSubscription(c echo.Context) error {
|
||||
|
||||
return c.JSON(http.StatusOK, nil)
|
||||
}
|
||||
*/
|
34
internal/services/cron/rss.go
Normal file
34
internal/services/cron/rss.go
Normal file
@ -0,0 +1,34 @@
|
||||
package cron
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
||||
)
|
||||
|
||||
func (c *Cron) LoadRssQueue() {
|
||||
sources, err := c.repo.Sources.ListBySource(*c.ctx, 0, 1000, domain.SourceCollectorRss)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
for _, source := range sources {
|
||||
if !source.Enabled {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (c *Cron) ListAllSourceRecords(sourceType string) ([]domain.SourceEntity, error) {
|
||||
var records []domain.SourceEntity
|
||||
|
||||
sources, err := c.repo.Sources.ListBySource(*c.ctx, 0, 1000, sourceType)
|
||||
if err != nil {
|
||||
return records, err
|
||||
}
|
||||
|
||||
return sources, nil
|
||||
}
|
@ -17,6 +17,7 @@ type Cron struct {
|
||||
ctx *context.Context
|
||||
timer *cron.Cron
|
||||
repo services.RepositoryService
|
||||
//queues services
|
||||
}
|
||||
|
||||
func NewScheduler(ctx context.Context, conn *sql.DB) *Cron {
|
||||
|
@ -30,3 +30,5 @@ func (c *Cron) CheckYoutube() {
|
||||
}
|
||||
log.Print("[YouTube] Done!")
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,21 +3,24 @@ package services
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
||||
"github.com/maragudk/goqite"
|
||||
)
|
||||
|
||||
|
||||
|
||||
type queues struct {
|
||||
repos RepositoryService
|
||||
|
||||
RssIndex goqite.Queue
|
||||
RssCollection goqite.Queue
|
||||
}
|
||||
|
||||
func NewQueues(conn *sql.DB) queues {
|
||||
return queues{
|
||||
repos: NewRepositoryService(conn),
|
||||
RssIndex: *goqite.New(goqite.NewOpts{
|
||||
RssCollection: *goqite.New(goqite.NewOpts{
|
||||
DB: conn,
|
||||
Name: "rss",
|
||||
Name: domain.QueueRssCollection,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
4
makefile
4
makefile
@ -4,8 +4,8 @@ help: ## Shows this help command
|
||||
|
||||
build: ## builds the application with the current go runtime
|
||||
~/go/bin/swag f
|
||||
~/go/bin/swag i
|
||||
go build .
|
||||
~/go/bin/swag init -g cmd/server.go
|
||||
go build cmd/server.go
|
||||
|
||||
docker-build: ## Generates the docker image
|
||||
docker build -t "newsbot.collector.api" .
|
||||
|
Loading…
Reference in New Issue
Block a user