Skip to content

Commit

Permalink
fix:search from slack
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Jun 29, 2024
1 parent 37b9e3a commit 2d6c3c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ x-depends-on-defaults: &depends-on-defaults

services:
searchdb:
image: getmeili/meilisearch:v1.7
image: getmeili/meilisearch:v1.8.3
ports:
- "7700:7700"
environment:
Expand Down Expand Up @@ -99,7 +99,7 @@ services:
- wiwik-network

redis:
image: redis/redis-stack-server:7.2.0-v9
image: redis/redis-stack-server:7.2.0-v11
ports:
- "6379:6379"
healthcheck:
Expand Down
12 changes: 6 additions & 6 deletions forum/forum/integrations/slack_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, List, Optional
from typing import Union, List, Optional, Dict, Any

from constance import config
from scheduler import job
Expand All @@ -14,6 +14,7 @@
DividerBlock,
HeaderBlock, MarkdownTextObject,
)
from slack_sdk.models.messages.message import Message
from slack_sdk.models.views import View
from slack_sdk.signature import SignatureVerifier

Expand Down Expand Up @@ -270,16 +271,14 @@ def verify_request(request) -> bool:
return verifier.is_valid(body, timestamp, signature)


def questions_message(questions: List[Question]) -> List:
def questions_slack_message(questions: List[Question]) -> Dict[str, Any]:
question_ids = [str(q.id) for q in questions]
logger.debug(f"Sending to slack question IDs ({','.join(question_ids)})")
blocks = list()
for question in questions:
question_url = get_model_url_with_base("question", question)
blocks.append(
HeaderBlock(
text=question.title,
).to_dict()
HeaderBlock(text=question.title, )
)
content = question.content[:1000]
content = content.split("\r\n")
Expand All @@ -294,4 +293,5 @@ def questions_message(questions: List[Question]) -> List:
).to_dict()
)
blocks.append(DividerBlock().to_dict())
return blocks
message = Message(text="", blocks=blocks)
return message.to_dict()
2 changes: 1 addition & 1 deletion forum/forum/views/integrations/slack_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def search_from_slack(request):
results = list(
search.query_method(Question.objects, query).order_by("-has_accepted_answer", "-votes", "-created_at")[:3]
)
res = {"blocks": slack_api.questions_message(results)}
res = slack_api.questions_slack_message(results)
logger.debug(res)
return JsonResponse(data=res, status=200)

0 comments on commit 2d6c3c0

Please sign in to comment.