Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,62 @@
|
|
| 1 |
from mastodon import Mastodon # Mastodon.py
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
# A HTML blob of text used to define the 'login in with' button
|
| 4 |
auth_button_text = '''<a href="{}"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
|
| 5 |
<i class=""></i> Login with Mastodon! 🐘
|
| 6 |
</button></a><br>'''
|
| 7 |
|
| 8 |
|
|
|
|
| 9 |
def client_log_in():
|
| 10 |
'''
|
| 11 |
Generates an authenticated Masterdon client for the admin user. Used for retireving the target website URL
|
|
@@ -13,28 +64,14 @@ def client_log_in():
|
|
| 13 |
'''
|
| 14 |
|
| 15 |
# Setup a 'secret' file used for persisting session between requests.
|
| 16 |
-
secret_file = open("ivory-secret.txt", "w")
|
| 17 |
-
secret_file.write("{}\n".format(os.getenv('app_secret_1')))
|
| 18 |
-
secret_file.write("{}\n".format(os.getenv('app_secret_2')))
|
| 19 |
-
secret_file.write("https://infosec.exchange\n")
|
| 20 |
-
secret_file.write("WatchTower | Ivory")
|
| 21 |
-
secret_file.close()
|
| 22 |
|
| 23 |
mastodon = Mastodon(
|
| 24 |
-
client_id="
|
| 25 |
api_base_url='https://infosec.exchange'
|
| 26 |
)
|
| 27 |
|
| 28 |
-
mastodon.log_in(
|
| 29 |
-
os.getenv('username'),
|
| 30 |
-
os.getenv('password'),
|
| 31 |
-
scopes=["write:blocks", "write:mutes"],
|
| 32 |
-
redirect_uri="https://user1342-ivory.hf.space/",
|
| 33 |
-
)
|
| 34 |
-
|
| 35 |
return mastodon
|
| 36 |
|
| 37 |
-
|
| 38 |
def get_auth_url(mastodon):
|
| 39 |
'''
|
| 40 |
Retrieves a URL for the user to visit to auth them with WatchTower.
|
|
@@ -350,6 +387,7 @@ with block:
|
|
| 350 |
value=auth_button_text.format(
|
| 351 |
get_target_website())).style(
|
| 352 |
)
|
|
|
|
| 353 |
with gr.Row().style(equal_height=True):
|
| 354 |
radio = gr.CheckboxGroup(value=["Violent", "Hate Speech"],
|
| 355 |
choices=["Violent", "Hate Speech", "Misinformation"],
|
|
|
|
| 1 |
from mastodon import Mastodon # Mastodon.py
|
| 2 |
|
| 3 |
+
list_of_servers = [
|
| 4 |
+
"mastodon.social",
|
| 5 |
+
"peoplemaking.games"
|
| 6 |
+
"maly.io"
|
| 7 |
+
"ani.work"
|
| 8 |
+
"libretooth.gr"
|
| 9 |
+
"tilde.zone"
|
| 10 |
+
"pettingzoo.co"
|
| 11 |
+
"phpc.social"
|
| 12 |
+
"hostux.social"
|
| 13 |
+
"activism.openworlds.info"
|
| 14 |
+
"metalhead.club"
|
| 15 |
+
"x0r.be"
|
| 16 |
+
"mathstodon.xyz"
|
| 17 |
+
"indieweb.social"
|
| 18 |
+
"social.linux.pizza"
|
| 19 |
+
"lor.sh"
|
| 20 |
+
"nerdculture.de"
|
| 21 |
+
"toot.wales"
|
| 22 |
+
"kolektiva.social"
|
| 23 |
+
"mastodon.pirateparty.be"
|
| 24 |
+
"socel.net"
|
| 25 |
+
"mastodon.nz"
|
| 26 |
+
"toot.funami.tech"
|
| 27 |
+
"noc.social"
|
| 28 |
+
"seo.chat"
|
| 29 |
+
"ioc.exchange"
|
| 30 |
+
"qoto.org"
|
| 31 |
+
"glasgow.social"
|
| 32 |
+
"primarycare.app"
|
| 33 |
+
"mindly.social"
|
| 34 |
+
"mstdn.party"
|
| 35 |
+
"universeodon.com"
|
| 36 |
+
"learningdisability.social"
|
| 37 |
+
"ravenation.club"
|
| 38 |
+
"home.social"
|
| 39 |
+
"mastodon.ie"
|
| 40 |
+
"techhub.social"
|
| 41 |
+
"mastodon.scot"
|
| 42 |
+
"sfba.social"
|
| 43 |
+
"mastodon.sdf.org"
|
| 44 |
+
"fosstodon.org"
|
| 45 |
+
"mastodon.lol"
|
| 46 |
+
"mastodonapp.uk"
|
| 47 |
+
"mstdn.social"
|
| 48 |
+
"mas.to"
|
| 49 |
+
"newsie.social"
|
| 50 |
+
"social.bau-ha.us"
|
| 51 |
+
"infosec.exchange"]
|
| 52 |
+
|
| 53 |
# A HTML blob of text used to define the 'login in with' button
|
| 54 |
auth_button_text = '''<a href="{}"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
|
| 55 |
<i class=""></i> Login with Mastodon! 🐘
|
| 56 |
</button></a><br>'''
|
| 57 |
|
| 58 |
|
| 59 |
+
|
| 60 |
def client_log_in():
|
| 61 |
'''
|
| 62 |
Generates an authenticated Masterdon client for the admin user. Used for retireving the target website URL
|
|
|
|
| 64 |
'''
|
| 65 |
|
| 66 |
# Setup a 'secret' file used for persisting session between requests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
mastodon = Mastodon(
|
| 69 |
+
client_id="irrelevant-secret.txt",
|
| 70 |
api_base_url='https://infosec.exchange'
|
| 71 |
)
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
return mastodon
|
| 74 |
|
|
|
|
| 75 |
def get_auth_url(mastodon):
|
| 76 |
'''
|
| 77 |
Retrieves a URL for the user to visit to auth them with WatchTower.
|
|
|
|
| 387 |
value=auth_button_text.format(
|
| 388 |
get_target_website())).style(
|
| 389 |
)
|
| 390 |
+
gr.Dropdown(choices=list_of_servers)
|
| 391 |
with gr.Row().style(equal_height=True):
|
| 392 |
radio = gr.CheckboxGroup(value=["Violent", "Hate Speech"],
|
| 393 |
choices=["Violent", "Hate Speech", "Misinformation"],
|