Skip to content

Commit

Permalink
chg: [titles] add api to get unsafe titles
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Feb 15, 2024
1 parent 811ee45 commit 152e7bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
6 changes: 0 additions & 6 deletions var/www/blueprints/objects_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,3 @@ def objects_title_search():
dict_page=dict_page,
to_search=to_search, case_sensitive=case_sensitive, type_to_search=type_to_search)

@objects_title.route("/objects/titles/download", methods=['GET'])
@login_required
@login_analyst
def objects_title_downloads():
return jsonify(Titles.Titles().get_contents_ids())

24 changes: 22 additions & 2 deletions var/www/modules/restApi/Flask_restApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from lib import Users
from lib.objects import Items
from lib.objects import Titles
from lib.objects import Domains
from lib import Tag
from lib import Tracker

Expand Down Expand Up @@ -696,10 +697,29 @@ def v1_ping():


@restApi.route("api/v1/titles/download", methods=['GET'])
@token_required('read_only')
def objects_titles_downloads():
@token_required('analyst')
def objects_titles_download():
return Response(json.dumps(Titles.Titles().get_contents_ids()), mimetype='application/json'), 200

@restApi.route("api/v1/titles/download/unsafe", methods=['GET'])
@token_required('analyst')
def objects_titles_download_unsafe():
all_titles = {}
unsafe_tags = Tag.unsafe_tags
for tag in unsafe_tags:
domains = Tag.get_tag_objects(tag, 'domain')
for domain_id in domains:
domain = Domains.Domain(domain_id)
domain_titles = domain.get_correlation('title').get('title', [])
for titl in domain_titles:
title = Titles.Title(titl[1:])
title_content = title.get_content()
if title_content and title_content != 'None':
if title_content not in all_titles:
all_titles[title_content] = []
all_titles[title_content].append(domain.get_id())
return Response(json.dumps(all_titles), mimetype='application/json'), 200


# ========= REGISTRATION =========
app.register_blueprint(restApi, url_prefix=baseUrl)

0 comments on commit 152e7bb

Please sign in to comment.