Compare commits
2 Commits
e4b979d61c
...
d08fcc0867
Author | SHA1 | Date |
---|---|---|
CJ_Clippy | d08fcc0867 | |
CJ_Clippy | e6179e20e5 |
|
@ -0,0 +1 @@
|
|||
{"last_found_secrets": [{"match": "7630852e9a6a0aecb849c91d14d426ca88187886fdf466189d67145856bdac3e", "name": "Generic Password - charts/postgresql/postgresql/templates/secrets.yaml"}]}
|
|
@ -0,0 +1,5 @@
|
|||
secret:
|
||||
ignored_matches:
|
||||
- match: 7630852e9a6a0aecb849c91d14d426ca88187886fdf466189d67145856bdac3e
|
||||
name: Generic Password - charts/postgresql/postgresql/templates/secrets.yaml
|
||||
version: 2
|
|
@ -1,3 +1,5 @@
|
|||
.venv/
|
||||
|
||||
**/.env*
|
||||
*~
|
||||
packages/**/isolate/
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
repos:
|
||||
- repo: https://github.com/gitguardian/ggshield
|
||||
rev: v1.30.2
|
||||
hooks:
|
||||
- id: ggshield
|
||||
language_version: python3
|
||||
stages: [commit]
|
11
devbox.json
11
devbox.json
|
@ -9,16 +9,21 @@
|
|||
"kubernetes-helm@latest",
|
||||
"k9s@latest",
|
||||
"ffmpeg@latest",
|
||||
"yt-dlp@latest"
|
||||
"yt-dlp@latest",
|
||||
"python310@latest",
|
||||
"python310Packages.pip@latest"
|
||||
],
|
||||
"env": {
|
||||
"DEVBOX_COREPACK_ENABLED": "true",
|
||||
"ENV": "development",
|
||||
"KUBECONFIG": "$HOME/.kube/futureporn.yaml"
|
||||
"KUBECONFIG": "$HOME/.kube/futureporn.yaml",
|
||||
"VENV_DIR": ".venv"
|
||||
},
|
||||
"shell": {
|
||||
"init_hook": [
|
||||
"echo Welcome to Futureporn devbox"
|
||||
"echo Welcome to Futureporn devbox",
|
||||
". $VENV_DIR/bin/activate",
|
||||
"pip install -r requirements.txt"
|
||||
],
|
||||
"scripts": {
|
||||
"test": [
|
||||
|
|
142
devbox.lock
142
devbox.lock
|
@ -490,6 +490,148 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"python310@latest": {
|
||||
"last_modified": "2024-07-07T07:43:47Z",
|
||||
"plugin_version": "0.0.3",
|
||||
"resolved": "github:NixOS/nixpkgs/b60793b86201040d9dee019a05089a9150d08b5b#python310",
|
||||
"source": "devbox-search",
|
||||
"version": "3.10.14",
|
||||
"systems": {
|
||||
"aarch64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/n0gcjj86qjx7w59bwpzqvzdwrjdc7bwy-python3-3.10.14",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/n0gcjj86qjx7w59bwpzqvzdwrjdc7bwy-python3-3.10.14"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/pzpn4j6hh8ayy15cb36s7i8v0mkavy0z-python3-3.10.14",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "debug",
|
||||
"path": "/nix/store/h873y0nbzqlmsda6m2vfdcjw1v6c660f-python3-3.10.14-debug"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/pzpn4j6hh8ayy15cb36s7i8v0mkavy0z-python3-3.10.14"
|
||||
},
|
||||
"x86_64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/3ia1741fyzlcjgp3kg01hlk3z1jlp9x0-python3-3.10.14",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/3ia1741fyzlcjgp3kg01hlk3z1jlp9x0-python3-3.10.14"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/handws5bj8l411asgs68s3bj8f05qnn5-python3-3.10.14",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "debug",
|
||||
"path": "/nix/store/sl3yyz93mar0jk6cnw0lqv4xrvsbas0a-python3-3.10.14-debug"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/handws5bj8l411asgs68s3bj8f05qnn5-python3-3.10.14"
|
||||
}
|
||||
}
|
||||
},
|
||||
"python310Packages.pip@latest": {
|
||||
"last_modified": "2023-12-13T22:54:10Z",
|
||||
"plugin_version": "0.0.2",
|
||||
"resolved": "github:NixOS/nixpkgs/fd04bea4cbf76f86f244b9e2549fca066db8ddff#python310Packages.pip",
|
||||
"source": "devbox-search",
|
||||
"version": "23.2.1",
|
||||
"systems": {
|
||||
"aarch64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/vjyrxbxqsadvr9g6mzig6y406dhwcrqi-python3.10-pip-23.2.1",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "man",
|
||||
"path": "/nix/store/2ra46imgas5srgxx8mgs424akh5j1msv-python3.10-pip-23.2.1-man",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "dist",
|
||||
"path": "/nix/store/xjj6xjh21k08rkyg6hnkbyrygqhqgn8y-python3.10-pip-23.2.1-dist"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/vjyrxbxqsadvr9g6mzig6y406dhwcrqi-python3.10-pip-23.2.1"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/j8pxwv7vyjm8z2fqglijjvabbkmxbv9r-python3.10-pip-23.2.1",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "man",
|
||||
"path": "/nix/store/bcfliw00z123ddyi8hsfxvfn2npdcpdq-python3.10-pip-23.2.1-man",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "dist",
|
||||
"path": "/nix/store/2326b2sr9p2z9bsghd2pzs346g2qjn7f-python3.10-pip-23.2.1-dist"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/j8pxwv7vyjm8z2fqglijjvabbkmxbv9r-python3.10-pip-23.2.1"
|
||||
},
|
||||
"x86_64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/7lyvqf8wl47wzgsqmlcz39ycmwxyg9zx-python3.10-pip-23.2.1",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "man",
|
||||
"path": "/nix/store/0j02s5hbsdhfxvvay5dm9j68nhalm39v-python3.10-pip-23.2.1-man",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "dist",
|
||||
"path": "/nix/store/8dvqh9ai83lqaaixs3bhmf1n4jxgp4v7-python3.10-pip-23.2.1-dist"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/7lyvqf8wl47wzgsqmlcz39ycmwxyg9zx-python3.10-pip-23.2.1"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/gdhvfi5zaqzpa5l3kk0spmv71r549slf-python3.10-pip-23.2.1",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "man",
|
||||
"path": "/nix/store/p37y2fhm6l3nd624jmr2r680wf4p0544-python3.10-pip-23.2.1-man",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "dist",
|
||||
"path": "/nix/store/r4qj7psryk532rkh0srhn25ygv8yk541-python3.10-pip-23.2.1-dist"
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/gdhvfi5zaqzpa5l3kk0spmv71r549slf-python3.10-pip-23.2.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tilt@latest": {
|
||||
"last_modified": "2024-07-15T21:47:20Z",
|
||||
"resolved": "github:NixOS/nixpkgs/b2c1f10bfbb3f617ea8e8669ac13f3f56ceb2ea2#tilt",
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
pre-commit
|
||||
ggshield
|
||||
click
|
|
@ -46,42 +46,6 @@ importers:
|
|||
specifier: ^5.5.3
|
||||
version: 5.5.4
|
||||
|
||||
../..: {}
|
||||
|
||||
../../packages/image: {}
|
||||
|
||||
../../packages/infra: {}
|
||||
|
||||
../../packages/meal: {}
|
||||
|
||||
../../packages/old: {}
|
||||
|
||||
../../packages/scout: {}
|
||||
|
||||
../../packages/storage: {}
|
||||
|
||||
../../packages/taco: {}
|
||||
|
||||
../../packages/types: {}
|
||||
|
||||
../../packages/utils: {}
|
||||
|
||||
../../packages/video: {}
|
||||
|
||||
../../packages/worker: {}
|
||||
|
||||
../capture: {}
|
||||
|
||||
../mailbox: {}
|
||||
|
||||
../migrations: {}
|
||||
|
||||
../next: {}
|
||||
|
||||
../strapi: {}
|
||||
|
||||
../uppy: {}
|
||||
|
||||
packages:
|
||||
|
||||
'@babel/code-frame@7.24.7':
|
||||
|
|
|
@ -51,15 +51,14 @@ createCommand({
|
|||
async execute(interaction: Interaction) {
|
||||
await interaction.defer()
|
||||
|
||||
console.log('interation.data as follows')
|
||||
console.log(interaction.data)
|
||||
// console.log('interation.data as follows')
|
||||
// console.log(interaction.data)
|
||||
const options = interaction.data?.options
|
||||
if (!options) throw new Error(`interaction options was undefined. it's expected to be an array of options.`);
|
||||
const urlOption = options.find((o) => o.name === 'url')
|
||||
if (!urlOption) throw new Error(`url option was missing from interaction data`);
|
||||
const url = ''+urlOption.value
|
||||
if (!url) throw new Error(`url was missing from interaction data options`);
|
||||
// const url = (interaction.data?.options?.find(o => o.name === 'url')?.value) ?? undefined;
|
||||
|
||||
// respond to the interaction and get a message ID which we will then add to the database Record
|
||||
const embeds = new EmbedsBuilder()
|
||||
|
@ -75,8 +74,8 @@ createCommand({
|
|||
const response: InteractionCallbackData = { embeds }
|
||||
const message = await interaction.edit(response)
|
||||
|
||||
console.log('defferred, interaction message is as follows')
|
||||
console.log(message)
|
||||
// console.log('deferred, interaction message is as follows')
|
||||
// console.log(message)
|
||||
if (!message?.id) {
|
||||
const msg = `message.id was empty, ruh roh raggy`
|
||||
console.error(msg)
|
||||
|
@ -85,57 +84,8 @@ createCommand({
|
|||
|
||||
// @todo create record in db
|
||||
const record = await createRecordInDatabase(url, message.id.toString())
|
||||
console.log(record)
|
||||
// console.log(record)
|
||||
|
||||
|
||||
|
||||
// if (!interaction.data?.values) throw new Error('interaction data was missing values');
|
||||
// console.log(`while executing record command, the following values were seen.`)
|
||||
// console.log(interaction.data.values)
|
||||
|
||||
// const embeds = new EmbedsBuilder()
|
||||
// .setTitle('My Embed')
|
||||
// .setDescription('This is my new embed')
|
||||
// .newEmbed()
|
||||
// .setTitle('My Second Embed')
|
||||
// await interaction.respond({
|
||||
// embeds:
|
||||
// })
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
// const statusEmbed = new EmbedBuilder()
|
||||
// .setTitle('Pending')
|
||||
// .setDescription('Waiting for a worker to accept the job.')
|
||||
// .setColor(2326507)
|
||||
|
||||
// const buttonRow = new ActionRowBuilder<MessageActionRowComponentBuilder>()
|
||||
// .addComponents([
|
||||
// new ButtonBuilder()
|
||||
// .setCustomId('stop')
|
||||
// .setLabel('Stop Recording')
|
||||
// .setEmoji('🛑')
|
||||
// .setStyle(ButtonStyle.Danger),
|
||||
// ]);
|
||||
|
||||
// const command: CreateSlashApplicationCommand = {
|
||||
// name: 'record',
|
||||
// description: 'Record a livestream.',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'url',
|
||||
// description: 'URL of the livestream',
|
||||
// type: ApplicationCommandOptionTypes.String
|
||||
// },
|
||||
// ],
|
||||
// async execute(interaction: Interaction) {
|
||||
// const ping = Date.now() - snowflakeToTimestamp(interaction.id)
|
||||
|
||||
// const embeds = createEmbeds().setTitle(`The bot ping is ${ping}ms`)
|
||||
|
||||
// await interaction.respond({ embeds })
|
||||
// },
|
||||
// }
|
||||
|
||||
// export default command
|
||||
}
|
||||
})
|
|
@ -3,29 +3,19 @@ import type { RecordingState } from '@futureporn/types'
|
|||
import { type Task, type Helpers } from 'graphile-worker'
|
||||
import { add } from 'date-fns'
|
||||
import prettyBytes from 'pretty-bytes'
|
||||
import {
|
||||
type APIEmbedField,
|
||||
Client,
|
||||
GatewayIntentBits,
|
||||
TextChannel,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
type MessageActionRowComponentBuilder,
|
||||
ButtonStyle,
|
||||
EmbedBuilder,
|
||||
Guild
|
||||
} from 'discord.js';
|
||||
import { EmbedsBuilder, type Component } from '@discordeno/bot'
|
||||
|
||||
|
||||
|
||||
interface Payload {
|
||||
recordId: number;
|
||||
record_id: number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function assertPayload(payload: any): asserts payload is Payload {
|
||||
if (typeof payload !== "object" || !payload) throw new Error("invalid payload");
|
||||
if (!payload.recordId) throw new Error(`recordId was absent in the payload`);
|
||||
if (!payload.record_id) throw new Error(`record_id was absent in the payload`);
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,7 +101,8 @@ async function getRecordFromDatabase(recordId: number) {
|
|||
export const updateDiscordMessage: Task = async function (payload, helpers: Helpers) {
|
||||
try {
|
||||
assertPayload(payload)
|
||||
const { recordId } = payload
|
||||
const { record_id } = payload
|
||||
const recordId = record_id
|
||||
helpers.logger.info(`updateDiscordMessage() with recordId=${recordId}`)
|
||||
const record = await getRecordFromDatabase(recordId)
|
||||
const { discord_message_id, recording_state, file_size, url } = record
|
||||
|
@ -133,64 +124,97 @@ export const updateDiscordMessage: Task = async function (payload, helpers: Help
|
|||
function getStatusEmbed({
|
||||
recordingState, recordId, fileSize, url
|
||||
}: { fileSize: number, recordingState: RecordingState, recordId: number, url: string }) {
|
||||
let title, description, color, fields;
|
||||
title = `Record ${recordId}`
|
||||
fields = [
|
||||
{ name: 'Status', value: 'Pending', inline: true },
|
||||
{ name: 'Filesize', value: `${fileSize} bytes (${prettyBytes(fileSize)})`, inline: true },
|
||||
{ name: 'URL', value: url, inline: false },
|
||||
] as APIEmbedField[]
|
||||
const embeds = new EmbedsBuilder()
|
||||
.setTitle(`Record ${recordId}`)
|
||||
.setFields([
|
||||
{ name: 'Status', value: 'Pending', inline: true },
|
||||
{ name: 'Filesize', value: `${fileSize} bytes (${prettyBytes(fileSize)})`, inline: true },
|
||||
{ name: 'URL', value: url, inline: false },
|
||||
])
|
||||
if (recordingState === 'pending') {
|
||||
description = "Waiting for a worker to accept the job."
|
||||
color = 2326507
|
||||
embeds
|
||||
.setDescription("Waiting for a worker to accept the job.")
|
||||
.setColor(2326507)
|
||||
} else if (recordingState === 'recording') {
|
||||
description = 'The stream is being recorded.'
|
||||
color = 392960
|
||||
embeds
|
||||
.setDescription('The stream is being recorded.')
|
||||
.setColor(392960)
|
||||
} else if (recordingState === 'aborted') {
|
||||
description = "The recording was stopped by the user."
|
||||
color = 8289651
|
||||
embeds
|
||||
.setDescription("The recording was stopped by the user.")
|
||||
.setColor(8289651)
|
||||
} else if (recordingState === 'ended') {
|
||||
description = "The recording has stopped."
|
||||
color = 10855845
|
||||
embeds
|
||||
.setDescription("The recording has stopped.")
|
||||
.setColor(10855845)
|
||||
} else {
|
||||
description = 'The recording is in an unknown state? (this is a bug.)'
|
||||
color = 10855845
|
||||
embeds
|
||||
.setDescription('The recording is in an unknown state? (this is a bug.)')
|
||||
.setColor(10855845)
|
||||
}
|
||||
return new EmbedBuilder().setTitle(title).setDescription(description).setColor(color).setFields(fields)
|
||||
return embeds
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getButtonRow(state: RecordingState) {
|
||||
let id, label, emoji, style;
|
||||
|
||||
const button = new Component()
|
||||
.setType("BUTTON")
|
||||
|
||||
// // Button with raw types
|
||||
// const button2 = new Component()
|
||||
// .setType(2)
|
||||
// .setStyle(4)
|
||||
// .setLabel("DO NOT CLICK")
|
||||
// .setCustomId("12345")
|
||||
// .toJSON();
|
||||
|
||||
// const actionRow = new Component()
|
||||
// .setType("ACTION_ROW")
|
||||
// .setComponents(button, button2)
|
||||
// .toJSON();
|
||||
|
||||
// return actionRow
|
||||
|
||||
// Message to send
|
||||
// const messageOptions = { content: "hello", components: [actionRow] };
|
||||
|
||||
// await client.helpers.sendMessage(channelId, messageOptions); // You can also use the Message Structure
|
||||
|
||||
if (state === 'pending') {
|
||||
id = 'stop';
|
||||
label = 'Cancel';
|
||||
emoji = '❌';
|
||||
style = ButtonStyle.Danger;
|
||||
button
|
||||
.setCustomId('stop')
|
||||
.setLabel('Cancel')
|
||||
.setEmoji('❌')
|
||||
.setStyle('DANGER')
|
||||
} else if (state === 'recording') {
|
||||
id = 'stop';
|
||||
label = 'Stop Recording';
|
||||
emoji = '🛑';
|
||||
style = ButtonStyle.Danger;
|
||||
button
|
||||
.setCustomId('stop')
|
||||
.setLabel('Stop Recording')
|
||||
.setEmoji('🛑')
|
||||
.setStyle('DANGER')
|
||||
} else if (state === 'aborted') {
|
||||
id = 'retry';
|
||||
label = 'Retry Recording';
|
||||
emoji = '🔄';
|
||||
style = ButtonStyle.Success;
|
||||
button
|
||||
.setCustomId('retry')
|
||||
.setLabel('Retry Recording')
|
||||
.setEmoji('🔄')
|
||||
.setStyle('SUCCESS')
|
||||
} else if (state === 'ended') {
|
||||
id = 'download';
|
||||
label = 'Download Recording';
|
||||
emoji = '📥';
|
||||
style = ButtonStyle.Primary;
|
||||
button
|
||||
.setCustomId('download')
|
||||
.setLabel('Download Recording')
|
||||
.setEmoji('📥')
|
||||
.setStyle('PRIMARY')
|
||||
} else {
|
||||
id = 'unknown';
|
||||
label = 'Unknown State';
|
||||
emoji = '🤔';
|
||||
style = ButtonStyle.Secondary;
|
||||
button
|
||||
.setCustomId('unknown')
|
||||
.setLabel('Unknown State')
|
||||
.setEmoji('🤔')
|
||||
.setStyle('SECONDARY')
|
||||
}
|
||||
|
||||
const actionRow = new Component
|
||||
return new ActionRowBuilder<MessageActionRowComponentBuilder>()
|
||||
.addComponents([
|
||||
new ButtonBuilder()
|
||||
|
|
|
@ -9,17 +9,17 @@
|
|||
|
||||
|
||||
CREATE FUNCTION public.tg__add_job() RETURNS trigger
|
||||
LANGUAGE plpgsql SECURITY DEFINER
|
||||
SET search_path TO 'pg_catalog', 'public', 'pg_temp'
|
||||
AS $$
|
||||
begin
|
||||
PERFORM graphile_worker.add_job(tg_argv[0], json_build_object(
|
||||
'url', NEW.url,
|
||||
'record_id', NEW.id
|
||||
), max_attempts := 12);
|
||||
return NEW;
|
||||
end;
|
||||
$$;
|
||||
LANGUAGE plpgsql SECURITY DEFINER
|
||||
SET search_path TO 'pg_catalog', 'public', 'pg_temp'
|
||||
AS $$
|
||||
begin
|
||||
PERFORM graphile_worker.add_job(tg_argv[0], json_build_object(
|
||||
'url', NEW.url,
|
||||
'record_id', NEW.id
|
||||
), max_attempts := 12);
|
||||
return NEW;
|
||||
end;
|
||||
$$;
|
||||
|
||||
|
||||
CREATE TRIGGER record
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
CREATE FUNCTION public.tg__update_discord_message() RETURNS trigger
|
||||
LANGUAGE plpgsql SECURITY DEFINER
|
||||
SET search_path TO 'pg_catalog', 'public', 'pg_temp'
|
||||
AS $$
|
||||
begin
|
||||
PERFORM graphile_worker.add_job('update_discord_message', json_build_object(
|
||||
'record_id', NEW.record_id
|
||||
), max_attempts := 3);
|
||||
return NEW;
|
||||
end;
|
||||
$$;
|
||||
|
||||
|
||||
|
||||
-- when a record is updated, we add a job in graphile to update_discord_message
|
||||
CREATE TRIGGER record_update
|
||||
AFTER UPDATE ON api.records
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE public.tg__update_discord_message('update_discord_message');
|
||||
|
Loading…
Reference in New Issue