forked from snarfed/bridgy
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As part of snarfed#873, we want to add support for RSVPing to events on Meetup.com via Bridgy. Meetup.com is the first silo that doesn't support Listen, so we need to handle it a little differently to other silos, ignoring anything Listen related, and when performing the initial Authorization flow from the home page, we use the Publish OAuth2 scopes, not Listen. As noted in [0], we can only have one `redirect_uri` for Meetup.com's OAuth2 clients, so we can use `https://brid.gy/meetup/` as the prefix, and then it will allow any matches under that path. Closes snarfed#873. [0]: https://www.jvt.me/posts/2020/02/15/meetup-api-multiple-redirect-uris/
- Loading branch information
1 parent
3cfa4ac
commit a4120f4
Showing
12 changed files
with
108 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"""Meetup API code and datastore model classes. | ||
""" | ||
import logging | ||
|
||
from granary import meetup as gr_meetup | ||
from oauth_dropins import meetup as oauth_meetup | ||
from oauth_dropins.webutil.util import json_dumps, json_loads | ||
import webapp2 | ||
|
||
from models import Source | ||
import util | ||
|
||
# We don't support listen | ||
LISTEN_SCOPES = [] | ||
PUBLISH_SCOPES = [ | ||
'rsvp', | ||
] | ||
|
||
|
||
class Meetup(Source): | ||
GR_CLASS = gr_meetup.Meetup | ||
OAUTH_START_HANDLER = oauth_meetup.StartHandler | ||
SHORT_NAME = 'meetup' | ||
BACKFEED_REQUIRES_SYNDICATION_LINK = True | ||
CAN_PUBLISH = True | ||
URL_CANONICALIZER = util.UrlCanonicalizer( | ||
domain=GR_CLASS.DOMAIN, | ||
headers=util.REQUEST_HEADERS) | ||
|
||
@staticmethod | ||
def new(handler, auth_entity=None, **kwargs): | ||
"""Creates and returns a :class:`Meetup` for the logged in user. | ||
Args: | ||
handler: the current :class:`webapp2.RequestHandler` | ||
auth_entity: :class:`oauth_dropins.meetup.MeetupAuth` | ||
kwargs: property values | ||
""" | ||
user = json_loads(auth_entity.user_json) | ||
gr_source = gr_meetup.Meetup(access_token=auth_entity.access_token()) | ||
actor = gr_source.user_to_actor(user) | ||
return Meetup(id=auth_entity.key.id(), | ||
auth_entity=auth_entity.key, | ||
name=actor.get('displayName'), | ||
picture=actor.get('image', {}).get('url'), | ||
url=actor.get('url'), | ||
**kwargs) | ||
|
||
def silo_url(self): | ||
"""Returns the Meetup account URL, e.g. https://meetup.com/members/....""" | ||
return self.gr_source.user_url(self.key.id()) | ||
|
||
def label_name(self): | ||
"""Returns the username.""" | ||
return self.name | ||
|
||
|
||
class AddMeetup(oauth_meetup.CallbackHandler, util.Handler): | ||
def finish(self, auth_entity, state=None): | ||
logging.debug('finish with %s, %s', auth_entity, state) | ||
self.maybe_add_or_delete_source(Meetup, auth_entity, state) | ||
|
||
ROUTES = [ | ||
('/meetup/start', util.oauth_starter(oauth_meetup.StartHandler).to( | ||
'/meetup/add', scopes=LISTEN_SCOPES)), | ||
('/meetup/add', AddMeetup), | ||
('/meetup/delete/finish', oauth_meetup.CallbackHandler.to('/delete/finish')), | ||
('/meetup/publish/start', oauth_meetup.StartHandler.to( | ||
'/meetup/publish/finish', scopes=PUBLISH_SCOPES)), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% extends "social_user.html" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters