Skip to content

Commit ec637f9

Browse files
committed
[backend] WIP background tasks on user
1 parent d5045d3 commit ec637f9

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

pycti/utils/opencti_stix2.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,10 +2595,13 @@ def element_add_organizations(self, item):
25952595
organization_ids = item["organization_ids"]
25962596
if item["type"] == "user":
25972597
for organization_id in organization_ids:
2598-
self.opencti.user.add_organization(id=item["id"], organization_id=organization_id)
2598+
self.opencti.user.add_organization(
2599+
id=item["id"], organization_id=organization_id
2600+
)
25992601
else:
26002602
raise ValueError(
2601-
"Add organizations operation not compatible with type", {"type": item["type"]}
2603+
"Add organizations operation not compatible with type",
2604+
{"type": item["type"]},
26022605
)
26032606

26042607
def element_remove_organizations(self, item):
@@ -2609,16 +2612,17 @@ def element_remove_organizations(self, item):
26092612
organization_ids = item["organization_ids"]
26102613
if item["type"] == "user":
26112614
for organization_id in organization_ids:
2612-
self.opencti.user.delete_organization(id=item["id"], organization_id=organization_id)
2615+
self.opencti.user.delete_organization(
2616+
id=item["id"], organization_id=organization_id
2617+
)
26132618
else:
26142619
raise ValueError(
2615-
"Remove organizations operation not compatible with type", {"type": item["type"]}
2620+
"Remove organizations operation not compatible with type",
2621+
{"type": item["type"]},
26162622
)
26172623

26182624
def element_add_groups(self, item):
2619-
group_ids = self.opencti.get_attribute_in_extension(
2620-
"group_ids", item
2621-
)
2625+
group_ids = self.opencti.get_attribute_in_extension("group_ids", item)
26222626
if group_ids is None:
26232627
group_ids = item["group_ids"]
26242628
if item["type"] == "user":
@@ -2630,17 +2634,16 @@ def element_add_groups(self, item):
26302634
)
26312635

26322636
def element_remove_groups(self, item):
2633-
group_ids = self.opencti.get_attribute_in_extension(
2634-
"group_ids", item
2635-
)
2637+
group_ids = self.opencti.get_attribute_in_extension("group_ids", item)
26362638
if group_ids is None:
26372639
group_ids = item["group_ids"]
26382640
if item["type"] == "user":
26392641
for group_id in group_ids:
26402642
self.opencti.user.delete_membership(id=item["id"], group_id=group_id)
26412643
else:
26422644
raise ValueError(
2643-
"Remove groups operation not compatible with type", {"type": item["type"]}
2645+
"Remove groups operation not compatible with type",
2646+
{"type": item["type"]},
26442647
)
26452648

26462649
def element_operation_delete(self, item, operation):

0 commit comments

Comments
 (0)