···99 SocialClipprFeedClip,
1010 SocialClipprFeedTag,
1111} from "@clipprjs/lexicons";
1212-import { isDatetime, isLanguageCode } from "@atcute/lexicons/syntax";
1212+import {
1313+ isDatetime,
1414+ isGenericUri,
1515+ isLanguageCode,
1616+} from "@atcute/lexicons/syntax";
1317import Logger from "../logger.js";
1818+import { ComAtprotoRepoStrongRef } from "@atcute/atproto";
1919+import { is } from "@atcute/lexicons";
14201521export async function validateProfile(
1622 record: SocialClipprActorProfile.Main,
···3137 );
3238 return false;
3339 }
4040+4141+ if (record.displayName.length < 1) {
4242+ Logger.verbose(
4343+ "Too short displayName from incoming profile record",
4444+ record,
4545+ );
4646+ return false;
4747+ }
3448 } else {
3549 Logger.verbose("No displayName from incoming profile record", record);
3650 return false;
···4458 );
4559 return false;
4660 }
6161+6262+ if (record.description.length < 1) {
6363+ Logger.verbose(
6464+ "Too short description from incoming profile record",
6565+ record,
6666+ );
6767+ return false;
6868+ }
4769 }
48704971 return true;
···6183 }
62846385 if (record.name.length > 64) {
6464- Logger.verbose("Invalid name length for incoming tag record", record);
8686+ Logger.verbose("Name from incoming tag record is too long", record);
6587 return false;
6688 }
67899090+ if (record.name.length < 1) {
9191+ Logger.verbose("Name from incoming tag record is too short", record);
9292+ }
9393+6894 if (record.color) {
6995 if (record.color.length > 7) {
7070- Logger.verbose("Invalid color length for incoming tag record", record);
9696+ Logger.verbose("Color from incoming tag record is too long", record);
9797+ return false;
9898+ }
9999+100100+ if (record.color.length < 4) {
101101+ Logger.verbose("Color from incoming tag record is too short", record);
71102 return false;
72103 }
73104···86117export async function validateClip(
87118 record: SocialClipprFeedClip.Main,
88119): Promise<boolean> {
120120+ if (!isGenericUri(record.url)) {
121121+ Logger.verbose("Invalid url from incoming clip record", record);
122122+ return false;
123123+ }
124124+89125 if (record.url.length > 2000) {
90126 Logger.verbose("Too long url from incoming clip record", record);
91127 return false;
92128 }
93129130130+ if (record.url.length < 3) {
131131+ Logger.verbose("Too short url from incoming clip record", record);
132132+ return false;
133133+ }
134134+94135 if (record.title.length > 2048) {
95136 Logger.verbose("Too long title from incoming clip record", record);
96137 return false;
97138 }
98139140140+ if (record.title.length < 1) {
141141+ Logger.verbose("Too short title from incoming clip record", record);
142142+ return false;
143143+ }
144144+99145 if (record.description.length > 4096) {
100146 Logger.verbose("Too long description from incoming clip record", record);
101147 return false;
102148 }
103149150150+ if (record.description.length < 1) {
151151+ Logger.verbose("Too short description from incoming clip record", record);
152152+ return false;
153153+ }
154154+104155 if (record.notes) {
105156 if (record.notes.length > 10000) {
106157 Logger.verbose("Too long notes from incoming clip record", record);
107158 return false;
108159 }
160160+161161+ if (record.notes.length < 1) {
162162+ Logger.verbose("Too short notes from incoming clip record", record);
163163+ return false;
164164+ }
109165 }
110166111167 if (record.tags) {
112112- if (record.tags.some((tag) => tag.$type !== "com.atproto.repo.strongRef")) {
168168+ if (
169169+ record.tags.some((tag) => {
170170+ return tag.$type !== "com.atproto.repo.strongRef";
171171+ })
172172+ ) {
113173 Logger.verbose(
114114- "A tag ref from incoming clip record is not a strongRef",
174174+ "A tag from incoming clip record is not typed as strongRef",
175175+ record,
176176+ );
177177+ return false;
178178+ }
179179+180180+ if (
181181+ record.tags.some((tag) => {
182182+ return !is(ComAtprotoRepoStrongRef.mainSchema, tag);
183183+ })
184184+ ) {
185185+ Logger.verbose(
186186+ "A tag from incoming clip record is not a valid strongRef",
115187 record,
116188 );
117189 return false;
118190 }
119191120120- // There should be more tests here, but I'm not exactly sure what to add...
192192+ // There should definitely be more tests here, but I'm not exactly sure what to add...
121193 }
122194123195 if (typeof record.unlisted !== "boolean") {