Compare commits

..

1 Commits

Author SHA1 Message Date
lebaudantoine dc9dedb91b wip update tag 2024-09-12 11:19:23 +02:00
13 changed files with 6 additions and 147 deletions
-1
View File
@@ -42,4 +42,3 @@ LIVEKIT_API_SECRET=secret
LIVEKIT_API_KEY=devkey
LIVEKIT_API_URL=http://localhost:7880
ALLOW_UNREGISTERED_ROOMS=False
WORKER_SECRET=DevPurposeOnly
+1 -1
Submodule secrets updated: 1a016aca31...f5fbc16e6e
-38
View File
@@ -1,8 +1,6 @@
"""API endpoints"""
import smtplib
import uuid
import requests
from django.conf import settings
from django.db.models import Q
@@ -16,9 +14,6 @@ from rest_framework import (
pagination,
viewsets,
)
from rest_framework import (
permissions as drf_permissions,
)
from rest_framework import (
response as drf_response,
)
@@ -254,39 +249,6 @@ class RoomViewSet(
},
)
@decorators.action(
methods=["POST"],
detail=True,
url_path="summary",
permission_classes=[drf_permissions.AllowAny],
)
def summary(self, request, pk=None): # pylint: disable=unused-argument
"""Wip"""
secret = self.request.data.get("secret", None)
if secret is None or secret != settings.WORKER_SECRET:
return drf_response.Response({"message": "Invalid secret"}, status=403)
summary = self.request.data.get("summary", None)
transcript = self.request.data.get("transcript", None)
instance = self.get_object()
owners = instance.get_owners()
email = owners[0].email
url = f"https://dinum-pad-dev.osc-fr1.scalingo.io/summary?email={email}"
headers = {
"Content-Type": "text/plain"
}
response = requests.post(url, headers=headers, data=summary, allow_redirects=False)
try:
instance.email_summary(summary=summary, transcript=transcript, owners=owners, link=response.headers['Location'])
except smtplib.SMTPException:
return drf_response.Response({"message": "Error"}, status=500)
return drf_response.Response({"message": "Webhook data received"}, status=200)
class ResourceAccessListModelMixin:
"""List mixin for resource access API."""
+2 -50
View File
@@ -11,14 +11,10 @@ from django.contrib.auth.base_user import AbstractBaseUser
from django.core import mail, validators
from django.core.exceptions import PermissionDenied, ValidationError
from django.db import models
from django.template.loader import render_to_string
from django.utils.functional import lazy
from django.utils.text import capfirst, slugify
from django.utils.translation import gettext_lazy as _
from django.core.mail import EmailMessage
from django.core.files.base import ContentFile
from timezone_field import TimeZoneField
logger = getLogger(__name__)
@@ -154,28 +150,11 @@ class User(AbstractBaseUser, BaseModel, auth_models.PermissionsMixin):
def __str__(self):
return self.email or self.admin_email or str(self.id)
def email_user(self, subject, transcript, from_email=None, **kwargs):
def email_user(self, subject, message, from_email=None, **kwargs):
"""Email this user."""
if not self.email:
raise ValueError("User has no email address.")
# mail.send_mail(subject, message, from_email, [self.email], **kwargs)
email = EmailMessage(
subject,
kwargs['html_message'],
from_email,
[self.email],
)
# email.attach_alternative(kwargs['html_message'], "text/html")
transcript = transcript or ''
wip_file = ContentFile(transcript, 'transcript.txt')
email.content_subtype = "html"
email.attach(wip_file.name, wip_file.read(), 'text/plain')
email.send()
mail.send_mail(subject, message, from_email, [self.email], **kwargs)
def get_teams(self):
"""
@@ -346,30 +325,3 @@ class Room(Resource):
else:
raise ValidationError({"name": f'Room name "{self.name:s}" is reserved.'})
super().clean_fields(exclude=exclude)
def get_owners(self):
"""Fetch the user who is the owner of the room."""
owner_accesses = self.accesses.filter(role=RoleChoices.OWNER)
return [access.user for access in owner_accesses]
def email_summary(self, owners, summary, transcript, link):
"""Wip"""
template_vars = {
"title": _("A new summary is ready"),
"room": self.slug,
"summary": summary,
"link": link,
}
msg_plain = render_to_string("mail/text/summary.txt", template_vars)
msg_html = render_to_string("mail/html/summary.html", template_vars)
for owner in owners:
owner.email_user(
subject=_("A new summary is ready"),
transcript=transcript,
from_email=settings.EMAIL_FROM,
html_message=msg_html,
fail_silently=False,
)
Binary file not shown.
Binary file not shown.
-4
View File
@@ -258,7 +258,6 @@ class Base(Configuration):
EMAIL_HOST_PASSWORD = values.Value(None)
EMAIL_PORT = values.PositiveIntegerValue(None)
EMAIL_USE_TLS = values.BooleanValue(False)
EMAIL_USE_SSL = values.BooleanValue(False)
EMAIL_FROM = values.Value("from@example.com")
AUTH_USER_MODEL = "core.User"
@@ -372,9 +371,6 @@ class Base(Configuration):
ANALYTICS_KEY = values.Value(
None, environ_name="ANALYTICS_KEY", environ_prefix=None
)
WORKER_SECRET = values.Value(
None, environ_name="WORKER_SECRET", environ_prefix=None
)
# pylint: disable=invalid-name
@property
@@ -1,22 +1,13 @@
import { useRoomContext } from '@livekit/components-react'
import { useEffect, useState } from 'react'
import { RoomEvent } from 'livekit-client'
import { egressStore } from '@/stores/egress.tsx'
import { useSnapshot } from 'valtio'
export const RecordingIndicator = () => {
const room = useRoomContext()
const [isRecording, setIsRecording] = useState(room.isRecording)
const egressSnap = useSnapshot(egressStore)
const egressIsStopping = egressSnap.egressIsStopping
useEffect(() => {
const handleRecordingStatusChanges = (isRecording: boolean) => {
if (!isRecording) {
egressStore.egressIsStopping = false
}
setIsRecording(isRecording)
}
room.on(RoomEvent.RecordingStatusChanged, handleRecordingStatusChanges)
@@ -25,18 +16,6 @@ export const RecordingIndicator = () => {
}
}, [room])
const getStatus = () => {
if (egressIsStopping) {
return 'saving recording'
}
if (isRecording) {
return 'recording'
}
if (!isRecording) {
return 'available'
}
}
return (
<div
style={{
@@ -47,7 +26,7 @@ export const RecordingIndicator = () => {
width: '100%',
}}
>
Room status: {getStatus()}
Room is recording: {isRecording ? 'yes' : 'no'}
</div>
)
}
@@ -17,7 +17,6 @@ export const RecordingMenuItem = () => {
const handleAction = async () => {
if (egressId) {
setIsPending(true)
egressStore.egressIsStopping = true
const response = await stopRecordingRoom(egressId)
console.log(response)
egressStore.egressId = undefined
-2
View File
@@ -2,10 +2,8 @@ import { proxy } from 'valtio'
type State = {
egressId: string | undefined
egressIsStopping: boolean
}
export const egressStore = proxy<State>({
egressId: undefined,
egressIsStopping: false,
})
@@ -1,7 +1,7 @@
image:
repository: lasuite/meet-backend
pullPolicy: Always
tag: "v-hackathon"
tag: "hackathon"
backend:
migrateJobAnnotations:
@@ -92,10 +92,6 @@ backend:
secretKeyRef:
name: backend
key: LIVEKIT_API_KEY
WORKER_SECRET:
secretKeyRef:
name: backend
key: WORKER_SECRET
LIVEKIT_API_URL: https://livekit-staging.beta.numerique.gouv.fr
ANALYTICS_KEY: Roi1k6IAc2DEqHB0
ALLOW_UNREGISTERED_ROOMS: False
@@ -112,7 +108,7 @@ frontend:
image:
repository: lasuite/meet-frontend
pullPolicy: Always
tag: "v-hackathon"
tag: "hackathon"
ingress:
enabled: true
-3
View File
@@ -11,6 +11,3 @@ stringData:
OIDC_RP_CLIENT_SECRET: {{ .Values.oidc.clientSecret }}
LIVEKIT_API_SECRET: {{ .Values.livekitApi.secret }}
LIVEKIT_API_KEY: {{ .Values.livekitApi.key }}
{{- if .Values.workerSecret }}
WORKER_SECRET: {{ .Values.workerSecret }}
{{- end }}
-19
View File
@@ -1,19 +0,0 @@
<mjml>
<mj-include path="./partial/header.mjml" />
<mj-body mj-class="bg--blue-100">
<mj-wrapper css-class="wrapper" padding="0 40px 40px 40px">
<mj-section mj-class="bg--white-100" padding="30px 20px 60px 20px">
<mj-column>
<mj-text font-size="14px">
<p>Dear user,</p>
<p>The meeting <strong>{{room}}</strong> has been successfully transcribed and summarized.</p>
</mj-text>
<mj-button href="{{link}}" font-size="14px" background-color="#346DB7" color="white">
Get your summary
</mj-button>
</mj-column>
</mj-section>
</mj-wrapper>
</mj-body>
<mj-include path="./partial/footer.mjml" />
</mjml>