Work on fixing bugs and reformat
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import time
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
from urllib.parse import urlencode
|
||||
from django.views import View
|
||||
from mixins.views import ObjectList, ObjectRead
|
||||
|
||||
from core.clients import transport
|
||||
from core.models import ChatSession, Message, PersonIdentifier
|
||||
from core.util import logs
|
||||
from core.views.compose import _compose_urls, _service_icon_class
|
||||
from core.views.manage.permissions import SuperUserRequiredMixin
|
||||
from core.util import logs
|
||||
import time
|
||||
|
||||
log = logs.get_logger("whatsapp_view")
|
||||
|
||||
@@ -32,16 +33,13 @@ class WhatsApp(SuperUserRequiredMixin, View):
|
||||
)
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
account = (
|
||||
str(request.GET.get("account") or "").strip()
|
||||
or next(
|
||||
(
|
||||
str(item or "").strip()
|
||||
for item in transport.list_accounts("whatsapp")
|
||||
if str(item or "").strip()
|
||||
),
|
||||
"",
|
||||
)
|
||||
account = str(request.GET.get("account") or "").strip() or next(
|
||||
(
|
||||
str(item or "").strip()
|
||||
for item in transport.list_accounts("whatsapp")
|
||||
if str(item or "").strip()
|
||||
),
|
||||
"",
|
||||
)
|
||||
if account:
|
||||
transport.unlink_account("whatsapp", account)
|
||||
@@ -381,9 +379,7 @@ class WhatsAppAccountAdd(SuperUserRequiredMixin, ObjectRead):
|
||||
|
||||
def _detail_context(self, kwargs, obj):
|
||||
detail_url_args = {
|
||||
arg: kwargs[arg]
|
||||
for arg in self.detail_url_args
|
||||
if arg in kwargs
|
||||
arg: kwargs[arg] for arg in self.detail_url_args if arg in kwargs
|
||||
}
|
||||
return {
|
||||
"object": obj,
|
||||
@@ -410,7 +406,9 @@ class WhatsAppAccountAdd(SuperUserRequiredMixin, ObjectRead):
|
||||
sqlite_scanned = int(state.get("history_sqlite_scanned") or 0)
|
||||
on_demand_requested = bool(state.get("history_on_demand_requested"))
|
||||
on_demand_error = str(state.get("history_on_demand_error") or "").strip() or "-"
|
||||
on_demand_anchor = str(state.get("history_on_demand_anchor") or "").strip() or "-"
|
||||
on_demand_anchor = (
|
||||
str(state.get("history_on_demand_anchor") or "").strip() or "-"
|
||||
)
|
||||
history_running = bool(state.get("history_sync_running"))
|
||||
return [
|
||||
f"connected={bool(state.get('connected'))}",
|
||||
|
||||
Reference in New Issue
Block a user