Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

85 changes: 0 additions & 85 deletions Pipfile

This file was deleted.

2,230 changes: 0 additions & 2,230 deletions Pipfile.lock

This file was deleted.

46 changes: 0 additions & 46 deletions app/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@


def remove_pii(text):
# Initialize Presidio engines for PII detection and anonymization
analyzer = AnalyzerEngine()
anonymizer = AnonymizerEngine()

# Step 1: Analyze the text for PII entities
results = analyzer.analyze(text=text, entities=[], language="en")

# Anonymize the text based on detected PII and the anonymization configuration
anonymized_result = anonymizer.anonymize(text=text, analyzer_results=results)

# Extract the anonymized text from the EngineResult object
anonymized_text = anonymized_result.text

pii_pattern = r"<(.*?)>"
Expand Down
52 changes: 2 additions & 50 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from app.celery.userDataComputation.activityClassification import (
from app.celery.compute.classifier import (
get_most_relevant_activity,
get_most_relevant_activity_for_batch,
)
from ..core.controllers.history import *
from ..core.models.history import *
from ..core.models.user import *
from ..core.models.celery_tasks import *
from ..core.models.visits import *
from ..core.modules.upload import upload_to_arweave, prepare_history_json
import redis
from celery import shared_task
Expand Down Expand Up @@ -50,46 +47,6 @@ def update_user_graph_cache(self, userAddress):



def send_telegram_message(slug, body):
tg_token_api = os.environ.get("TELEGRAM_API_TOKEN")
channel_id = "-1002178791722" # The channel ID you provided

subject = f"Activity for Slug: {slug}"
message = f"```{json.dumps(body, indent=2)}```"

# Send the message
telegram_api_url = f"https://api.telegram.org/bot{tg_token_api}/sendMessage"

payload = {
"chat_id": channel_id,
"text": f"{subject}\n\n{message}",
"parse_mode": "Markdown",
}

try:
response = requests.post(telegram_api_url, json=payload)
if response.status_code == 200:
print(f"Telegram message sent successfully for slug: {slug}")
else:
print(
f"Failed to send Telegram message for slug: {slug}. Status code: {response.status_code}"
)
except Exception as e:
print(f"Failed to send Telegram message for slug: {slug}. Error: {str(e)}")


@shared_task(
bind=True,
base=AbortableTask,
ack_later=True,
default_retry_delay=20,
max_retries=2,
queue="send-email",
)
def send_telegram_notification(self, slug, response):
send_telegram_message(slug, response)


@shared_task(
bind=True,
base=AbortableTask,
Expand All @@ -110,9 +67,7 @@ def contextual_activity_classification(self, item, address):
if not user:
print(f"User with address {address} not found")
return


print(item)

activity_json = get_activity_json(address)
history_entry = History(
address=address,
Expand Down Expand Up @@ -192,16 +147,13 @@ def contextual_activity_classification_for_batch(self, history_batch, address):
print(f"User with address {address} not found")
continue

# Create a new History entry
history_entry = History(
address=address,
url=item["url"],
title=item.get("title", "No Title Available"),
visitTime=float(item.get("lastVisitTime", datetime.now().timestamp())),
category=activity,
)

# Save the history entry to the database
history_entry.save()

print(
Expand Down
108 changes: 0 additions & 108 deletions app/config.py

This file was deleted.

Loading