From eabb595d473cc73273ba21749ccb121f1aa03780 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 3 Aug 2021 18:00:15 +0000 Subject: [PATCH 1/7] schema --- schema.sql | 51 +-------------------------------------------------- 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/schema.sql b/schema.sql index 2312459bbd..48bcc63e06 100644 --- a/schema.sql +++ b/schema.sql @@ -501,17 +501,8 @@ CREATE TABLE public.client_auths ( id integer NOT NULL, user_id integer, oauth_client integer, - scope_identity boolean, - scope_create boolean, - scope_read boolean, - scope_update boolean, - scope_delete boolean, - scope_vote boolean, scope_guildmaster boolean, - access_token character(128), - refresh_token character(128), - oauth_code character(128), - access_token_expire_utc integer + access_token character(128) ); @@ -889,11 +880,9 @@ ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id; CREATE TABLE public.oauth_apps ( id integer NOT NULL, client_id character(64), - client_secret character(128), app_name character varying(50), redirect_uri character varying(4096), author_id integer, - is_banned boolean, description character varying(256) ); @@ -1681,14 +1670,6 @@ ALTER TABLE ONLY public.client_auths ADD CONSTRAINT unique_access UNIQUE (access_token); --- --- Name: client_auths unique_code; Type: CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY public.client_auths - ADD CONSTRAINT unique_code UNIQUE (oauth_code); - - -- -- Name: oauth_apps unique_id; Type: CONSTRAINT; Schema: public; Owner: postgres -- @@ -1697,22 +1678,6 @@ ALTER TABLE ONLY public.oauth_apps ADD CONSTRAINT unique_id UNIQUE (client_id); --- --- Name: client_auths unique_refresh; Type: CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY public.client_auths - ADD CONSTRAINT unique_refresh UNIQUE (refresh_token); - - --- --- Name: oauth_apps unique_secret; Type: CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY public.oauth_apps - ADD CONSTRAINT unique_secret UNIQUE (client_secret); - - -- -- Name: badges user_badge_constraint; Type: CONSTRAINT; Schema: public; Owner: postgres -- @@ -1906,20 +1871,6 @@ CREATE INDEX block_user_idx ON public.userblocks USING btree (user_id); CREATE INDEX cflag_user_idx ON public.commentflags USING btree (user_id); --- --- Name: client_access_token_idx; Type: INDEX; Schema: public; Owner: postgres --- - -CREATE INDEX client_access_token_idx ON public.client_auths USING btree (access_token, access_token_expire_utc); - - --- --- Name: client_refresh_token_idx; Type: INDEX; Schema: public; Owner: postgres --- - -CREATE INDEX client_refresh_token_idx ON public.client_auths USING btree (refresh_token); - - -- -- Name: comment_body_idx; Type: INDEX; Schema: public; Owner: postgres -- From 237bf6ee12d9136cff424868f35807f79fea0e15 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 3 Aug 2021 20:19:36 +0200 Subject: [PATCH 2/7] gfgf --- drama/templates/settings_apps.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drama/templates/settings_apps.html b/drama/templates/settings_apps.html index e75d27985d..8e8d7f8d71 100644 --- a/drama/templates/settings_apps.html +++ b/drama/templates/settings_apps.html @@ -29,6 +29,14 @@ + + + {% if app.client_id %} + + + {% endif %} + + @@ -62,6 +70,12 @@ + + {% if app.client_id %} + + + {% endif %} + From 7c66ad0fab34ed0f6070e54cd4ecd67489bb96f3 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 3 Aug 2021 20:20:25 +0200 Subject: [PATCH 3/7] fdfd --- drama/templates/settings_apps.html | 1 - 1 file changed, 1 deletion(-) diff --git a/drama/templates/settings_apps.html b/drama/templates/settings_apps.html index 8e8d7f8d71..4845ff8f24 100644 --- a/drama/templates/settings_apps.html +++ b/drama/templates/settings_apps.html @@ -105,7 +105,6 @@
-
From 0dde2ac6d816b48629049603e0ff7025ac393cb5 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 3 Aug 2021 20:22:22 +0200 Subject: [PATCH 4/7] fdfd --- drama/routes/oauth.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drama/routes/oauth.py b/drama/routes/oauth.py index af0c933d46..16283b14cf 100644 --- a/drama/routes/oauth.py +++ b/drama/routes/oauth.py @@ -206,4 +206,20 @@ def admin_apps_list(v): apps = g.db.query(OauthApp).all() - return render_template("admin/apps.html", v=v, apps=apps) \ No newline at end of file + return render_template("admin/apps.html", v=v, apps=apps) + + +@app.post("/oauth/reroll/") +@auth_required +def reroll_oauth_tokens(aid, v): + + aid = aid + + a = g.db.query(OauthApp).filter_by(id=aid).first() + + if a.author_id != v.id: abort(403) + + a.client_id = secrets.token_urlsafe(64)[:64] + g.db.add(a) + + return {"message": "Client ID Rerolled", "id": a.client_id} \ No newline at end of file From efd7165840e6edcfdcd16dbcadfc54606364095b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 3 Aug 2021 20:22:32 +0200 Subject: [PATCH 5/7] fdfd --- drama/templates/settings_apps.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drama/templates/settings_apps.html b/drama/templates/settings_apps.html index 4845ff8f24..7c61599f24 100644 --- a/drama/templates/settings_apps.html +++ b/drama/templates/settings_apps.html @@ -45,7 +45,7 @@ From ce4b4782697bdc60da3365a59af3c9a300dbbe15 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 3 Aug 2021 20:57:04 +0200 Subject: [PATCH 6/7] fdfd --- drama/routes/posts.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drama/routes/posts.py b/drama/routes/posts.py index b5ae29edf0..1a574b59c0 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -619,11 +619,13 @@ def submit_post(v): embed = requests.get("https://graph.facebook.com/v9.0/instagram_oembed", params={"url":url,"access_token":environ.get("FACEBOOK_TOKEN","").strip(),"omitscript":'true'}, headers={"User-Agent":"Instagram embedder for Drama"}).json()["html"] elif app.config['SERVER_NAME'] in domain: - matches = re.match(re.compile(f"^.*{domain}/post/+\w+/(\w+)(/\w+/(\w+))?"), url) - post_id = matches.group(1) - comment_id = matches.group(3) - if comment_id: embed = f"https://{app.config['SERVER_NAME']}/embed/comment/{comment_id}" - else: embed = f"https://{app.config['SERVER_NAME']}/embed/post/{post_id}" + try: + matches = re.match(re.compile(f"^.*{domain}/post/+\w+/(\w+)(/\w+/(\w+))?"), url) + post_id = matches.group(1) + comment_id = matches.group(3) + if comment_id: embed = f"https://{app.config['SERVER_NAME']}/embed/comment/{comment_id}" + else: embed = f"https://{app.config['SERVER_NAME']}/embed/post/{post_id}" + except: embed = None else: embed = None From 65cab20a7a31a549e813cab12f85a9d3b58a1ce6 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 3 Aug 2021 21:00:12 +0200 Subject: [PATCH 7/7] fdfd --- drama/routes/admin.py | 3 +-- drama/routes/search.py | 1 - drama/routes/settings.py | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drama/routes/admin.py b/drama/routes/admin.py index 8db5a2e24b..cf616d9860 100644 --- a/drama/routes/admin.py +++ b/drama/routes/admin.py @@ -606,7 +606,6 @@ def admin_title_change(user_id, v): new_name=request.form.get("title").strip() user.customtitleplain=new_name - new_name=new_name.replace('_','\_') new_name = sanitize(new_name, linkgen=True) user=g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=user.id).first() @@ -937,7 +936,7 @@ def admin_toggle_ban_domain(v): reason=request.form.get("reason", "").strip() - d = g.db.query(BannedDomain).filter_by(domain=domain.replace("_","\_")).first() + d = g.db.query(BannedDomain).filter_by(domain=domain).first() if d: g.db.delete(d) else: d = BannedDomain(domain=domain, reason=reason) diff --git a/drama/routes/search.py b/drama/routes/search.py index b16648bdd4..31cd8dc76a 100644 --- a/drama/routes/search.py +++ b/drama/routes/search.py @@ -275,7 +275,6 @@ def searchusers(v): term=term.replace('\\','') term=term.replace('_','\_') - now=int(time.time()) users=g.db.query(User).filter(User.username.ilike(f'%{term}%')) users=users.order_by(User.username.ilike(term).desc(), User.stored_subscriber_count.desc()) diff --git a/drama/routes/settings.py b/drama/routes/settings.py index 40fb696c4a..78a20e73c0 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -684,7 +684,6 @@ def settings_title_change(v): error="You didn't change anything") v.customtitleplain = new_name - new_name = new_name.replace('_','\_') new_name = sanitize(new_name, flair=True) v = g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=v.id).first()