Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Merge 0fbc673 into dcd55af
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibhas committed Feb 18, 2019
2 parents dcd55af + 0fbc673 commit 16c1baf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions instance/settings-sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#: Cache type
CACHE_TYPE = 'redis'

#: For RQ
RQ_REDIS_URL = 'redis://localhost:6379/0'
RQ_SCHEDULER_INTERVAL = 1

#: Secret key
SECRET_KEY = 'make this something random'

Expand Down
2 changes: 2 additions & 0 deletions lastuser_oauth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from itsdangerous import JSONWebSignatureSerializer
from flask import Blueprint
from flask_assets import Bundle
from flask_rq2 import RQ


class LastuserOAuthBlueprint(Blueprint):
Expand All @@ -21,5 +22,6 @@ def init_app(self, app):

lastuser_oauth_js = Bundle('lastuser_oauth/js/app.js')
lastuser_oauth_css = Bundle('lastuser_oauth/css/app.css')
rq = RQ()

from . import forms, views # NOQA
10 changes: 5 additions & 5 deletions lastuser_oauth/views/notify.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-

import requests
from flask_rq import job
from lastuser_core.models import AuthToken
from lastuser_core.signals import user_data_changed, org_data_changed, team_data_changed, session_revoked
from lastuser_oauth import rq


user_changes_to_notify = set(['merge', 'profile', 'email', 'email-claim', 'email-delete',
Expand All @@ -14,7 +14,7 @@
def notify_session_revoked(session):
for client in session.clients:
if client.notification_uri:
send_notice.delay(client.notification_uri, data={
send_notice.queue(client.notification_uri, data={
'userid': session.user.buid, # XXX: Deprecated parameter
'buid': session.user.buid,
'type': 'user',
Expand Down Expand Up @@ -50,7 +50,7 @@ def notify_user_data_changed(user, changes):
'teams' in tokenscope or 'teams/*' in tokenscope):
notify_changes.append(change)
if notify_changes:
send_notice.delay(token.client.notification_uri, data={
send_notice.queue(token.client.notification_uri, data={
'userid': user.buid, # XXX: Deprecated parameter
'buid': user.buid,
'type': 'user',
Expand Down Expand Up @@ -81,7 +81,7 @@ def notify_org_data_changed(org, user, changes, team=None):
notify_user = user
else:
notify_user = users[0] # First user available
send_notice.delay(client.notification_uri, data={
send_notice.queue(client.notification_uri, data={
'userid': notify_user.buid, # XXX: Deprecated parameter
'buid': notify_user.buid,
'type': 'org' if team is None else 'team',
Expand All @@ -99,6 +99,6 @@ def notify_team_data_changed(team, user, changes):
notify_org_data_changed(team.org, user=user, changes=['team-' + c for c in changes], team=team)


@job('lastuser')
@rq.job('lastuser')
def send_notice(url, params=None, data=None, method='POST'):
requests.request(method, url, params=params, data=data)
5 changes: 2 additions & 3 deletions lastuserapp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

from flask import Flask
from flask_rq import RQ
from flask_migrate import Migrate
import coaster.app
from baseframe import baseframe, assets, Version
Expand All @@ -11,7 +10,7 @@
import lastuser_ui
from lastuser_core import login_registry
from lastuser_core.models import db
from lastuser_oauth import providers
from lastuser_oauth import providers, rq
from ._version import __version__

version = Version(__version__)
Expand All @@ -32,7 +31,7 @@
db.init_app(app)
db.app = app # To make it work without an app context
migrate = Migrate(app, db)
RQ(app) # Pick up RQ configuration from the app
rq.init_app(app) # Pick up RQ configuration from the app
baseframe.init_app(app, requires=['lastuser-oauth'],
ext_requires=['baseframe-mui', 'jquery.cookie', 'timezone'], theme='mui')

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ordereddict==1.1
Flask-WTF==0.14.2
requests==2.21.0
blinker==1.4
Flask-RQ==0.2
Flask-RQ2==18.2.1
tweepy==3.7.0
unicodecsv==0.14.1
oauth2client==4.1.3
Expand Down

0 comments on commit 16c1baf

Please sign in to comment.