forked from MarseyWorld/MarseyWorld
add a discord server for api users to help eachother
parent
b84bd72beb
commit
81b762fbc2
|
@ -19,7 +19,7 @@ class OauthApp(Base):
|
||||||
description = Column(String)
|
description = Column(String)
|
||||||
author_id = Column(Integer, ForeignKey("users.id"))
|
author_id = Column(Integer, ForeignKey("users.id"))
|
||||||
|
|
||||||
author = relationship("User")
|
author = relationship("User", back_populates="apps")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<OauthApp(id={self.id})>"
|
return f"<OauthApp(id={self.id})>"
|
||||||
|
|
|
@ -138,6 +138,7 @@ class User(Base):
|
||||||
blocking = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.user_id", back_populates="user")
|
blocking = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.user_id", back_populates="user")
|
||||||
blocked = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.target_id", back_populates="target")
|
blocked = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.target_id", back_populates="target")
|
||||||
authorizations = relationship("ClientAuth", back_populates="user")
|
authorizations = relationship("ClientAuth", back_populates="user")
|
||||||
|
apps = relationship("OauthApp", back_populates="author")
|
||||||
awards = relationship("AwardRelationship", primaryjoin="User.id==AwardRelationship.user_id", back_populates="user")
|
awards = relationship("AwardRelationship", primaryjoin="User.id==AwardRelationship.user_id", back_populates="user")
|
||||||
referrals = relationship("User")
|
referrals = relationship("User")
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,16 @@ def discord_redirect(v):
|
||||||
v.discord_id=x["id"]
|
v.discord_id=x["id"]
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
|
if v.apps:
|
||||||
|
url=f"https://discord.com/api/guilds/998387482984980541/members/{x['id']}"
|
||||||
|
name=v.username
|
||||||
|
data={
|
||||||
|
"access_token":token,
|
||||||
|
"nick":name,
|
||||||
|
}
|
||||||
|
requests.put(url, headers=headers, json=data, timeout=5)
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
url=f"https://discord.com/api/guilds/{DISCORD_SERVER_ID}/members/{x['id']}"
|
url=f"https://discord.com/api/guilds/{DISCORD_SERVER_ID}/members/{x['id']}"
|
||||||
|
|
||||||
name=v.username
|
name=v.username
|
||||||
|
|
|
@ -141,26 +141,27 @@ def admin_app_approve(v, aid):
|
||||||
app = g.db.get(OauthApp, aid)
|
app = g.db.get(OauthApp, aid)
|
||||||
user = app.author
|
user = app.author
|
||||||
|
|
||||||
app.client_id = secrets.token_urlsafe(64)[:64]
|
if not app.client_id:
|
||||||
g.db.add(app)
|
app.client_id = secrets.token_urlsafe(64)[:64]
|
||||||
|
g.db.add(app)
|
||||||
|
|
||||||
access_token = secrets.token_urlsafe(128)[:128]
|
access_token = secrets.token_urlsafe(128)[:128]
|
||||||
new_auth = ClientAuth(
|
new_auth = ClientAuth(
|
||||||
oauth_client = app.id,
|
oauth_client = app.id,
|
||||||
user_id = user.id,
|
user_id = user.id,
|
||||||
access_token=access_token
|
access_token=access_token
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(new_auth)
|
g.db.add(new_auth)
|
||||||
|
|
||||||
send_repeatable_notification(user.id, f"@{v.username} has approved your application `{app.app_name}`. Here's your access token: `{access_token}`\nPlease check the guide [here](/api) if you don't know what to do next.")
|
send_repeatable_notification(user.id, f"@{v.username} has approved your application `{app.app_name}`. Here's your access token: `{access_token}`\nPlease check the guide [here](/api) if you don't know what to do next, and join this [discord server](/discord) if you need help!")
|
||||||
|
|
||||||
ma = ModAction(
|
ma = ModAction(
|
||||||
kind="approve_app",
|
kind="approve_app",
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
target_user_id=user.id,
|
target_user_id=user.id,
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
|
|
||||||
|
|
||||||
return {"message": "Application approved"}
|
return {"message": "Application approved"}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
{% if not app.client_id%}
|
{% if not app.client_id%}
|
||||||
|
|
||||||
<a role="button" class="btn btn-primary ml-auto" onclick="post_toast(this,'/admin/app/approve/{{app.id}}')">Approve</a>
|
<a role="button" class="btn btn-primary ml-auto mr-2" onclick="post_toast(this,'/admin/app/approve/{{app.id}}')">Approve</a>
|
||||||
<a role="button" class="btn btn-secondary mr-0" onclick="post_toast(this,'/admin/app/reject/{{app.id}}')">Reject</a>
|
<a role="button" class="btn btn-secondary mr-0" onclick="post_toast(this,'/admin/app/reject/{{app.id}}')">Reject</a>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
{% if not app.client_id %}
|
{% if not app.client_id %}
|
||||||
|
|
||||||
<a role="button" class="btn btn-primary ml-auto" onclick="post_toast(this,'/admin/app/approve/{{app.id}}')">Approve</a>
|
<a role="button" class="btn btn-primary ml-auto mr-2" onclick="post_toast(this,'/admin/app/approve/{{app.id}}')">Approve</a>
|
||||||
<a role="button" class="btn btn-secondary mr-0" onclick="post_toast(this,'/admin/app/reject/{{app.id}}')">Reject</a>
|
<a role="button" class="btn btn-secondary mr-0" onclick="post_toast(this,'/admin/app/reject/{{app.id}}')">Reject</a>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Reference in New Issue