Compare commits
	
		
			3 Commits
		
	
	
		
			f7c3f9afd9
			...
			445f38c6be
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 445f38c6be | |||
| f8a71d0aab | |||
| 49c8c9f124 | 
@ -35,7 +35,8 @@ import * as lex from '../lexicon/lexicons'
 | 
			
		||||
import { isRecord as isFeedGenerator } from '../lexicon/types/app/bsky/feed/generator'
 | 
			
		||||
import { isRecord as isStarterPack } from '../lexicon/types/app/bsky/graph/starterpack'
 | 
			
		||||
import { isRecord as isPost } from '../lexicon/types/app/bsky/feed/post'
 | 
			
		||||
import { isTag } from '../lexicon/types/app/bsky/richtext/facet'
 | 
			
		||||
import { isLink, isTag } from '../lexicon/types/app/bsky/richtext/facet'
 | 
			
		||||
import { isMain } from '../lexicon/types/app/bsky/embed/external'
 | 
			
		||||
import { isRecord as isList } from '../lexicon/types/app/bsky/graph/list'
 | 
			
		||||
import { isRecord as isProfile } from '../lexicon/types/app/bsky/actor/profile'
 | 
			
		||||
import { hasExplicitSlur } from '../handle/explicit-slurs'
 | 
			
		||||
@ -120,6 +121,7 @@ export const prepareCreate = async (opts: {
 | 
			
		||||
  const rkey = opts.rkey || nextRkey.toString()
 | 
			
		||||
  // @TODO: validate against Lexicon record 'key' type, not just overall recordkey syntax
 | 
			
		||||
  ensureValidRecordKey(rkey)
 | 
			
		||||
  filterSi(record)
 | 
			
		||||
  assertNoExplicitSlurs(rkey, record)
 | 
			
		||||
  return {
 | 
			
		||||
    action: WriteOpAction.Create,
 | 
			
		||||
@ -221,6 +223,26 @@ async function cidForSafeRecord(record: RepoRecord) {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function filterSi(record: RepoRecord) {
 | 
			
		||||
  const filt = str => str.replace(/si=[\w-]{16}/, '');
 | 
			
		||||
  if (isPost(record)) {
 | 
			
		||||
    // app truncates url so si will never be in text
 | 
			
		||||
    for (const facet of record.facets || []) {
 | 
			
		||||
      for (const feat of facet.features) {
 | 
			
		||||
        if (isLink(feat)) {
 | 
			
		||||
          feat.uri = filt(feat.uri);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if (record.embed) {
 | 
			
		||||
      if (isMain(record.embed)) {
 | 
			
		||||
        record.embed.external.uri = filt(record.embed.external.uri);
 | 
			
		||||
      }
 | 
			
		||||
      //todo filter alt text
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function assertNoExplicitSlurs(rkey: string, record: RepoRecord) {
 | 
			
		||||
  let toCheck = ''
 | 
			
		||||
  if (isProfile(record)) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user