-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add endpoint to contact experts via email
- Loading branch information
1 parent
fe4071a
commit 7df3893
Showing
9 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class EmailData(BaseModel): | ||
firstname: str | ||
lastname: str | ||
nigend: str | ||
service: str | None | ||
phone: str | ||
email: str | ||
seizure: str | ||
una_or_procedure_number: str | ||
gun_type: str | ||
gun_length: int | None | ||
gun_barrel_length: int | None | ||
markings_description: str | None | ||
right_picture: str | ||
left_picture: str | ||
markings_pictures: str | ||
magazine_picture: str | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import logging | ||
import os | ||
import time | ||
from typing import Union | ||
from typing import Annotated, Union | ||
from uuid import uuid4 | ||
|
||
from basegun_ml.classification import get_typology | ||
|
@@ -10,6 +10,7 @@ | |
APIRouter, | ||
BackgroundTasks, | ||
Cookie, | ||
Depends, | ||
File, | ||
Form, | ||
HTTPException, | ||
|
@@ -21,7 +22,8 @@ | |
from user_agents import parse | ||
|
||
from .config import APP_VERSION, S3_PREFIX, TYPOLOGIES_MEASURED, get_base_logs | ||
from .utils import upload_image | ||
from .models import EmailData | ||
from .utils import get_current_user, send_mail, upload_image | ||
|
||
router = APIRouter(prefix="/api") | ||
|
||
|
@@ -163,3 +165,33 @@ async def log_identification_dummy( | |
extras_logging["bg_" + key] = res[key] | ||
|
||
logging.info("Identification dummy", extra=extras_logging) | ||
|
||
|
||
# Currently missing because we don't know if we can send attachements or if target can use S3 link | ||
# Photo face droite : {request.right_picture} | ||
# Photo face gauche : {request.left_picture} | ||
# Photo des marquages : {request.markings_pictures} | ||
# Photo du chargeur : {request.magazine_picture} | ||
@router.post("/expert-contact") | ||
async def expert_contact( | ||
request: EmailData, | ||
current_user: Annotated[dict, Depends(get_current_user)], | ||
): | ||
send_mail( | ||
subject="[Basegun] Demande d'identification", | ||
to="[email protected]", | ||
message=f""" | ||
Nom : {request.lastname} | ||
Prénom : {request.firstname} | ||
NIGEND / matricule : {request.nigend} | ||
Service d'affectation : {request.service} | ||
Téléphone : {request.phone} | ||
Email : {request.email} | ||
Saisie : {request.seizure} | ||
N° de procédure : {request.una_or_procedure_number} | ||
Typologie de l'arme (épaule ou poing) : {request.gun_type} | ||
Longueur de l'arme : {request.gun_length} | ||
Longueur du canon de l'arme : {request.gun_barrel_length} | ||
Précision sur les marquages présents sur l'arme : {request.markings_description} | ||
""", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import jwt | ||
import pytest | ||
from fastapi.testclient import TestClient | ||
from src.config import PUBLIC_KEY | ||
from src.main import app | ||
|
||
client = TestClient(app) | ||
|
||
token = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiA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InZpZXctY2xpZW50cyIsIm1hbmFnZS1hdXRob3JpemF0aW9uIiwibWFuYWdlLWNsaWVudHMiLCJxdWVyeS1ncm91cHMiXX0sImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoicHJvZmlsZSBlbWFpbCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoiYWRtaW4ifQ.hU0hJgMQayorct84UK9jiXDWOoBZ2KgmGa-JK0OOvn5Dfq0i_uZEOwzSjNwsvsYjX5NtHRrVBIxIcYzD-6IubUB2eUk7dgbYTqcVyjkWFrjwuv6ieTYvk-OuUg5iCXSe67ZbFuQwvNCg_8ns3JhEAEgHD4mLmhkPDlln4FkK605vAGZ5bDDYuPbaBI3ao4zpFr837r8zP5BGnzsclzk-T9k03pbTZ2aIv3PqlhfBVl2rKM0KYYKL8n3zLvObFMnZSx22-AuTPKKxkv3IrpCX2Zr_pAv-Bb2dw9LfEy_jxKv1i175Awjy3ayLbltvMcRzDTEzZ7YdBiuKoGoYjdoHng" | ||
|
||
|
||
@pytest.mark.skip(reason="Cannot currently run in CI.") | ||
class TestAuthentication: | ||
def test_jwks(self): | ||
print( | ||
jwt.decode( | ||
token, | ||
PUBLIC_KEY, | ||
algorithms=["RS256"], | ||
audience=["master-realm", "account"], | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters