kopia lustrzana https://github.com/bugout-dev/moonstream
Add changes.
rodzic
6a710ef9f7
commit
2daf6ab755
|
@ -23,7 +23,7 @@ from ..admin import subscription_types
|
||||||
from ..middleware import MoonstreamHTTPException
|
from ..middleware import MoonstreamHTTPException
|
||||||
from ..reporter import reporter
|
from ..reporter import reporter
|
||||||
from ..settings import bugout_client as bc, entity_client as ec
|
from ..settings import bugout_client as bc, entity_client as ec
|
||||||
from ..settings import MOONSTREAM_ADMIN_ACCESS_TOKEN, MOONSTREAM_MOONWORM_TASKS_JOURNAL
|
from ..settings import MOONSTREAM_ADMIN_ACCESS_TOKEN, MOONSTREAM_ENTITIES_RESERVED_TAGS
|
||||||
from ..web3_provider import yield_web3_provider
|
from ..web3_provider import yield_web3_provider
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,16 +131,7 @@ async def add_subscription_handler(
|
||||||
allowed_required_fields = {
|
allowed_required_fields = {
|
||||||
key: value
|
key: value
|
||||||
for key, value in additional_required_fields_dict.items()
|
for key, value in additional_required_fields_dict.items()
|
||||||
if key
|
if key not in MOONSTREAM_ENTITIES_RESERVED_TAGS
|
||||||
not in [
|
|
||||||
"type",
|
|
||||||
"subscription_type_id",
|
|
||||||
"color",
|
|
||||||
"label",
|
|
||||||
"user_id",
|
|
||||||
"address",
|
|
||||||
"blockchain",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required_fields = [
|
required_fields = [
|
||||||
|
@ -389,7 +380,11 @@ async def update_subscriptions_handler(
|
||||||
|
|
||||||
subscription_type_id = None
|
subscription_type_id = None
|
||||||
|
|
||||||
update_required_fields = subscription_entity.required_fields
|
update_required_fields = [
|
||||||
|
field
|
||||||
|
for field in subscription_entity.required_fields
|
||||||
|
if any(key in field for key in MOONSTREAM_ENTITIES_RESERVED_TAGS)
|
||||||
|
]
|
||||||
|
|
||||||
update_secondary_fields = subscription_entity.secondary_fields
|
update_secondary_fields = subscription_entity.secondary_fields
|
||||||
|
|
||||||
|
@ -418,6 +413,8 @@ async def update_subscriptions_handler(
|
||||||
)
|
)
|
||||||
raise MoonstreamHTTPException(status_code=500, internal_error=e)
|
raise MoonstreamHTTPException(status_code=500, internal_error=e)
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
for field in update_required_fields:
|
for field in update_required_fields:
|
||||||
if "color" in field and color is not None:
|
if "color" in field and color is not None:
|
||||||
field["color"] = color
|
field["color"] = color
|
||||||
|
@ -449,23 +446,13 @@ async def update_subscriptions_handler(
|
||||||
allowed_required_fields = {
|
allowed_required_fields = {
|
||||||
key: value
|
key: value
|
||||||
for key, value in additional_required_fields_dict.items()
|
for key, value in additional_required_fields_dict.items()
|
||||||
if key
|
if key not in MOONSTREAM_ENTITIES_RESERVED_TAGS
|
||||||
not in [
|
|
||||||
"type",
|
|
||||||
"subscription_type_id",
|
|
||||||
"color",
|
|
||||||
"label",
|
|
||||||
"user_id",
|
|
||||||
"address",
|
|
||||||
"blockchain",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if allowed_required_fields:
|
if allowed_required_fields:
|
||||||
update_required_fields.extend(
|
update_required_fields.extend(
|
||||||
[{key: value} for key, value in allowed_required_fields.items()]
|
[{key: value} for key, value in allowed_required_fields.items()]
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subscription = ec.update_entity(
|
subscription = ec.update_entity(
|
||||||
token=token,
|
token=token,
|
||||||
|
|
|
@ -123,6 +123,16 @@ if MOONSTREAM_S3_QUERIES_BUCKET_PREFIX == "":
|
||||||
"MOONSTREAM_S3_QUERIES_BUCKET_PREFIX environment variable must be set"
|
"MOONSTREAM_S3_QUERIES_BUCKET_PREFIX environment variable must be set"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Entities reserved tags
|
||||||
|
MOONSTREAM_ENTITIES_RESERVED_TAGS = [
|
||||||
|
"type",
|
||||||
|
"subscription_type_id",
|
||||||
|
"color",
|
||||||
|
"label",
|
||||||
|
"user_id",
|
||||||
|
"address",
|
||||||
|
"blockchain",
|
||||||
|
]
|
||||||
|
|
||||||
## Moonstream resources types
|
## Moonstream resources types
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue