Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

673 tags filtering #705

Merged
merged 3 commits into from
Jan 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions libraries/plugins/tags/tags_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,31 +189,30 @@ struct operation_visitor {
}

set< string > lower_tags;
if( c.category != "" )
meta.tags.insert( fc::to_lower( to_string( c.category ) ) );

uint8_t tag_limit = 5;
uint8_t count = 0;
for( const auto& tag : meta.tags )
{
++count;
if( count > tag_limit || lower_tags.size() > tag_limit )
break;
if( tag == "" )
continue;
lower_tags.insert( fc::to_lower( tag ) );
}

lower_tags.insert( fc::to_lower( to_string( c.category ) ) );


bool safe_for_work = false;
/// the universal tag applies to everything safe for work or nsfw with a positive payout
/// the universal tag applies to everything safe for work or nsfw with a non-negative payout
if( c.net_rshares >= 0 ||
(lower_tags.find( "spam" ) == lower_tags.end() &&
lower_tags.find( "nsfw" ) == lower_tags.end() &&
lower_tags.find( "test" ) == lower_tags.end() ) )
(lower_tags.find( "spam" ) == lower_tags.end() &&
lower_tags.find( "test" ) == lower_tags.end() ) )
{
safe_for_work = true;
lower_tags.insert( string() ); /// add it to the universal tag
}

meta.tags = lower_tags; /// TODO: std::move???
if( meta.tags.size() > 5 ) {
//wlog( "ignoring post ${a} because it has ${n} tags",("a", c.author + "/"+c.permlink)("n",meta.tags.size()));
if( safe_for_work )
meta.tags = set< string >( {"", to_string( c.parent_permlink ) } );
else
meta.tags.clear();
}


const auto& comment_idx = _db.get_index< tag_index >().indices().get< by_comment >();
Expand Down