2
0
Fork 0

Mark incoming messages as read when sending outgoing message, replace $token

This commit is contained in:
Luca 2023-05-08 21:07:43 +02:00
parent 8e3726eba4
commit 639524b9a4
1 changed files with 8 additions and 1 deletions

View File

@ -164,7 +164,14 @@ class HelperDetail(FormMixin, LoginRequiredMixin, DetailView):
form = self.get_form()
if form.is_valid():
Message(text=form.cleaned_data["message"], to=self.object).save()
IncomingMessage.objects.filter(sender=self.object.phone).update(read=True)
Message(
text=form.cleaned_data["message"].replace(
"$token",
f"https://helfen.kntkt.de{self.object.logintoken_set.first().get_absolute_url()}",
),
to=self.object,
).save()
return self.render_to_response(self.get_context_data(form=form))