This commit is contained in:
AF 2020-08-22 23:19:22 +03:00
parent 57fc83567d
commit ab311c54d8
8 changed files with 24 additions and 10 deletions

3
.gitignore vendored
View File

@ -206,3 +206,6 @@ fabric.properties
# Others # Others
*.db *.db
/v25pushx/
/report.sql
/vapidkeys.json

7
.idea/sqldialects.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/report.sql" dialect="GenericSQL" />
<file url="PROJECT" dialect="SQLite" />
</component>
</project>

View File

@ -2,6 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/v25pushx" />
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />

View File

@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/v25pushx" vcs="Git" />
</component> </component>
</project> </project>

View File

@ -1,7 +1,7 @@
from flask import Flask from flask import Flask
from werkzeug.middleware.dispatcher import DispatcherMiddleware from werkzeug.middleware.dispatcher import DispatcherMiddleware
import config25 from v25 import config
from v25.storage.dbstorage import DBStorage from v25.storage.dbstorage import DBStorage
from v25.web.server.api import API from v25.web.server.api import API
@ -11,8 +11,8 @@ def simple(_env, resp):
return [] return []
d = config25.get_config('dev-config.json') d = config.get_config('dev-config.json')
config25.from_config(d) config.from_config(d)
app = Flask(__name__) app = Flask(__name__)
app.wsgi_app = DispatcherMiddleware(simple, { app.wsgi_app = DispatcherMiddleware(simple, {

View File

@ -1,7 +1,7 @@
from flask import Flask from flask import Flask
from werkzeug.middleware.dispatcher import DispatcherMiddleware from werkzeug.middleware.dispatcher import DispatcherMiddleware
import config25 from v25 import config
from v25.storage.dbstorage import DBStorage from v25.storage.dbstorage import DBStorage
from v25.web.server.api import API from v25.web.server.api import API
@ -11,8 +11,8 @@ def simple(_env, resp):
return [] return []
d = config25.get_config('staging-config.json') d = config.get_config('staging-config.json')
config25.from_config(d) config.from_config(d)
app = Flask(__name__) app = Flask(__name__)
app.wsgi_app = DispatcherMiddleware(simple, { app.wsgi_app = DispatcherMiddleware(simple, {

View File

@ -4,7 +4,7 @@ from typing import Dict, Any, Union
from v25.storage.dbstorage import DBStorage from v25.storage.dbstorage import DBStorage
_d_type = Dict[Any, Union[str, Dict[str, Any]]] _d_type = Dict[str, Union[str, Dict[str, Any]]]
def get_config(file: str) -> _d_type: def get_config(file: str) -> _d_type:

View File

@ -1,10 +1,10 @@
import json import json
from subprocess import Popen, PIPE
from sys import stderr from sys import stderr
from threading import Thread from threading import Thread
from time import time, sleep from time import time, sleep
from typing import Tuple, Optional, Iterable, List from typing import Tuple, Optional, Iterable, List
import requests
from nacl.bindings import crypto_sign_PUBLICKEYBYTES from nacl.bindings import crypto_sign_PUBLICKEYBYTES
from sqlalchemy import create_engine, LargeBinary, Column, REAL, BLOB, String, or_, and_, ForeignKeyConstraint, \ from sqlalchemy import create_engine, LargeBinary, Column, REAL, BLOB, String, or_, and_, ForeignKeyConstraint, \
Integer, UniqueConstraint, Index, Boolean Integer, UniqueConstraint, Index, Boolean
@ -342,14 +342,16 @@ class DBStorage(PushStorage):
@staticmethod @staticmethod
def pushsubscription(subscription: dict): def pushsubscription(subscription: dict):
assert requests.post('http://localhost:5025/api/push', json={ p = Popen(["node", "v25pushx/push.js"], stdin=PIPE, shell=True)
p.communicate(json.dumps({
"subscription": subscription, "subscription": subscription,
"notification": { "notification": {
"notification": { "notification": {
"title": "New Message (V25PUSH)" "title": "New Message (V25PUSH)"
} }
} }
}).status_code == 200, "push failed" }).encode())
assert not p.wait(), "push subprocess failed"
def pushpush(self, subject: Subject): def pushpush(self, subject: Subject):
session = self.Session() session = self.Session()