Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
boke0 committed Mar 6, 2021
1 parent fc28110 commit 11d5e50
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 178 deletions.
5 changes: 3 additions & 2 deletions mitama/models/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ def object(self):

class PushSubscription(db.Model):
__tablename__ = "mitama_push_subscription"
_project = None
user_id = Column(String(64), ForeignKey("mitama_user._id", ondelete="CASCADE"))
user = relationship("User", backref="subscriptions")
subscription = Column(String(1024))
Expand All @@ -591,9 +592,9 @@ def push(self, data):
webpush(
subscription_info=json.loads(self.subscription),
data=json.dumps(data),
vapid_private_key=self.project.vapid.private_key,
vapid_private_key=self._project.vapid.private_key,
vapid_claims={
"sub": "mailto:{}".format(self.project.vapid.mailto)
"sub": "mailto:{}".format(self._project.vapid.mailto)
}
)
except Exception as err:
Expand Down
3 changes: 2 additions & 1 deletion mitama/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ def __init__(
self.install_dir = Path(os.path.dirname(os.path.abspath(__file__)))
self.project_dir = project_dir

from mitama.models import User, Group, UserInvite
from mitama.models import User, Group, UserInvite, PushSubscription
User._project = self
Group._project = self
UserInvite._project = self
PushSubscription._project = self
self.port = port
self.mail = mail
self.vapid = vapid
Expand Down
Loading

0 comments on commit 11d5e50

Please sign in to comment.