forked from rDrama/rDrama
Merge branch 'master' into fix-seed-db
commit
8b3ea17bf1
|
@ -606,7 +606,6 @@ def admin_title_change(user_id, v):
|
||||||
new_name=request.form.get("title").strip()
|
new_name=request.form.get("title").strip()
|
||||||
|
|
||||||
user.customtitleplain=new_name
|
user.customtitleplain=new_name
|
||||||
new_name=new_name.replace('_','\_')
|
|
||||||
new_name = sanitize(new_name, linkgen=True)
|
new_name = sanitize(new_name, linkgen=True)
|
||||||
|
|
||||||
user=g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=user.id).first()
|
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()
|
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)
|
if d: g.db.delete(d)
|
||||||
else:
|
else:
|
||||||
d = BannedDomain(domain=domain, reason=reason)
|
d = BannedDomain(domain=domain, reason=reason)
|
||||||
|
|
|
@ -207,3 +207,19 @@ def admin_apps_list(v):
|
||||||
apps = g.db.query(OauthApp).all()
|
apps = g.db.query(OauthApp).all()
|
||||||
|
|
||||||
return render_template("admin/apps.html", v=v, apps=apps)
|
return render_template("admin/apps.html", v=v, apps=apps)
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/oauth/reroll/<aid>")
|
||||||
|
@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}
|
|
@ -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"]
|
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:
|
elif app.config['SERVER_NAME'] in domain:
|
||||||
|
try:
|
||||||
matches = re.match(re.compile(f"^.*{domain}/post/+\w+/(\w+)(/\w+/(\w+))?"), url)
|
matches = re.match(re.compile(f"^.*{domain}/post/+\w+/(\w+)(/\w+/(\w+))?"), url)
|
||||||
post_id = matches.group(1)
|
post_id = matches.group(1)
|
||||||
comment_id = matches.group(3)
|
comment_id = matches.group(3)
|
||||||
if comment_id: embed = f"https://{app.config['SERVER_NAME']}/embed/comment/{comment_id}"
|
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}"
|
else: embed = f"https://{app.config['SERVER_NAME']}/embed/post/{post_id}"
|
||||||
|
except: embed = None
|
||||||
|
|
||||||
else: embed = None
|
else: embed = None
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,6 @@ def searchusers(v):
|
||||||
term=term.replace('\\','')
|
term=term.replace('\\','')
|
||||||
term=term.replace('_','\_')
|
term=term.replace('_','\_')
|
||||||
|
|
||||||
now=int(time.time())
|
|
||||||
users=g.db.query(User).filter(User.username.ilike(f'%{term}%'))
|
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())
|
users=users.order_by(User.username.ilike(term).desc(), User.stored_subscriber_count.desc())
|
||||||
|
|
|
@ -684,7 +684,6 @@ def settings_title_change(v):
|
||||||
error="You didn't change anything")
|
error="You didn't change anything")
|
||||||
|
|
||||||
v.customtitleplain = new_name
|
v.customtitleplain = new_name
|
||||||
new_name = new_name.replace('_','\_')
|
|
||||||
new_name = sanitize(new_name, flair=True)
|
new_name = sanitize(new_name, flair=True)
|
||||||
|
|
||||||
v = g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=v.id).first()
|
v = g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=v.id).first()
|
||||||
|
|
|
@ -29,6 +29,14 @@
|
||||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||||
<label for="edit-{{app.id}}-name" class="mb-0 w-lg-25">App Name</label>
|
<label for="edit-{{app.id}}-name" class="mb-0 w-lg-25">App Name</label>
|
||||||
<input id="edit-{{app.id}}-name" class="form-control" type="text" name="name" value="{{app.app_name}}">
|
<input id="edit-{{app.id}}-name" class="form-control" type="text" name="name" value="{{app.app_name}}">
|
||||||
|
|
||||||
|
|
||||||
|
{% if app.client_id %}
|
||||||
|
<label for="edit-{{app.id}}-client-id" class="mb-0 w-lg-25">Client ID</label>
|
||||||
|
<input id="edit-{{app.id}}-client-id" class="form-control copy-link" type="text" name="name" value="{{app.client_id}}" data-clipboard-text="{{app.client_id}}" role="button" readonly="readonly">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
<label for="edit-{{app.id}}-redirect" class="mb-0 w-lg-25">Redirect URI</label>
|
<label for="edit-{{app.id}}-redirect" class="mb-0 w-lg-25">Redirect URI</label>
|
||||||
<input id="edit-{{app.id}}-redirect" class="form-control" type="text" name="redirect_uri" value="{{app.redirect_uri}}">
|
<input id="edit-{{app.id}}-redirect" class="form-control" type="text" name="redirect_uri" value="{{app.redirect_uri}}">
|
||||||
<label for="edit-{{app.id}}-desc" class="mb-0 w-lg-25">Description</label>
|
<label for="edit-{{app.id}}-desc" class="mb-0 w-lg-25">Description</label>
|
||||||
|
@ -37,7 +45,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<a href="javascript:void(0)" class="btn btn-secondary ml-auto" onclick="post_toast('/oauth/reroll/{{app.id}}', callback=function(xhr){document.getElementById('edit-{{app.id}}-client-id').value=JSON.parse(xhr.response)['id'];document.getElementById('edit-{{app.id}}-client-secret').value=JSON.parse(xhr.response)['secret'];})">Reroll Tokens</a>
|
<a href="javascript:void(0)" class="btn btn-secondary ml-auto" onclick="post_toast('/oauth/reroll/{{app.id}}', callback=function(xhr){document.getElementById('edit-{{app.id}}-client-id').value=JSON.parse(xhr.response)['id'];document.getElementById('edit-{{app.id}}-client-secret').value=JSON.parse(xhr.response)['secret'];})">Reroll Client ID</a>
|
||||||
<input type="submit" class="btn btn-primary ml-2" value="Save Changes">
|
<input type="submit" class="btn btn-primary ml-2" value="Save Changes">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,6 +70,12 @@
|
||||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||||
<label for="edit-{{app.id}}-name" class="mb-0 w-lg-25">App Name</label>
|
<label for="edit-{{app.id}}-name" class="mb-0 w-lg-25">App Name</label>
|
||||||
<input id="edit-{{app.id}}-name" class="form-control" type="text" name="name" value="{{app.app_name}}">
|
<input id="edit-{{app.id}}-name" class="form-control" type="text" name="name" value="{{app.app_name}}">
|
||||||
|
|
||||||
|
{% if app.client_id %}
|
||||||
|
<label for="edit-{{app.id}}-client-id" class="mb-0 w-lg-25">Client ID</label>
|
||||||
|
<input id="edit-{{app.id}}-client-id" class="form-control copy-link" type="text" name="name" value="{{app.client_id}}" data-clipboard-text="{{app.client_id}}" role="button" readonly="readonly">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<label for="edit-{{app.id}}-redirect" class="mb-0 w-lg-25">Redirect URI</label>
|
<label for="edit-{{app.id}}-redirect" class="mb-0 w-lg-25">Redirect URI</label>
|
||||||
<input id="edit-{{app.id}}-redirect" class="form-control" type="text" name="redirect_uri" value="{{app.redirect_uri}}">
|
<input id="edit-{{app.id}}-redirect" class="form-control" type="text" name="redirect_uri" value="{{app.redirect_uri}}">
|
||||||
<label for="edit-{{app.id}}-desc" class="mb-0 w-lg-25">Description</label>
|
<label for="edit-{{app.id}}-desc" class="mb-0 w-lg-25">Description</label>
|
||||||
|
@ -91,7 +105,6 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="body w-lg-100">
|
<div class="body w-lg-100">
|
||||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||||
<label class="mb-0 w-lg-25">Permissions</label>
|
|
||||||
<label class="mb-0 w-lg-25">Description</label>
|
<label class="mb-0 w-lg-25">Description</label>
|
||||||
<textarea class="form-control" name="description" maxlength="256" readonly="readonly">{{auth.application.description}}</textarea>
|
<textarea class="form-control" name="description" maxlength="256" readonly="readonly">{{auth.application.description}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
51
schema.sql
51
schema.sql
|
@ -501,17 +501,8 @@ CREATE TABLE public.client_auths (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
user_id integer,
|
user_id integer,
|
||||||
oauth_client 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,
|
scope_guildmaster boolean,
|
||||||
access_token character(128),
|
access_token character(128)
|
||||||
refresh_token character(128),
|
|
||||||
oauth_code character(128),
|
|
||||||
access_token_expire_utc integer
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -889,11 +880,9 @@ ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id;
|
||||||
CREATE TABLE public.oauth_apps (
|
CREATE TABLE public.oauth_apps (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
client_id character(64),
|
client_id character(64),
|
||||||
client_secret character(128),
|
|
||||||
app_name character varying(50),
|
app_name character varying(50),
|
||||||
redirect_uri character varying(4096),
|
redirect_uri character varying(4096),
|
||||||
author_id integer,
|
author_id integer,
|
||||||
is_banned boolean,
|
|
||||||
description character varying(256)
|
description character varying(256)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1681,14 +1670,6 @@ ALTER TABLE ONLY public.client_auths
|
||||||
ADD CONSTRAINT unique_access UNIQUE (access_token);
|
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
|
-- 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);
|
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
|
-- 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);
|
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
|
-- Name: comment_body_idx; Type: INDEX; Schema: public; Owner: postgres
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in New Issue