mirror of
https://github.com/fuckpiracyshield/service.git
synced 2024-11-21 12:49:46 +01:00
Added an error when trying to retrieve a checksum from an empty list. Small other fixes.
This commit is contained in:
parent
c82d4683b9
commit
579ed1de04
16 changed files with 60 additions and 5 deletions
|
@ -11,6 +11,7 @@ python_requires = >= 3.10
|
||||||
install_requires =
|
install_requires =
|
||||||
redis
|
redis
|
||||||
rq
|
rq
|
||||||
|
python-dateutil
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = src
|
where = src
|
||||||
|
|
|
@ -53,7 +53,7 @@ class AccountSessionGetCurrentByAccountService(BaseService):
|
||||||
|
|
||||||
# TODO: need to deal with this in the storage.
|
# TODO: need to deal with this in the storage.
|
||||||
# let's save the long session as well
|
# let's save the long session as well
|
||||||
long_session = self.data_memory.get_session(f'session:{account_id}:long:{session.get('refresh_token')}')
|
long_session = self.data_memory.get_session(f"session:{account_id}:long:{session.get('refresh_token')}")
|
||||||
|
|
||||||
long_session['token'] = session.get('refresh_token')
|
long_session['token'] = session.get('refresh_token')
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ class TicketCreateService(BaseService):
|
||||||
)
|
)
|
||||||
|
|
||||||
# proceed to build the relation item <-> provider
|
# proceed to build the relation item <-> provider
|
||||||
|
# this part provides a check for duplicates, whitelisted items and error tickets
|
||||||
(fqdn_ticket_items, ipv4_ticket_items, ipv6_ticket_items) = self.ticket_relation_establish_service.execute(
|
(fqdn_ticket_items, ipv4_ticket_items, ipv6_ticket_items) = self.ticket_relation_establish_service.execute(
|
||||||
ticket_id = model.get('ticket_id'),
|
ticket_id = model.get('ticket_id'),
|
||||||
providers = model.get('assigned_to'),
|
providers = model.get('assigned_to'),
|
||||||
|
@ -150,7 +151,8 @@ class TicketCreateService(BaseService):
|
||||||
ipv6 = ipv6,
|
ipv6 = ipv6,
|
||||||
now = Time.now_iso8601(),
|
now = Time.now_iso8601(),
|
||||||
created_by = created_by,
|
created_by = created_by,
|
||||||
tasks = [ # append the task id so we can cancel its execution if needed
|
tasks = [
|
||||||
|
# append the task id so we can cancel its execution if needed
|
||||||
initialize_job_id,
|
initialize_job_id,
|
||||||
autoclose_job_id
|
autoclose_job_id
|
||||||
]
|
]
|
||||||
|
|
|
@ -23,6 +23,8 @@ class TicketItemErrorCode:
|
||||||
|
|
||||||
TICKET_ITEM_UPDATE_TIME_EXCEEDED = '5010'
|
TICKET_ITEM_UPDATE_TIME_EXCEEDED = '5010'
|
||||||
|
|
||||||
|
TICKET_ITEM_EMPTY_CHECKSUM = '5011'
|
||||||
|
|
||||||
class TicketItemErrorMessage:
|
class TicketItemErrorMessage:
|
||||||
|
|
||||||
GENERIC = 'Error during the creation of the ticket item.'
|
GENERIC = 'Error during the creation of the ticket item.'
|
||||||
|
@ -46,3 +48,5 @@ class TicketItemErrorMessage:
|
||||||
TICKET_ITEM_REASON_NON_VALID = 'Non valid unprocessed reason.'
|
TICKET_ITEM_REASON_NON_VALID = 'Non valid unprocessed reason.'
|
||||||
|
|
||||||
TICKET_ITEM_UPDATE_TIME_EXCEEDED = 'Cannot update the ticket item: max update time has been exceeded.'
|
TICKET_ITEM_UPDATE_TIME_EXCEEDED = 'Cannot update the ticket item: max update time has been exceeded.'
|
||||||
|
|
||||||
|
TICKET_ITEM_EMPTY_CHECKSUM = 'No ticket item available to generate a checksum.'
|
||||||
|
|
|
@ -39,6 +39,10 @@ class TicketItemFQDNGetAllByTicketChecksumService(BaseService):
|
||||||
ticket_id = ticket_id
|
ticket_id = ticket_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -40,6 +40,10 @@ class TicketItemFQDNGetAllByTicketChecksumForProviderService(BaseService):
|
||||||
account_id = account_id
|
account_id = account_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TicketItemFQDNGetAllChecksumService(BaseService):
|
||||||
|
|
||||||
self._prepare_modules()
|
self._prepare_modules()
|
||||||
|
|
||||||
def execute(self, ticket_id: str) -> dict | Exception:
|
def execute(self) -> dict | Exception:
|
||||||
"""
|
"""
|
||||||
Get the checksum of all the FQDN items in the database.
|
Get the checksum of all the FQDN items in the database.
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@ class TicketItemFQDNGetAllChecksumService(BaseService):
|
||||||
|
|
||||||
response = self.ticket_item_fqdn_get_all_service.execute()
|
response = self.ticket_item_fqdn_get_all_service.execute()
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -39,6 +39,10 @@ class TicketItemFQDNGetAllChecksumByProviderService(BaseService):
|
||||||
account_id = account_id
|
account_id = account_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -39,6 +39,10 @@ class TicketItemIPv4GetAllByTicketChecksumService(BaseService):
|
||||||
ticket_id = ticket_id
|
ticket_id = ticket_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -40,6 +40,10 @@ class TicketItemIPv4GetAllByTicketChecksumForProviderService(BaseService):
|
||||||
account_id = account_id
|
account_id = account_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TicketItemIPv4GetAllChecksumService(BaseService):
|
||||||
|
|
||||||
self._prepare_modules()
|
self._prepare_modules()
|
||||||
|
|
||||||
def execute(self, ticket_id: str) -> dict | Exception:
|
def execute(self) -> dict | Exception:
|
||||||
"""
|
"""
|
||||||
Get the checksum of all the IPv4 items in the database.
|
Get the checksum of all the IPv4 items in the database.
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@ class TicketItemIPv4GetAllChecksumService(BaseService):
|
||||||
|
|
||||||
response = self.ticket_item_ipv4_get_all_service.execute()
|
response = self.ticket_item_ipv4_get_all_service.execute()
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -39,6 +39,10 @@ class TicketItemIPv4GetAllChecksumByProviderService(BaseService):
|
||||||
account_id = account_id
|
account_id = account_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -37,6 +37,10 @@ class TicketItemIPv6GetAllByTicketChecksumService(BaseService):
|
||||||
|
|
||||||
response = self.get_ipv6_all_by_ticket(ticket_id)
|
response = self.get_ipv6_all_by_ticket(ticket_id)
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -40,6 +40,10 @@ class TicketItemIPv6GetAllByTicketChecksumForProviderService(BaseService):
|
||||||
account_id = account_id
|
account_id = account_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TicketItemIPv6GetAllChecksumService(BaseService):
|
||||||
|
|
||||||
self._prepare_modules()
|
self._prepare_modules()
|
||||||
|
|
||||||
def execute(self, ticket_id: str) -> dict | Exception:
|
def execute(self) -> dict | Exception:
|
||||||
"""
|
"""
|
||||||
Get the checksum of all the IPv6 items in the database.
|
Get the checksum of all the IPv6 items in the database.
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@ class TicketItemIPv6GetAllChecksumService(BaseService):
|
||||||
|
|
||||||
response = self.ticket_item_ipv6_get_all_service.execute()
|
response = self.ticket_item_ipv6_get_all_service.execute()
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -39,6 +39,10 @@ class TicketItemIPv6GetAllChecksumByProviderService(BaseService):
|
||||||
account_id = account_id
|
account_id = account_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# we don't have any data to work on
|
||||||
|
if not len(response):
|
||||||
|
raise ApplicationException(TicketItemErrorCode.TICKET_ITEM_EMPTY_CHECKSUM, TicketItemErrorMessage.TICKET_ITEM_EMPTY_CHECKSUM)
|
||||||
|
|
||||||
data = '\n'.join(response)
|
data = '\n'.join(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue