diff --git a/indexer/src/indexer/indexer.go b/indexer/src/indexer/indexer.go index f1e676ca..38479418 100644 --- a/indexer/src/indexer/indexer.go +++ b/indexer/src/indexer/indexer.go @@ -78,7 +78,7 @@ func New( metaprotocols := make(map[string]metaprotocol.Processor) metaprotocols["inscription"] = metaprotocol.NewInscriptionProcessor(config.ChainID, db, nsfwWorker) - metaprotocols["cft20"] = metaprotocol.NewCFT20Processor(config.ChainID, db) + metaprotocols["cft20"] = metaprotocol.NewCFT20Processor(config.ChainID, db, nsfwWorker) metaprotocols["marketplace"] = metaprotocol.NewMarketplaceProcessor(config.ChainID, db) return &Indexer{ diff --git a/indexer/src/indexer/metaprotocol/cft20.go b/indexer/src/indexer/metaprotocol/cft20.go index 90e81605..c1b63399 100644 --- a/indexer/src/indexer/metaprotocol/cft20.go +++ b/indexer/src/indexer/metaprotocol/cft20.go @@ -19,6 +19,7 @@ import ( "github.com/aws/aws-sdk-go/service/s3/s3manager" "github.com/donovansolms/cosmos-inscriptions/indexer/src/indexer/models" "github.com/donovansolms/cosmos-inscriptions/indexer/src/indexer/types" + "github.com/donovansolms/cosmos-inscriptions/indexer/src/nsfw" "github.com/kelseyhightower/envconfig" "github.com/leodido/go-urn" "gorm.io/gorm" @@ -36,6 +37,7 @@ type CFT20Config struct { type CFT20 struct { chainID string db *gorm.DB + nsfwWorker *nsfw.Worker s3Endpoint string s3Region string s3Bucket string @@ -55,7 +57,7 @@ type CFT20 struct { perWalletLimitMaxValue uint64 } -func NewCFT20Processor(chainID string, db *gorm.DB) *CFT20 { +func NewCFT20Processor(chainID string, db *gorm.DB, nsfwWorker *nsfw.Worker) *CFT20 { // Parse config environment variables for self var config InscriptionConfig err := envconfig.Process("", &config) @@ -66,6 +68,7 @@ func NewCFT20Processor(chainID string, db *gorm.DB) *CFT20 { return &CFT20{ chainID: chainID, db: db, + nsfwWorker: nsfwWorker, s3Endpoint: config.S3Endpoint, s3Region: config.S3Region, s3Bucket: config.S3Bucket, @@ -182,6 +185,8 @@ func (protocol *CFT20) Process(transactionModel models.Transaction, protocolURN // TODO: Rework the content extraction contentPath := "" contentLength := 0 + isExplicit := false + // If this token includes content, we need to store it and add to the record if len(rawTransaction.Body.NonCriticalExtensionOptions) == 1 { // Logo is stored in the non_critical_extension_options @@ -219,6 +224,9 @@ func (protocol *CFT20) Process(transactionModel models.Transaction, protocolURN return fmt.Errorf("unable to store content '%s'", err) } + // check if content is explicit + isExplicit = <-protocol.nsfwWorker.CheckImage(logoContent) + contentLength = len(logoContent) } @@ -239,6 +247,7 @@ func (protocol *CFT20) Process(transactionModel models.Transaction, protocolURN ContentPath: contentPath, ContentSizeBytes: uint64(contentLength), DateCreated: transactionModel.DateCreated, + IsExplicit: isExplicit, CirculatingSupply: 0, } diff --git a/indexer/src/indexer/metaprotocol/inscription.go b/indexer/src/indexer/metaprotocol/inscription.go index d7a2672f..8394abda 100644 --- a/indexer/src/indexer/metaprotocol/inscription.go +++ b/indexer/src/indexer/metaprotocol/inscription.go @@ -147,7 +147,7 @@ func (protocol *Inscription) Process(transactionModel models.Transaction, protoc } // check if content is explicit - isExplicit := <-protocol.nsfwWorker.Add(content) + isExplicit := <-protocol.nsfwWorker.CheckImage(content) inscriptionModel := models.Inscription{ ChainID: parsedURN.ChainID, diff --git a/indexer/src/indexer/models/token.go b/indexer/src/indexer/models/token.go index b8dc3654..1ddb8ac9 100644 --- a/indexer/src/indexer/models/token.go +++ b/indexer/src/indexer/models/token.go @@ -24,6 +24,7 @@ type Token struct { Metadata datatypes.JSON `gorm:"column:metadata"` ContentPath string `gorm:"column:content_path"` ContentSizeBytes uint64 `gorm:"column:content_size_bytes"` + IsExplicit bool `gorm:"column:is_explicit"` CirculatingSupply uint64 `gorm:"column:circulating_supply"` LastPriceBase uint64 `gorm:"column:last_price_base"` Volume24Base uint64 `gorm:"column:volume_24_base"` diff --git a/indexer/src/nsfw/worker.go b/indexer/src/nsfw/worker.go index 5f525014..853a7531 100644 --- a/indexer/src/nsfw/worker.go +++ b/indexer/src/nsfw/worker.go @@ -69,7 +69,7 @@ func (w Worker) Stop() { }() } -func (w Worker) Add(image []byte) <-chan bool { +func (w Worker) CheckImage(image []byte) <-chan bool { w.work <- image return w.result }