Increase object ID size limit to 2000 chars

This commit is contained in:
silverpill 2023-04-06 15:39:23 +00:00
parent e950189086
commit 7c38c0a4d6
4 changed files with 14 additions and 7 deletions

View file

@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Validate actor aliases before saving into database. - Validate actor aliases before saving into database.
- Process incoming `Move()` activities in background. - Process incoming `Move()` activities in background.
- Allow custom emojis with `image/webp` media type. - Allow custom emojis with `image/webp` media type.
- Increase object ID size limit to 2000 chars.
### Fixed ### Fixed

View file

@ -0,0 +1,6 @@
ALTER TABLE actor_profile ALTER COLUMN actor_id TYPE VARCHAR(2000);
ALTER TABLE oauth_application ALTER COLUMN redirect_uri TYPE VARCHAR(2000);
ALTER TABLE follow_request ALTER COLUMN activity_id TYPE VARCHAR(2000);
ALTER TABLE post ALTER COLUMN object_id TYPE VARCHAR(2000);
ALTER TABLE post_reaction ALTER COLUMN activity_id TYPE VARCHAR(2000);
ALTER TABLE emoji ALTER COLUMN object_id TYPE VARCHAR(2000);

View file

@ -37,7 +37,7 @@ CREATE TABLE actor_profile (
post_count INTEGER NOT NULL CHECK (post_count >= 0) DEFAULT 0, post_count INTEGER NOT NULL CHECK (post_count >= 0) DEFAULT 0,
emojis JSONB NOT NULL DEFAULT '[]', emojis JSONB NOT NULL DEFAULT '[]',
actor_json JSONB, actor_json JSONB,
actor_id VARCHAR(200) UNIQUE GENERATED ALWAYS AS (actor_json ->> 'id') STORED, actor_id VARCHAR(2000) UNIQUE GENERATED ALWAYS AS (actor_json ->> 'id') STORED,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
unreachable_since TIMESTAMP WITH TIME ZONE, unreachable_since TIMESTAMP WITH TIME ZONE,
@ -66,7 +66,7 @@ CREATE TABLE oauth_application (
app_name VARCHAR(100) NOT NULL, app_name VARCHAR(100) NOT NULL,
website VARCHAR(100), website VARCHAR(100),
scopes VARCHAR(200) NOT NULL, scopes VARCHAR(200) NOT NULL,
redirect_uri VARCHAR(200) NOT NULL, redirect_uri VARCHAR(2000) NOT NULL,
client_id UUID UNIQUE NOT NULL, client_id UUID UNIQUE NOT NULL,
client_secret VARCHAR(100) NOT NULL, client_secret VARCHAR(100) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
@ -103,7 +103,7 @@ CREATE TABLE follow_request (
id UUID PRIMARY KEY, id UUID PRIMARY KEY,
source_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE, source_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
target_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE, target_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
activity_id VARCHAR(250) UNIQUE, activity_id VARCHAR(2000) UNIQUE,
request_status SMALLINT NOT NULL, request_status SMALLINT NOT NULL,
UNIQUE (source_id, target_id), UNIQUE (source_id, target_id),
CHECK (source_id != target_id) CHECK (source_id != target_id)
@ -119,7 +119,7 @@ CREATE TABLE post (
reply_count INTEGER NOT NULL CHECK (reply_count >= 0) DEFAULT 0, reply_count INTEGER NOT NULL CHECK (reply_count >= 0) DEFAULT 0,
reaction_count INTEGER NOT NULL CHECK (reaction_count >= 0) DEFAULT 0, reaction_count INTEGER NOT NULL CHECK (reaction_count >= 0) DEFAULT 0,
repost_count INTEGER NOT NULL CHECK (repost_count >= 0) DEFAULT 0, repost_count INTEGER NOT NULL CHECK (repost_count >= 0) DEFAULT 0,
object_id VARCHAR(200) UNIQUE, object_id VARCHAR(2000) UNIQUE,
ipfs_cid VARCHAR(200), ipfs_cid VARCHAR(200),
token_id INTEGER, token_id INTEGER,
token_tx_id VARCHAR(200), token_tx_id VARCHAR(200),
@ -132,7 +132,7 @@ CREATE TABLE post_reaction (
id UUID PRIMARY KEY, id UUID PRIMARY KEY,
author_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE, author_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
post_id UUID NOT NULL REFERENCES post (id) ON DELETE CASCADE, post_id UUID NOT NULL REFERENCES post (id) ON DELETE CASCADE,
activity_id VARCHAR(250) UNIQUE, activity_id VARCHAR(2000) UNIQUE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
UNIQUE (author_id, post_id) UNIQUE (author_id, post_id)
); );
@ -177,7 +177,7 @@ CREATE TABLE emoji (
emoji_name VARCHAR(100) NOT NULL, emoji_name VARCHAR(100) NOT NULL,
hostname VARCHAR(100) REFERENCES instance (hostname) ON DELETE RESTRICT, hostname VARCHAR(100) REFERENCES instance (hostname) ON DELETE RESTRICT,
image JSONB NOT NULL, image JSONB NOT NULL,
object_id VARCHAR(250) UNIQUE, object_id VARCHAR(2000) UNIQUE,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL, updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
UNIQUE (emoji_name, hostname), UNIQUE (emoji_name, hostname),
CHECK ((hostname IS NULL) = (object_id IS NULL)) CHECK ((hostname IS NULL) = (object_id IS NULL))

View file

@ -7,7 +7,7 @@ pub const MENTIONS_MAX_NUM: usize = 50;
pub const LINKS_MAX_NUM: usize = 10; pub const LINKS_MAX_NUM: usize = 10;
pub const EMOJIS_MAX_NUM: usize = 50; pub const EMOJIS_MAX_NUM: usize = 50;
pub const OBJECT_ID_SIZE_MAX: usize = 200; pub const OBJECT_ID_SIZE_MAX: usize = 2000;
pub const CONTENT_MAX_SIZE: usize = 100000; pub const CONTENT_MAX_SIZE: usize = 100000;
const CONTENT_ALLOWED_TAGS: [&str; 8] = [ const CONTENT_ALLOWED_TAGS: [&str; 8] = [
"a", "a",