-
Notifications
You must be signed in to change notification settings - Fork 330
[hma][api] bank_get_content can optionally return signals #1763
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
base: main
Are you sure you want to change the base?
Changes from all commits
fd68bb8
8925bbc
63e58c5
579050d
2038b4d
0438f83
6ab8dfa
916ec07
5fac425
aec6a4e
d7a2459
4b88738
133bf41
cce8aed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
""" | ||
|
||
import abc | ||
from dataclasses import dataclass | ||
from dataclasses import dataclass, field | ||
import typing as t | ||
import time | ||
|
||
|
@@ -308,7 +308,11 @@ class BankContentConfig: | |
Represents all the signals (hashes) for one piece of content. | ||
|
||
When signals come from external sources, or the original content | ||
has been lost | ||
has been lost. | ||
|
||
Signals are only included in this object when explicitly requested via | ||
signal_type parameter in bank_content_get(). | ||
The signals field will be None unless specifically requested. | ||
""" | ||
|
||
ENABLED: t.ClassVar[int] = 1 | ||
|
@@ -330,6 +334,10 @@ class BankContentConfig: | |
|
||
bank: BankConfig | ||
|
||
# Dictionary mapping signal_type names to signal values | ||
# which is only populated when explicitly requested | ||
signals: t.Optional[dict[str, str]] = None | ||
|
||
@property | ||
def enabled(self) -> bool: | ||
if self.disable_until_ts == 0: | ||
|
@@ -409,8 +417,25 @@ def bank_delete(self, name: str) -> None: | |
|
||
# Bank content | ||
@abc.abstractmethod | ||
def bank_content_get(self, id: t.Iterable[int]) -> t.Sequence[BankContentConfig]: | ||
"""Get the content config for a bank""" | ||
def bank_content_get( | ||
self, id: t.Iterable[int], *, include_signals: bool = false | ||
) -> t.Sequence[BankContentConfig]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unsure: As an alternative to including it in the bank content config, another solution would be to return this as |
||
""" | ||
Get the content config for a bank. | ||
|
||
Args: | ||
id: The IDs of the bank content to retrieve | ||
signal_type: Optional signal type to include in the response. | ||
If provided, signals of this type will be included in the result. | ||
If not provided, no signals will be fetched, significantly improving | ||
performance by avoiding unnecessary database joins. | ||
|
||
Returns: | ||
List of bank content configs. The 'signals' field will only be populated | ||
when signal_type is specified, and will only contain signals of the requested type. | ||
When signal_type is not specified, the 'signals' field will not be present in the | ||
returned objects, helping to reduce response size and improve clarity. | ||
""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unsure: As an alternative, we could provide a method that allows fetching the signals one at a time directly. The upsides would be that it's simpler to implement multiple interfaces, and would allow fetching strictly only the signals. |
||
@abc.abstractmethod | ||
def bank_content_update(self, val: BankContentConfig) -> None: | ||
|
Uh oh!
There was an error while loading. Please reload this page.