Номер клиента
- Кол-во попыток
Дата и время
- Продолжительность
- Оператор
- Запись
Действие
@@ -105,16 +94,7 @@
{% else %}
{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
{% endif %}
- {{ c.count_try }}
- {{ c.time }}
- {{ c.answered_duration // 60 }}:{{ "{:02}".format(c.answered_duration % 60) }}
- {{ c.operator }}
-
- {% if c.has_record == true: %}
- Запись
- {% else %}
- Отсутствует
- {% endif %}
+ {{ c.dt }}
-
@@ -102,11 +100,18 @@
{% if c.mkt_phone == "83912051045": %}
- {{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7],
- c.client[7:11]) }}
+
+
+ {{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
+
+
{% else %}
- {{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
+
+
+ {{ "%s %s %s %s" |format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
+
+
{% endif %}
{{ c.time }} {{ c.important }}
{{ c.answered_duration // 60 }}:{{ "{:02}".format(c.answered_duration % 60) }}
diff --git a/web-dev backup-2024.03.22/templates/repair.html b/backup/web-dev/templates/repair.html
similarity index 100%
rename from web-dev backup-2024.03.22/templates/repair.html
rename to backup/web-dev/templates/repair.html
diff --git a/backup/web-dev/templates/truerecall.html b/backup/web-dev/templates/truerecall.html
new file mode 100644
index 0000000..49e7b23
--- /dev/null
+++ b/backup/web-dev/templates/truerecall.html
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+ Перезвонили успешно
+
+
+
+
+
+
+
+
+
+ Номер клиента
+ Дата и время
+
+
+
+
+ {% for c in call %}
+
+ {% if c.mkt_phone == "83912051045": %}
+
+ {{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7],
+ c.client[7:11]) }}
+
+ {% else %}
+ {{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
+ {% endif %}
+ {{ c.dt }}
+
+ {% endfor %}
+
+
+
+
+
\ No newline at end of file
diff --git a/backup/web-dev/templates/work.html b/backup/web-dev/templates/work.html
new file mode 100644
index 0000000..40ff0f1
--- /dev/null
+++ b/backup/web-dev/templates/work.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+ В работе
+
+
+
+ {% for c in call %}
+ {{ c.client }}
+
+
+
+ Направление:
+ {{ c.direction }}
+
+
+ Продолжительность:
+ {{ c.answered_duration }}
+
+
+ Время события:
+ {{ c.time }}
+
+
+ Вызываемый номер:
+ {{ c.mkt_phone }}
+
+
+
+
+ {% endfor %}
+
+
+
\ No newline at end of file
diff --git a/worker-dev backup-2024.03.22/app.py b/backup/worker-dev/app.py
similarity index 79%
rename from worker-dev backup-2024.03.22/app.py
rename to backup/worker-dev/app.py
index df32310..9d1e6e8 100644
--- a/worker-dev backup-2024.03.22/app.py
+++ b/backup/worker-dev/app.py
@@ -79,7 +79,6 @@ def main():
# В этом месте описывается логика работы программы исходя основываясь на данных мобилона
if res["direction"] == "incoming" and isBlack(res["from"]) == False:
# Подмена полей
-
res["client"] = res.pop("from")
res["mkt_phone"] = res.pop("to")
@@ -87,27 +86,6 @@ def main():
coll.delete_many(
{"client": {'$regex': res["client"]}, "status": {"$in": ["NOT_ANSWERED", "RECALL_FALSE"]}})
coll.insert_one(res)
-
- if res["direction"] == "external":
- res["client"] = res.pop("to")
- res["operator"] = res.pop("from")
-
- # Совершенно непонятный костыль, откуда берется загадка
- res.pop("_id")
-
- if res["has_record"] == True and res["answered_duration"] > min_recall_len_in_sec:
- res["status"] = "RECALL_TRUE"
- else:
- res["status"] = "RECALL_FALSE"
-
- t = coll.update_many({
- "client": {'$regex': res["client"]},
- "status": {'$in': ["NOT_ANSWERED", "RECALL_FALSE"]}
- }, {'$set': res, '$inc': {"count_try": 1}})
-
- coll.update_many({"count_try": {"$gt": 2}, "client": res["client"]}, {
- "$set": {"status": "DELETED"}})
-
# -------------------------------
res.clear()
diff --git a/worker-dev backup-2024.03.22/dockerfile b/backup/worker-dev/dockerfile
similarity index 100%
rename from worker-dev backup-2024.03.22/dockerfile
rename to backup/worker-dev/dockerfile
diff --git a/worker-dev backup-2024.03.22/phone.py b/backup/worker-dev/phone.py
similarity index 100%
rename from worker-dev backup-2024.03.22/phone.py
rename to backup/worker-dev/phone.py
diff --git a/worker-dev backup-2024.03.22/requirements.txt b/backup/worker-dev/requirements.txt
similarity index 100%
rename from worker-dev backup-2024.03.22/requirements.txt
rename to backup/worker-dev/requirements.txt
diff --git a/dev/web/app.py b/dev/web/app.py
new file mode 100644
index 0000000..abb1e24
--- /dev/null
+++ b/dev/web/app.py
@@ -0,0 +1,144 @@
+from urllib import request
+from flask import Flask, jsonify, render_template, url_for, request, redirect
+import json
+import datetime
+from pymongo import MongoClient
+import requests
+
+CONNECTION_STRING = "mongodb://mongodb:Cc03Wz5XX3iI3uY3@mongo"
+
+db_connection = MongoClient(CONNECTION_STRING)
+db_base = db_connection["phone-dev"]
+coll = db_base["phone"]
+bl = db_base["blacklist"]
+
+rep = False
+# coll_call = db_base["phone"]
+# coll_history = db_base["history"]
+
+app = Flask(__name__)
+
+internal = {}
+external = {}
+State = ""
+Findlimit = 100
+
+
+@app.route("/")
+def root():
+ return redirect("/notanswer")
+
+
+ImportantNumber = ['839122051045']
+
+
+@app.route("/answer")
+def answer():
+ call = coll.find({"status": "ANSWERED"}).sort('time', -1).limit(Findlimit)
+ return render_template("answer.html", call=call) if rep == False else render_template("repair.html")
+
+
+@app.route("/notanswer")
+def notanswer():
+ call = coll.find({"status": "NOT_ANSWERED"}).sort(
+ 'time', -1).limit(Findlimit)
+ return render_template("notanswer.html", call=call) if rep == False else render_template("repair.html")
+
+
+@app.route("/truerecall")
+def recallTrue():
+ call = coll.find({"status": "RECALL_TRUE"}).sort(
+ 'time', -1).limit(Findlimit)
+ return render_template("truerecall.html", call=call) if rep == False else render_template("repair.html")
+
+
+@app.route("/falserecall")
+def rcallFalse():
+ call = coll.find({"status": "RECALL_FALSE"}).sort(
+ 'time', -1).limit(Findlimit)
+ return render_template("falserecall.html", call=call) if rep == False else render_template("repair.html")
+
+
+@app.route("/blacklist")
+def blacklist():
+ call = bl.find().sort('_id')
+ return render_template("blacklist.html", call=call) if rep == False else render_template("repair.html")
+
+
+@app.route("/test")
+def ttt():
+ res = []
+ for p in request.environ:
+ try:
+ res.append(p + " = " + request.environ[p])
+ except:
+ pass
+ # #" ".join(request.environ)
+ return str(res)
+
+
+@app.route("/work/")
+def work_uuid(uuid):
+ coll.update_one({"uuid": uuid}, {"$set": {"status": "INWORK"}})
+ call = coll.find({"uuid": uuid})
+ return render_template("work.html", call=call) if rep == False else render_template("repair.html")
+
+# API
+
+
+@app.route("/api/v1/call/set/", methods=["POST"])
+def call_put():
+ # print(request.form)
+ if request.form["act"] == "delete":
+ coll.update_many({"uuid": request.form["uuid"], "status": "RECALL_FALSE"}, {
+ "$set": {"status": "DELETED"}})
+ return redirect("/falserecall")
+
+
+@app.route("/api/v1/work/", methods=["POST"])
+def work():
+ dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+ coll.update_one({"uuid": request.form["uuid"]}, {
+ "$set": {"status": "RECALL_" + str(request.form["recall"]).upper(), "dt": dt}})
+ return redirect("/")
+
+
+@app.route("/api/v1/blacklist/add/", methods=["POST"])
+def blacklist_put(number):
+ insdict = {"_id": number, "desc": datetime.datetime.now()}
+ bl.update_one({"_id": number}, {"$set": insdict}, True)
+ coll.update_many({"client": number, "status": {
+ "$in": ["RECALL_TRUE", "RECALL_FALSE", "NOT_ANSWERED"]}}, {"$set": {"status": "IGNORED"}})
+ return redirect("/blacklist")
+
+
+@app.route("/api/v1/blacklist/delete/", methods=["POST"])
+def blacklist_delete(number):
+ bl.delete_many({"_id": number})
+ return redirect("/blacklist")
+
+
+@app.route("/api/v1/blacklist/get/")
+def blacklist_get(number):
+ try:
+ return [i for i in bl.find({"_id": number})][0]
+ except:
+ return {}
+
+
+@app.route("/api/v1/sync")
+def sync():
+ j = []
+ for x in coll.find({"status": "NOT_ANSWERED"}):
+ t_req = "https://callinfo.services.mobilon.ru/api/call/info/1e86a98e026578eb5f6bf8c092c0c4a2/" + \
+ x["uuid"]
+ res: dict = json.loads(requests.get(t_req).content)
+
+ j.append(res)
+ coll.update_one({"uuid": x["uuid"]}, {"$set": res})
+ return j
+
+
+if __name__ == "__main__":
+ app.debug = True
+ app.run(host="0.0.0.0", port=5000)
diff --git a/dev/web/dockerfile b/dev/web/dockerfile
new file mode 100644
index 0000000..abeabaa
--- /dev/null
+++ b/dev/web/dockerfile
@@ -0,0 +1,16 @@
+FROM alpine
+
+RUN apk update && apk upgrade && apk add python3 && apk add -U tzdata
+
+WORKDIR /app
+
+COPY requirements.txt requirements.txt
+RUN python3 -m venv .venv
+RUN /app/.venv/bin/pip3 install -r /app/requirements.txt
+COPY app.py /app
+COPY static /app/static
+COPY templates /app/templates
+
+EXPOSE 5000
+
+CMD [".venv/bin/python3", "app.py"]
\ No newline at end of file
diff --git a/dev/web/requirements.txt b/dev/web/requirements.txt
new file mode 100644
index 0000000..bc69331
--- /dev/null
+++ b/dev/web/requirements.txt
@@ -0,0 +1,11 @@
+click==8.1.3
+dnspython==2.3.0
+Flask==2.2.3
+importlib-metadata==6.2.0
+itsdangerous==2.1.2
+Jinja2==3.1.2
+MarkupSafe==2.1.2
+pymongo==4.3.3
+Werkzeug==2.2.3
+zipp==3.15.0
+requests==2.28.2
diff --git a/dev/web/static/main.css b/dev/web/static/main.css
new file mode 100644
index 0000000..0ab7019
--- /dev/null
+++ b/dev/web/static/main.css
@@ -0,0 +1,51 @@
+table {
+ width: 100%;
+ margin-bottom: 20px;
+ border: 5px solid #fff;
+ border-top: 5px solid #fff;
+ border-bottom: 3px solid #fff;
+ border-collapse: collapse;
+ outline: 3px solid #ffd300;
+ font-size: 15px;
+ background: #fff !important;
+ font-family: Verdana, Geneva, Tahoma, sans-serif;
+}
+
+table th {
+ font-weight: bold;
+ padding: 7px;
+ background: #ffd300;
+ border: none;
+ text-align: left;
+ font-size: 15px;
+ border-top: 3px solid #fff;
+ border-bottom: 3px solid #ffd300;
+}
+
+table td {
+ padding: 7px;
+ border: none;
+ border-top: 3px solid #fff;
+ border-bottom: 3px solid #fff;
+ font-size: 15px;
+}
+
+table tbody tr:nth-child(even) {
+ background: #f8f8f8 !important;
+}
+
+a {
+ font-size: large;
+ font-family: Verdana, Geneva, Tahoma, sans-serif;
+ color: chocolate;
+ padding-right: 50px;
+}
+
+header {
+ height: 50px;
+ vertical-align: middle;
+}
+
+form {
+ height: 40px;
+}
\ No newline at end of file
diff --git a/dev/web/templates/DeleteCall.html b/dev/web/templates/DeleteCall.html
new file mode 100644
index 0000000..760664f
--- /dev/null
+++ b/dev/web/templates/DeleteCall.html
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+ Удаление документа
+
+
+
+ Вы действительно хотите удалить номер: {{ id }}?
+ Причина удаления?
+
+
+
+
+
\ No newline at end of file
diff --git a/web-dev backup-2024.03.22/templates/truerecall.html b/dev/web/templates/answer.html
similarity index 80%
rename from web-dev backup-2024.03.22/templates/truerecall.html
rename to dev/web/templates/answer.html
index b91e900..536663e 100644
--- a/web-dev backup-2024.03.22/templates/truerecall.html
+++ b/dev/web/templates/answer.html
@@ -4,8 +4,8 @@
-
- Перезвонили успешно
+
+ Принятые вызовы
+
Номер клиента
Дата и время
- Продолжительность
- Оператор
Запись разговора
+ {% for c in call %}
- {% for c in call %}
{% if c.mkt_phone == "83912051045": %}
@@ -104,10 +103,8 @@
{% else %}
{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
{% endif %}
-
+
{{ c.time }}
- {{ c.answered_duration // 60 }}:{{ "{:02}".format(c.answered_duration % 60) }}
- {{ c.operator }}
Запись
{% endfor %}
diff --git a/dev/web/templates/blacklist.html b/dev/web/templates/blacklist.html
new file mode 100644
index 0000000..05deee5
--- /dev/null
+++ b/dev/web/templates/blacklist.html
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+ Черный список
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/web/templates/falserecall.html b/dev/web/templates/falserecall.html
new file mode 100644
index 0000000..d36b84a
--- /dev/null
+++ b/dev/web/templates/falserecall.html
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+ Перезвонили безуспешно
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/web/templates/notanswer.html b/dev/web/templates/notanswer.html
new file mode 100644
index 0000000..46bc0c4
--- /dev/null
+++ b/dev/web/templates/notanswer.html
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+ Непринятые
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/web/templates/repair.html b/dev/web/templates/repair.html
new file mode 100644
index 0000000..8c2648d
--- /dev/null
+++ b/dev/web/templates/repair.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ Document
+
+
+
+ Ведутся работы, скоро все заработает
+
+
+
\ No newline at end of file
diff --git a/dev/web/templates/truerecall.html b/dev/web/templates/truerecall.html
new file mode 100644
index 0000000..49e7b23
--- /dev/null
+++ b/dev/web/templates/truerecall.html
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+ Перезвонили успешно
+
+
+
+
+
+
+
+
+
+ Номер клиента
+ Дата и время
+
+
+
+
+ {% for c in call %}
+
+ {% if c.mkt_phone == "83912051045": %}
+
+ {{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7],
+ c.client[7:11]) }}
+
+ {% else %}
+ {{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
+ {% endif %}
+ {{ c.dt }}
+
+ {% endfor %}
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/web/templates/work.html b/dev/web/templates/work.html
new file mode 100644
index 0000000..40ff0f1
--- /dev/null
+++ b/dev/web/templates/work.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+ В работе
+
+
+
+ {% for c in call %}
+ {{ c.client }}
+
+
+
+ Направление:
+ {{ c.direction }}
+
+
+ Продолжительность:
+ {{ c.answered_duration }}
+
+
+ Время события:
+ {{ c.time }}
+
+
+ Вызываемый номер:
+ {{ c.mkt_phone }}
+
+
+
+
+
+ Результат
+
+
+ Дозвонились
+
+
+
+ Не дозвонились
+
+
+
+
+
+
+
+
+
+ {% endfor %}
+
+
+
\ No newline at end of file
diff --git a/dev/worker/app.py b/dev/worker/app.py
new file mode 100644
index 0000000..f0d7cfb
--- /dev/null
+++ b/dev/worker/app.py
@@ -0,0 +1,107 @@
+import pika
+import sys
+import os
+import json
+import datetime
+from pymongo import MongoClient
+import time
+from phone import phone
+import requests
+
+db_connection = MongoClient("mongodb://mongodb:Cc03Wz5XX3iI3uY3@mongo")
+db_base = db_connection["phone-dev"]
+coll = db_base["phone"]
+coll_all = db_base["phone-all"]
+err = db_base["err"]
+blacklist = db_base["blacklist"]
+phoneDebug = db_base["phone-debug"]
+coll_userkey = db_base['userkey']
+
+mkt_phones = ['83912051046', '83912051045']
+
+mobilon_wait = 5 # Время ожидания необходимо чтобы на стороне мобилона все улеглось
+min_recall_len_in_sec = 8
+
+
+def isBlack(number: str) -> bool:
+ return True if blacklist.count_documents({"_id": number}) > 0 else False
+
+
+# Stats:
+# 0 - ответили
+# 1 - не приняли
+# 2 - перезвонили успешно
+# 4 - Перезвонили неуспешно
+
+
+# LOG
+# 0 - выходящий вызов закончен
+# 1 - Вызов не принят
+# 2 - Перезвонили и дозвонились
+def main():
+
+ connection = pika.BlockingConnection(pika.ConnectionParameters(
+ 'rabbitmq', 5672, 'mkt', pika.PlainCredentials('rabbit', 'mrl2X0jwnYuCCiKFTshG7WKyOAhfDo')))
+ channel = connection.channel()
+
+ channel.queue_declare(queue='dev-incoming')
+
+ def callback(ch, method, properties, body: bytearray):
+ # Парсим строку
+ ph = phone(body)
+ # Определяем тип соединения
+ # Если входящий
+ print(ph.ConvertToJSON())
+
+ phoneDebug.insert_one(ph.ConvertToJSON())
+
+ if ph.GetState() == "START":
+ ph.addStart()
+
+ if ph.GetState() == "END":
+ ph.addEnd()
+
+ if ph.GetState() == "HANGUP" and ph.isCanClose() == 1:
+ # Ждем
+ time.sleep(mobilon_wait)
+
+ t_req = "https://callinfo.services.mobilon.ru/api/call/info/1e86a98e026578eb5f6bf8c092c0c4a2/" + ph.GetUUID()
+ try:
+ res: dict = json.loads(requests.get(t_req).content)
+ except:
+ print("Get data from Mobilon", t_req)
+
+ try:
+ coll_all.insert_one(res)
+ except:
+ print("coll_all:", res)
+
+ # В этом месте описывается логика работы программы исходя основываясь на данных мобилона
+ if res["direction"] == "incoming" and isBlack(res["from"]) == False:
+ # Подмена полей
+ res["client"] = res.pop("from")
+ res["mkt_phone"] = res.pop("to")
+
+ # 2. Удаляем пропущенные если есть
+ coll.delete_many(
+ {"client": {'$regex': res["client"]}, "status": {"$in": ["NOT_ANSWERED", "RECALL_FALSE"]}})
+ coll.insert_one(res)
+ # -------------------------------
+ res.clear()
+
+ channel.basic_consume(
+ queue='incoming-dev', on_message_callback=callback, auto_ack=True)
+
+ print(' [*] Waiting for messages. To exit press CTRL+C')
+ channel.start_consuming()
+
+
+if __name__ == '__main__':
+ try:
+ main()
+ except KeyboardInterrupt:
+ print('Interrupted')
+ try:
+ sys.exit(0)
+ except SystemExit:
+ os._exit(0)
diff --git a/worker-dev-backup/dockerfile b/dev/worker/dockerfile
similarity index 99%
rename from worker-dev-backup/dockerfile
rename to dev/worker/dockerfile
index 063c2bf..5ca5662 100644
--- a/worker-dev-backup/dockerfile
+++ b/dev/worker/dockerfile
@@ -5,10 +5,9 @@ RUN apk update && apk upgrade && apk add python3 && apk add -U tzdata
WORKDIR /app
COPY requirements.txt requirements.txt
-ADD *.py /app
RUN python3 -m venv .venv
RUN /app/.venv/bin/pip3 install -r /app/requirements.txt
-
+ADD *.py /app
EXPOSE 5000
CMD [".venv/bin/python3", "app.py"]
\ No newline at end of file
diff --git a/dev/worker/phone.py b/dev/worker/phone.py
new file mode 100644
index 0000000..4677213
--- /dev/null
+++ b/dev/worker/phone.py
@@ -0,0 +1,60 @@
+import json
+import redis
+
+
+r = redis.Redis(host="redis")
+
+
+class phone:
+ def __init__(self, message: bytearray):
+ self.msg = message
+ self.dict = self.ConvertToJSON()
+
+ def ConvertToJSON(self):
+ try:
+ return json.loads(str(self.msg.decode('utf-8')).replace("\'", "\""))
+ except:
+ return {}
+
+ # def GetDirection(self) -> str:
+ # return self.dict["direction"]
+
+ def GetUUID(self) -> str:
+ return self.dict["uuid"]
+
+ # def GetClient(self) -> str:
+ # return self.dict["from"] if self.GetDirection() == "incoming" else self.dict["to"]
+
+ # def GetOperator(self) -> str:
+ # return self.dict["to"] if self.GetDirection() == "incoming" else self.dict["from"]
+
+ # def GetTimestamp(self) -> int:
+ # """Return int timestamp"""
+ # return self.dict["time"]
+
+ def GetState(self) -> str:
+ return self.dict["state"]
+
+ # def isIncoming(self) -> bool:
+ # """True Если входящий, иначе False"""
+ # return True if self.GetDirection() == "incoming" else False
+
+ # def isExternal(self) -> bool:
+ # """True если исходящий, иначе False"""
+ # return True if self.GetDirection() == "external" else False
+
+ def isCanClose(self) -> int:
+ try:
+ return int(r.hget(self.GetUUID(), "canClose"))
+ except:
+ return 0
+
+ def addStart(self):
+ r.hset(self.GetUUID(), mapping={
+ "canClose": "0"
+ })
+
+ def addEnd(self):
+ r.hset(self.GetUUID(), mapping={
+ "canClose": "1"
+ })
diff --git a/dev/worker/requirements.txt b/dev/worker/requirements.txt
new file mode 100644
index 0000000..7479d1b
--- /dev/null
+++ b/dev/worker/requirements.txt
@@ -0,0 +1,18 @@
+async-timeout==4.0.3
+click==8.1.3
+dnspython==2.3.0
+Flask==2.2.3
+importlib-metadata==6.2.0
+itsdangerous==2.1.2
+Jinja2==3.1.2
+MarkupSafe==2.1.2
+pika==1.3.1
+pymongo==4.3.3
+certifi==2022.12.7
+charset-normalizer==3.1.0
+idna==3.4
+requests==2.28.2
+urllib3==1.26.15
+redis==5.0.1
+Werkzeug==2.2.3
+zipp==3.15.0
\ No newline at end of file
diff --git a/docker-compose.yaml b/docker-compose.yaml
index fb4d037..b776ee0 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -96,7 +96,28 @@ services:
- phone
ports:
- 6001:6001
-
+ dev-worker:
+ build: ./dev/worker
+ restart: always
+ environment:
+ - TZ=Asia/Krasnoyarsk
+ depends_on:
+ - mongo
+ networks:
+ - phone
+ dev-web:
+ build: ./dev/web
+ restart: always
+ environment:
+ - TZ=Asia/Krasnoyarsk
+ depends_on:
+ - mongo
+ networks:
+ - phone
+ ports:
+ - 7001:5000
+
+
networks:
phone:
volumes:
diff --git a/web-dev backup-2024.03.22/templates/TestCall.html b/web-dev backup-2024.03.22/templates/TestCall.html
deleted file mode 100644
index 021dbf5..0000000
--- a/web-dev backup-2024.03.22/templates/TestCall.html
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
- Lost Calls
-
-
-
-
-
\ No newline at end of file
diff --git a/web-dev backup-2024.03.22/templates/WebCall.html b/web-dev backup-2024.03.22/templates/WebCall.html
deleted file mode 100644
index 493117a..0000000
--- a/web-dev backup-2024.03.22/templates/WebCall.html
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
-
-
-
-
-
- Lost Calls
-
-
-
-
- Номер клиента
-
- Дата время
- Ссылка на запись
-
-
-
- {% for entry in call %}
-
-
- {% if entry.important == True %}
-
- {{ "%s %s %s %s"|format(entry.client[0:1], entry.client[1:4], entry.client[4:7],
- entry.client[7:11]) }}
-
- {% else %}
- {{ "%s %s %s %s"|format(entry.client[0:1], entry.client[1:4], entry.client[4:7], entry.client[7:11]) }}
-
- {% endif %}
-
- {{ entry.time }}
-
-<<<<<<< HEAD
- {% if entry.status == 0 %}
- Вызов принят
- {% elif entry.status == 1 %}
- Вызов не принят
- {% elif entry.status == 2 %}
- Перезвонили
- {% elif entry.status == 2 %}
- Абонент не взял трубку
- {% elif entry.status == 9 %}
- Абонент заблокирован
- {% endif %}
-
-
-=======
->>>>>>> parent of c52dc73 (Добавил поиск)
- {% if entry.recordUrl|length > 1 %}
- Запись
- {% endif %}
-
-
-
- {% endfor %}
-
-
-
-
\ No newline at end of file
diff --git a/web-dev backup-2024.03.22/templates/test.html b/web-dev backup-2024.03.22/templates/test.html
deleted file mode 100644
index e69de29..0000000
diff --git a/web-dev/app.py b/web-dev/app.py
index e02dc83..db9b86d 100644
--- a/web-dev/app.py
+++ b/web-dev/app.py
@@ -64,6 +64,7 @@ def blacklist():
call = bl.find().sort('_id')
return render_template("blacklist.html", call=call) if rep == False else render_template("repair.html")
+
@app.route("/test")
def ttt():
res = []
@@ -75,6 +76,7 @@ def ttt():
# #" ".join(request.environ)
return str(res)
+
@app.route("/work/")
def work_uuid(uuid):
coll.update_one({"uuid": uuid}, {"$set": {"status": "INWORK"}})
@@ -96,9 +98,11 @@ def call_put():
@app.route("/api/v1/work/", methods=["POST"])
def work():
dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- coll.update_one({"uuid": request.form["uuid"]}, {"$set": {"status": "RECALL_" + str(request.form["recall"]).upper(), "dt": dt}})
+ coll.update_one({"uuid": request.form["uuid"]}, {
+ "$set": {"status": "RECALL_" + str(request.form["recall"]).upper(), "dt": dt}})
return redirect("/")
+
@app.route("/api/v1/blacklist/add/", methods=["POST"])
def blacklist_put(number):
insdict = {"_id": number, "desc": datetime.datetime.now()}
diff --git a/worker-dev-backup/__pycache__/config.cpython-39.pyc b/worker-dev-backup/__pycache__/config.cpython-39.pyc
deleted file mode 100644
index 842d1e6..0000000
Binary files a/worker-dev-backup/__pycache__/config.cpython-39.pyc and /dev/null differ
diff --git a/worker-dev-backup/__pycache__/msg.cpython-39.pyc b/worker-dev-backup/__pycache__/msg.cpython-39.pyc
deleted file mode 100644
index 5cff7dd..0000000
Binary files a/worker-dev-backup/__pycache__/msg.cpython-39.pyc and /dev/null differ
diff --git a/worker-dev-backup/app.py b/worker-dev-backup/app.py
deleted file mode 100644
index 3051217..0000000
--- a/worker-dev-backup/app.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import pika
-import sys
-import os
-import json
-import datetime
-import re
-import config
-from pymongo import MongoClient
-from msg import msg
-import requests
-import time
-
-def main():
- connection = pika.BlockingConnection(pika.ConnectionParameters(
- "192.168.0.20", 5672, "mkt", pika.PlainCredentials(
- "rabbit", "mrl2X0jwnYuCCiKFTshG7WKyOAhfDo")
- ))
- channel = connection.channel()
-
- def callback(ch, method, properties, body: bytearray):
- srcJson = json.loads(str(body.decode('utf-8')).replace("\'", "\""))
-# if srcJson['state'] == 'HANGUP' and srcJson['direction'] == 'incoming' and srcJson['from'] == '89135853246':
- try:
- if srcJson['callstatus'] != 'ANSWER':
- print(srcJson)
- except:
- pass
-
- channel.basic_consume(
- queue='incoming-dev', on_message_callback=callback, auto_ack=False)
-
- print(' [*] Waiting for messages. To exit press CTRL+C')
- channel.start_consuming()
-
-
-if __name__ == '__main__':
- try:
- main()
- except KeyboardInterrupt:
- print('Interrupted')
- try:
- sys.exit(0)
- except SystemExit:
- os._exit(0)
diff --git a/worker-dev-backup/config.py b/worker-dev-backup/config.py
deleted file mode 100644
index 7a257dd..0000000
--- a/worker-dev-backup/config.py
+++ /dev/null
@@ -1,16 +0,0 @@
-
-IMPORTANT_LINE = ['83912051045']
-
-IGNORE_LIST = ['83912051045',
- '83912051046',
- '83919865589',
- '83919865589',
- '84950213944',
- '84951183750',
- '84951252791',
- '89919237009',
- '89919241441',
- '89919398228',
- '89919500798',
- '89919505445',
- '89919863883']
diff --git a/worker-dev-backup/getmsg.py b/worker-dev-backup/getmsg.py
deleted file mode 100644
index f782416..0000000
--- a/worker-dev-backup/getmsg.py
+++ /dev/null
@@ -1,94 +0,0 @@
-import pika
-import sys
-import os
-import json
-import datetime
-import re
-import config
-from pymongo import MongoClient
-from msg import msg
-import requests
-import time
-
-CONNECTION_STRING = "mongodb://mongodb:Cc03Wz5XX3iI3uY3@192.168.0.20"
-db_connection = MongoClient(CONNECTION_STRING)
-
-db_base = db_connection["phone"]
-coll_call = db_base["phone_dev"]
-from_api = db_base["from_api"]
-
-
-def main():
- connection = pika.BlockingConnection(pika.ConnectionParameters(
- "192.168.0.20", 5672, "mkt", pika.PlainCredentials(
- "rabbit", "mrl2X0jwnYuCCiKFTshG7WKyOAhfDo")
- ))
- channel = connection.channel()
-
- def callback(ch, method, properties, body: bytearray):
- m = msg(body)
-
- # Разбираем входящие звонки
- if m.isIncoming():
- # Если статус START
- if m.getState() == "START":
- insert_value = {
- "uuid": m.getUUID(),
- "status": -1,
- "canClose": 0
- }
-
- coll_call.update_one(
- filter={"client": m.getClient(), "status": -1},
- update={"$set": insert_value},
- upsert=True
- )
- #print("НАЧАТ:", m.dict)
-
- # Если Статус END
- if m.getState() == "END":
- coll_call.update_one(
- filter={"uuid": m.getUUID()},
- update={"$set": {"canClose": 1}}
- )
- #print("ЗАКОНЧЕН:", m.dict)
- time.sleep(5)
- resp = requests.get("https://callinfo.services.mobilon.ru/api/call/info/1e86a98e026578eb5f6bf8c092c0c4a2/" + m.getUUID())
- j = json.loads(resp.content.decode('utf-8'))
- d = dict(j)
- from_api.insert_one(d)
-
- # Если статус HANGUP
- if m.getState() == "HANGUP":
- if m.isAnswered():
- insert_value = {
- "status": 0,
- "duration": m.getDuration(),
- "recordUrl": m.getRecordUrl()
- }
- else:
- insert_value = {
- "status": 1
- }
- coll_call.update_one(
- filter={"uuid": m.getUUID(), "canClose": 1},
- update={"$set": insert_value}
- )
- #print("Положена трубка:", m.dict)
-
- channel.basic_consume(
- queue='test', on_message_callback=callback, auto_ack=True)
-
- print(' [*] Waiting for messages. To exit press CTRL+C')
- channel.start_consuming()
-
-
-if __name__ == '__main__':
- try:
- main()
- except KeyboardInterrupt:
- print('Interrupted')
- try:
- sys.exit(0)
- except SystemExit:
- os._exit(0)
diff --git a/worker-dev-backup/msg.py b/worker-dev-backup/msg.py
deleted file mode 100644
index 71b1b4a..0000000
--- a/worker-dev-backup/msg.py
+++ /dev/null
@@ -1,68 +0,0 @@
-import os
-import json
-import datetime
-import re
-import config
-
-
-class msg:
- def __init__(self, body):
- self.body: bytearray = body
- self.decode: str = self.body.decode('utf-8')
- self.json: json = json.loads(self.decode.replace("\'", "\""))
- self.dict: dict = dict(self.json)
-
- def getDirection(self):
- try:
- return self.dict["direction"]
- except:
- pass
-
- def isIncoming(self) -> bool:
- return True if self.dict["direction"] == "incoming" else False
-
- def isExternal(self) -> bool:
- return not self.isIncoming()
-
- def getState(self) -> str:
- try:
- return self.dict["state"]
- except:
- pass
-
- def getClient(self) -> str:
- return self.dict["from"] if self.isIncoming() else self.dict["to"]
-
- def getTime(self) -> str:
- try:
- return datetime.datetime.fromtimestamp(self.dict["time"]).strftime('%Y-%m-%d %H:%M:%S')
- except:
- return None
-
- def getStatus(self) -> int:
- pass
-
- def getRecordUrl(self) -> str:
- return self.dict["recordUrl"]
-
- def getDuration(self) -> int:
- return self.dict["duration"]
-
- def getUUID(self) -> str:
- try:
- return self.dict["uuid"]
- except:
- pass
-
- def isAnswered(self) -> bool:
- try:
- self.dict["callstatus"]
- return True
- except:
- return False
-
- def isImportant(self):
- try:
- return True if self.getState() == "START" and self.isIncoming() and self.dict["to"] in config.IMPORTANT_LINE else False
- except:
- pass
diff --git a/worker-dev-backup/requirements.txt b/worker-dev-backup/requirements.txt
deleted file mode 100644
index e575685..0000000
--- a/worker-dev-backup/requirements.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-dnspython==2.3.0
-pika==1.3.1
-pymongo==4.3.3
-certifi==2022.12.7
-charset-normalizer==3.1.0
-idna==3.4
-requests==2.28.2
-urllib3==1.26.15
\ No newline at end of file
diff --git a/worker-dev/app.py b/worker-dev/app.py
index 9d1e6e8..c97221e 100644
--- a/worker-dev/app.py
+++ b/worker-dev/app.py
@@ -9,7 +9,7 @@ from phone import phone
import requests
db_connection = MongoClient("mongodb://mongodb:Cc03Wz5XX3iI3uY3@mongo")
-db_base = db_connection["phone-dev"]
+db_base = db_connection["dev-phone"]
coll = db_base["phone"]
coll_all = db_base["phone-all"]
err = db_base["err"]