added subscription details route
This commit is contained in:
parent
8d99ec9155
commit
4ab7854ba2
@ -1,6 +1,6 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.13.0
|
// sqlc v1.16.0
|
||||||
|
|
||||||
package database
|
package database
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.13.0
|
// sqlc v1.16.0
|
||||||
|
|
||||||
package database
|
package database
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.13.0
|
// sqlc v1.16.0
|
||||||
// source: query.sql
|
// source: query.sql
|
||||||
|
|
||||||
package database
|
package database
|
||||||
|
84
docs/docs.go
84
docs/docs.go
@ -97,7 +97,6 @@ const docTemplate = `{
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -111,7 +110,6 @@ const docTemplate = `{
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -138,7 +136,6 @@ const docTemplate = `{
|
|||||||
"/discord/webhooks/new": {
|
"/discord/webhooks/new": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -175,7 +172,6 @@ const docTemplate = `{
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -193,7 +189,6 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -211,7 +206,6 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"patch": {
|
"patch": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -231,7 +225,6 @@ const docTemplate = `{
|
|||||||
"/discord/webhooks/{id}/disable": {
|
"/discord/webhooks/{id}/disable": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -251,7 +244,6 @@ const docTemplate = `{
|
|||||||
"/discord/webhooks/{id}/enable": {
|
"/discord/webhooks/{id}/enable": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -711,6 +703,25 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/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/routes.ListSubscriptionDetails"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/subscriptions/discord/webhook/delete": {
|
"/subscriptions/discord/webhook/delete": {
|
||||||
"delete": {
|
"delete": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@ -720,8 +731,8 @@ const docTemplate = `{
|
|||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Id",
|
"description": "id",
|
||||||
"name": "Id",
|
"name": "id",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"required": true
|
"required": true
|
||||||
}
|
}
|
||||||
@ -729,7 +740,7 @@ const docTemplate = `{
|
|||||||
"responses": {}
|
"responses": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/subscriptions/new/discord/webhook": {
|
"/subscriptions/discord/webhook/new": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Subscription"
|
"Subscription"
|
||||||
@ -767,6 +778,26 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"models.DiscordWebHooksDto": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"ID": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"channel": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"enabled": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"server": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"models.SourceDto": {
|
"models.SourceDto": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -805,6 +836,20 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"models.SubscriptionDetails": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"discordwebhook": {
|
||||||
|
"$ref": "#/definitions/models.DiscordWebHooksDto"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"$ref": "#/definitions/models.SourceDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"models.SubscriptionDto": {
|
"models.SubscriptionDto": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -878,6 +923,23 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"routes.ListSubscriptionDetails": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"payload": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/models.SubscriptionDetails"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"routes.ListSubscriptionResults": {
|
"routes.ListSubscriptionResults": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -88,7 +88,6 @@
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -102,7 +101,6 @@
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -129,7 +127,6 @@
|
|||||||
"/discord/webhooks/new": {
|
"/discord/webhooks/new": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -166,7 +163,6 @@
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -184,7 +180,6 @@
|
|||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -202,7 +197,6 @@
|
|||||||
},
|
},
|
||||||
"patch": {
|
"patch": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -222,7 +216,6 @@
|
|||||||
"/discord/webhooks/{id}/disable": {
|
"/discord/webhooks/{id}/disable": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -242,7 +235,6 @@
|
|||||||
"/discord/webhooks/{id}/enable": {
|
"/discord/webhooks/{id}/enable": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Config",
|
|
||||||
"Discord",
|
"Discord",
|
||||||
"Webhook"
|
"Webhook"
|
||||||
],
|
],
|
||||||
@ -702,6 +694,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/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/routes.ListSubscriptionDetails"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/subscriptions/discord/webhook/delete": {
|
"/subscriptions/discord/webhook/delete": {
|
||||||
"delete": {
|
"delete": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@ -711,8 +722,8 @@
|
|||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Id",
|
"description": "id",
|
||||||
"name": "Id",
|
"name": "id",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"required": true
|
"required": true
|
||||||
}
|
}
|
||||||
@ -720,7 +731,7 @@
|
|||||||
"responses": {}
|
"responses": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/subscriptions/new/discord/webhook": {
|
"/subscriptions/discord/webhook/new": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Subscription"
|
"Subscription"
|
||||||
@ -758,6 +769,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"models.DiscordWebHooksDto": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"ID": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"channel": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"enabled": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"server": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"models.SourceDto": {
|
"models.SourceDto": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -796,6 +827,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"models.SubscriptionDetails": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"discordwebhook": {
|
||||||
|
"$ref": "#/definitions/models.DiscordWebHooksDto"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"$ref": "#/definitions/models.SourceDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"models.SubscriptionDto": {
|
"models.SubscriptionDto": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -869,6 +914,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"routes.ListSubscriptionDetails": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"payload": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/models.SubscriptionDetails"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"routes.ListSubscriptionResults": {
|
"routes.ListSubscriptionResults": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -7,6 +7,19 @@ definitions:
|
|||||||
id:
|
id:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
models.DiscordWebHooksDto:
|
||||||
|
properties:
|
||||||
|
ID:
|
||||||
|
type: string
|
||||||
|
channel:
|
||||||
|
type: string
|
||||||
|
enabled:
|
||||||
|
type: boolean
|
||||||
|
server:
|
||||||
|
type: string
|
||||||
|
url:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
models.SourceDto:
|
models.SourceDto:
|
||||||
properties:
|
properties:
|
||||||
deleted:
|
deleted:
|
||||||
@ -32,6 +45,15 @@ definitions:
|
|||||||
value:
|
value:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
models.SubscriptionDetails:
|
||||||
|
properties:
|
||||||
|
discordwebhook:
|
||||||
|
$ref: '#/definitions/models.DiscordWebHooksDto'
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
source:
|
||||||
|
$ref: '#/definitions/models.SourceDto'
|
||||||
|
type: object
|
||||||
models.SubscriptionDto:
|
models.SubscriptionDto:
|
||||||
properties:
|
properties:
|
||||||
discordwebhookid:
|
discordwebhookid:
|
||||||
@ -79,6 +101,17 @@ definitions:
|
|||||||
status:
|
status:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
|
routes.ListSubscriptionDetails:
|
||||||
|
properties:
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
payload:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/models.SubscriptionDetails'
|
||||||
|
type: array
|
||||||
|
status:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
routes.ListSubscriptionResults:
|
routes.ListSubscriptionResults:
|
||||||
properties:
|
properties:
|
||||||
message:
|
message:
|
||||||
@ -154,7 +187,6 @@ paths:
|
|||||||
responses: {}
|
responses: {}
|
||||||
summary: Returns the top 100 entries from the queue to be processed.
|
summary: Returns the top 100 entries from the queue to be processed.
|
||||||
tags:
|
tags:
|
||||||
- Config
|
|
||||||
- Discord
|
- Discord
|
||||||
- Webhook
|
- Webhook
|
||||||
/discord/webhooks/{id}:
|
/discord/webhooks/{id}:
|
||||||
@ -168,7 +200,6 @@ paths:
|
|||||||
responses: {}
|
responses: {}
|
||||||
summary: Deletes a record by ID.
|
summary: Deletes a record by ID.
|
||||||
tags:
|
tags:
|
||||||
- Config
|
|
||||||
- Discord
|
- Discord
|
||||||
- Webhook
|
- Webhook
|
||||||
get:
|
get:
|
||||||
@ -183,7 +214,6 @@ paths:
|
|||||||
responses: {}
|
responses: {}
|
||||||
summary: Returns the top 100 entries from the queue to be processed.
|
summary: Returns the top 100 entries from the queue to be processed.
|
||||||
tags:
|
tags:
|
||||||
- Config
|
|
||||||
- Discord
|
- Discord
|
||||||
- Webhook
|
- Webhook
|
||||||
patch:
|
patch:
|
||||||
@ -196,7 +226,6 @@ paths:
|
|||||||
responses: {}
|
responses: {}
|
||||||
summary: Updates a valid discord webhook ID based on the body given.
|
summary: Updates a valid discord webhook ID based on the body given.
|
||||||
tags:
|
tags:
|
||||||
- Config
|
|
||||||
- Discord
|
- Discord
|
||||||
- Webhook
|
- Webhook
|
||||||
/discord/webhooks/{id}/disable:
|
/discord/webhooks/{id}/disable:
|
||||||
@ -210,7 +239,6 @@ paths:
|
|||||||
responses: {}
|
responses: {}
|
||||||
summary: Disables a Webhook from being used.
|
summary: Disables a Webhook from being used.
|
||||||
tags:
|
tags:
|
||||||
- Config
|
|
||||||
- Discord
|
- Discord
|
||||||
- Webhook
|
- Webhook
|
||||||
/discord/webhooks/{id}/enable:
|
/discord/webhooks/{id}/enable:
|
||||||
@ -224,7 +252,6 @@ paths:
|
|||||||
responses: {}
|
responses: {}
|
||||||
summary: Enables a source to continue processing.
|
summary: Enables a source to continue processing.
|
||||||
tags:
|
tags:
|
||||||
- Config
|
|
||||||
- Discord
|
- Discord
|
||||||
- Webhook
|
- Webhook
|
||||||
/discord/webhooks/by/serverAndChannel:
|
/discord/webhooks/by/serverAndChannel:
|
||||||
@ -245,7 +272,6 @@ paths:
|
|||||||
responses: {}
|
responses: {}
|
||||||
summary: Returns all the known web hooks based on the Server and Channel given.
|
summary: Returns all the known web hooks based on the Server and Channel given.
|
||||||
tags:
|
tags:
|
||||||
- Config
|
|
||||||
- Discord
|
- Discord
|
||||||
- Webhook
|
- Webhook
|
||||||
/discord/webhooks/new:
|
/discord/webhooks/new:
|
||||||
@ -269,7 +295,6 @@ paths:
|
|||||||
responses: {}
|
responses: {}
|
||||||
summary: Creates a new record for a discord web hook to post data to.
|
summary: Creates a new record for a discord web hook to post data to.
|
||||||
tags:
|
tags:
|
||||||
- Config
|
|
||||||
- Discord
|
- Discord
|
||||||
- Webhook
|
- Webhook
|
||||||
/hello/{who}:
|
/hello/{who}:
|
||||||
@ -564,19 +589,31 @@ paths:
|
|||||||
summary: Returns the top 100 entries from the queue to be processed.
|
summary: Returns the top 100 entries from the queue to be processed.
|
||||||
tags:
|
tags:
|
||||||
- Subscription
|
- Subscription
|
||||||
|
/subscriptions/details:
|
||||||
|
get:
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ok
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/routes.ListSubscriptionDetails'
|
||||||
|
summary: Returns the top 50 entries with full deatils on the source and output.
|
||||||
|
tags:
|
||||||
|
- Subscription
|
||||||
/subscriptions/discord/webhook/delete:
|
/subscriptions/discord/webhook/delete:
|
||||||
delete:
|
delete:
|
||||||
parameters:
|
parameters:
|
||||||
- description: Id
|
- description: id
|
||||||
in: query
|
in: query
|
||||||
name: Id
|
name: id
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
responses: {}
|
responses: {}
|
||||||
summary: Removes a Discord WebHook Subscription based on the Subscription ID.
|
summary: Removes a Discord WebHook Subscription based on the Subscription ID.
|
||||||
tags:
|
tags:
|
||||||
- Subscription
|
- Subscription
|
||||||
/subscriptions/new/discord/webhook:
|
/subscriptions/discord/webhook/new:
|
||||||
post:
|
post:
|
||||||
parameters:
|
parameters:
|
||||||
- description: discordWebHookId
|
- description: discordWebHookId
|
||||||
|
@ -8,6 +8,24 @@ import (
|
|||||||
"github.com/jtom38/newsbot/collector/database"
|
"github.com/jtom38/newsbot/collector/database"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type DiscordWebHooksDto struct {
|
||||||
|
ID uuid.UUID `json:"ID"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
Server string `json:"server"`
|
||||||
|
Channel string `json:"channel"`
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConvertToDiscordWebhookDto(i database.Discordwebhook) DiscordWebHooksDto {
|
||||||
|
return DiscordWebHooksDto{
|
||||||
|
ID: i.ID,
|
||||||
|
Url: i.Url,
|
||||||
|
Server: i.Server,
|
||||||
|
Channel: i.Channel,
|
||||||
|
Enabled: i.Enabled,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type SourceDto struct {
|
type SourceDto struct {
|
||||||
ID uuid.UUID `json:"id"`
|
ID uuid.UUID `json:"id"`
|
||||||
Site string `json:"site"`
|
Site string `json:"site"`
|
||||||
@ -68,6 +86,12 @@ func ConvertToSubscriptionDto(i database.Subscription) SubscriptionDto {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SubscriptionDetails struct {
|
||||||
|
ID uuid.UUID `json:"id"`
|
||||||
|
Source SourceDto `json:"source"`
|
||||||
|
DiscordWebHook DiscordWebHooksDto `json:"discordwebhook"`
|
||||||
|
}
|
||||||
|
|
||||||
func splitTags(t string) []string {
|
func splitTags(t string) []string {
|
||||||
items := strings.Split(t, ", ")
|
items := strings.Split(t, ", ")
|
||||||
return items
|
return items
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
// @Tags Articles
|
// @Tags Articles
|
||||||
// @Router /articles [get]
|
// @Router /articles [get]
|
||||||
func (s *Server) listArticles(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) listArticles(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", ApplicationJson)
|
||||||
|
|
||||||
res, err := s.Db.ListArticlesByDate(*s.ctx, 50)
|
res, err := s.Db.ListArticlesByDate(*s.ctx, 50)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
func (s *Server) GetDiscordWebHooks(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) GetDiscordWebHooks(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
|
||||||
res, err := s.Db.ListDiscordWebhooks(*s.ctx, 100)
|
res, err := s.Db.ListDiscordWebhooks(*s.ctx, 100)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
|
@ -23,6 +23,12 @@ type Server struct {
|
|||||||
ctx *context.Context
|
ctx *context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
HeaderContentType = "Content-Type"
|
||||||
|
|
||||||
|
ApplicationJson = "application/json"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrIdValueMissing string = "id value is missing"
|
ErrIdValueMissing string = "id value is missing"
|
||||||
ErrValueNotUuid string = "a value given was expected to be a uuid but was not correct."
|
ErrValueNotUuid string = "a value given was expected to be a uuid but was not correct."
|
||||||
|
@ -2,7 +2,6 @@ package routes
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
@ -16,29 +15,28 @@ import (
|
|||||||
// @Tags Settings
|
// @Tags Settings
|
||||||
// @Router /settings/{key} [get]
|
// @Router /settings/{key} [get]
|
||||||
func (s *Server) getSettings(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) getSettings(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
//var item model.Sources
|
//var item model.Sources
|
||||||
id := chi.URLParam(r, "ID")
|
id := chi.URLParam(r, "ID")
|
||||||
|
|
||||||
uuid, err := uuid.Parse(id)
|
uuid, err := uuid.Parse(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
s.WriteError(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := s.Db.GetSourceByID(*s.ctx, uuid)
|
res, err := s.Db.GetSourceByID(*s.ctx, uuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
s.WriteError(w, err.Error(), http.StatusNotFound)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//itemId := fmt.Sprint(item.ID)
|
|
||||||
//if id != itemId {
|
|
||||||
// log.Panicln("Unable to find the requested record. Either unable to access SQL or the record does not exist.")
|
|
||||||
//}
|
|
||||||
|
|
||||||
bResult, err := json.Marshal(res)
|
bResult, err := json.Marshal(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicln(err)
|
s.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
w.Write(bResult)
|
w.Write(bResult)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ func (s *Server) GetSubscriptionsRouter() http.Handler {
|
|||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
|
|
||||||
r.Get("/", s.ListSubscriptions)
|
r.Get("/", s.ListSubscriptions)
|
||||||
|
r.Get("/details", s.ListSubscriptionDetails)
|
||||||
r.Get("/by/discordId", s.GetSubscriptionsByDiscordId)
|
r.Get("/by/discordId", s.GetSubscriptionsByDiscordId)
|
||||||
r.Get("/by/sourceId", s.GetSubscriptionsBySourceId)
|
r.Get("/by/sourceId", s.GetSubscriptionsBySourceId)
|
||||||
r.Post("/discord/webhook/new", s.newDiscordWebHookSubscription)
|
r.Post("/discord/webhook/new", s.newDiscordWebHookSubscription)
|
||||||
@ -25,7 +26,7 @@ func (s *Server) GetSubscriptionsRouter() http.Handler {
|
|||||||
|
|
||||||
type ListSubscriptionResults struct {
|
type ListSubscriptionResults struct {
|
||||||
ApiStatusModel
|
ApiStatusModel
|
||||||
Payload []models.SubscriptionDto `json:"payload"`
|
Payload []models.SubscriptionDto `json:"payload"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSubscriptions
|
// GetSubscriptions
|
||||||
@ -46,7 +47,7 @@ func (s *Server) ListSubscriptions(w http.ResponseWriter, r *http.Request) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := s.Db.ListSubscriptions(*s.ctx, 100)
|
res, err := s.Db.ListSubscriptions(*s.ctx, 50)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.WriteError(w, err.Error(), http.StatusBadRequest)
|
s.WriteError(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
@ -65,9 +66,63 @@ func (s *Server) ListSubscriptions(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Write(bres)
|
w.Write(bres)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ListSubscriptionDetails struct {
|
||||||
|
ApiStatusModel
|
||||||
|
Payload []models.SubscriptionDetails `json:"payload"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSubscriptionDetails
|
||||||
|
// @Summary Returns the top 50 entries with full deatils on the source and output.
|
||||||
|
// @Produce application/json
|
||||||
|
// @Tags Subscription
|
||||||
|
// @Router /subscriptions/details [get]
|
||||||
|
// @Success 200 {object} ListSubscriptionDetails "ok"
|
||||||
|
func (s Server) ListSubscriptionDetails(w http.ResponseWriter, t *http.Request) {
|
||||||
|
w.Header().Set(HeaderContentType, ApplicationJson)
|
||||||
|
payload := ListSubscriptionDetails{
|
||||||
|
ApiStatusModel: ApiStatusModel{
|
||||||
|
StatusCode: http.StatusOK,
|
||||||
|
Message: "OK",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := s.Db.ListSubscriptions(t.Context(), 50)
|
||||||
|
if err != nil {
|
||||||
|
s.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, item := range res {
|
||||||
|
dwh, err := s.Db.GetDiscordWebHooksByID(t.Context(), item.Discordwebhookid)
|
||||||
|
if err != nil {
|
||||||
|
s.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
source, err := s.Db.GetSourceByID(t.Context(), item.Sourceid)
|
||||||
|
if err != nil {
|
||||||
|
s.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
payload.Payload = append(payload.Payload, models.SubscriptionDetails{
|
||||||
|
ID: item.ID,
|
||||||
|
DiscordWebHook: models.ConvertToDiscordWebhookDto(dwh),
|
||||||
|
Source: models.ConvertToSourceDto(source),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := json.Marshal(payload)
|
||||||
|
if err != nil {
|
||||||
|
s.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write(b)
|
||||||
|
}
|
||||||
|
|
||||||
type GetSubscriptionResults struct {
|
type GetSubscriptionResults struct {
|
||||||
ApiStatusModel
|
ApiStatusModel
|
||||||
Payload models.SubscriptionDto `json:"payload"`
|
Payload models.SubscriptionDto `json:"payload"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSubscriptionsByDiscordId
|
// GetSubscriptionsByDiscordId
|
||||||
@ -82,10 +137,10 @@ type GetSubscriptionResults struct {
|
|||||||
func (s *Server) GetSubscriptionsByDiscordId(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) GetSubscriptionsByDiscordId(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
p := ListSubscriptionResults {
|
p := ListSubscriptionResults{
|
||||||
ApiStatusModel: ApiStatusModel{
|
ApiStatusModel: ApiStatusModel{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Message: "OK",
|
Message: "OK",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,10 +186,10 @@ func (s *Server) GetSubscriptionsByDiscordId(w http.ResponseWriter, r *http.Requ
|
|||||||
func (s *Server) GetSubscriptionsBySourceId(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) GetSubscriptionsBySourceId(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
p := ListSubscriptionResults {
|
p := ListSubscriptionResults{
|
||||||
ApiStatusModel: ApiStatusModel{
|
ApiStatusModel: ApiStatusModel{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Message: "OK",
|
Message: "OK",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +230,7 @@ func (s *Server) GetSubscriptionsBySourceId(w http.ResponseWriter, r *http.Reque
|
|||||||
// @Param discordWebHookId query string true "discordWebHookId"
|
// @Param discordWebHookId query string true "discordWebHookId"
|
||||||
// @Param sourceId query string true "sourceId"
|
// @Param sourceId query string true "sourceId"
|
||||||
// @Tags Subscription
|
// @Tags Subscription
|
||||||
// @Router /subscriptions/new/discord/webhook [post]
|
// @Router /subscriptions/discord/webhook/new [post]
|
||||||
func (s *Server) newDiscordWebHookSubscription(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) newDiscordWebHookSubscription(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
@ -239,20 +294,20 @@ func (s *Server) newDiscordWebHookSubscription(w http.ResponseWriter, r *http.Re
|
|||||||
|
|
||||||
// DeleteDiscordWebHookSubscription
|
// DeleteDiscordWebHookSubscription
|
||||||
// @Summary Removes a Discord WebHook Subscription based on the Subscription ID.
|
// @Summary Removes a Discord WebHook Subscription based on the Subscription ID.
|
||||||
// @Param Id query string true "Id"
|
// @Param id query string true "id"
|
||||||
// @Tags Subscription
|
// @Tags Subscription
|
||||||
// @Router /subscriptions/discord/webhook/delete [delete]
|
// @Router /subscriptions/discord/webhook/delete [delete]
|
||||||
func (s *Server) DeleteDiscordWebHookSubscription(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) DeleteDiscordWebHookSubscription(w http.ResponseWriter, r *http.Request) {
|
||||||
var ErrMissingSubscriptionID string = "the request was missing a 'Id'"
|
var ErrMissingSubscriptionID string = "the request was missing a 'Id'"
|
||||||
query := r.URL.Query()
|
query := r.URL.Query()
|
||||||
|
|
||||||
id := query["Id"][0]
|
id := query["id"][0]
|
||||||
if id == "" {
|
if id == "" {
|
||||||
s.WriteError(w, ErrMissingSubscriptionID, http.StatusBadRequest)
|
s.WriteError(w, ErrMissingSubscriptionID, http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
uid, err := uuid.Parse(query["Id"][0])
|
uid, err := uuid.Parse(query["id"][0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.WriteError(w, err.Error(), http.StatusBadRequest)
|
s.WriteError(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user