Aevann 2024-03-03 03:12:39 +02:00
parent fd9398f049
commit b6476da7aa
10 changed files with 31 additions and 19 deletions

View File

@ -85,8 +85,8 @@ def normalize_urls_runtime(body, v):
if v and v.reddit != 'old.reddit.com':
body = reddit_to_vreddit_regex.sub(rf'\1https://{v.reddit}/\2/', body)
if v and v.nitter:
body = twitter_to_nitter_regex.sub(r'\1https://nitter.unixfox.eu/', body)
if v and v.twitter != 'twitter.com':
body = twitter_domain_regex.sub(rf'\1https://{v.twitter}/', body)
if v and v.imgsed:
body = instagram_to_imgsed_regex.sub(r'\1https://imgsed.com/', body)

View File

@ -154,7 +154,7 @@ class User(Base):
offsite_mentions = Column(Boolean)
if SITE_NAME == 'WPD' and not IS_LOCALHOST:
nitter = False
twitter = 'twitter.com'
imgsed = False
controversial = False
reddit = 'old.reddit.com'
@ -164,7 +164,7 @@ class User(Base):
hidevotedon = Column(Boolean, default=False)
hide_cw = Column(Boolean, default=False)
else:
nitter = Column(Boolean, default=False)
twitter = Column(String, default='twitter.com')
imgsed = Column(Boolean, default=False)
controversial = Column(Boolean, default=False)
reddit = Column(String, default='old.reddit.com')

View File

@ -38,9 +38,6 @@ def _archiveorg(url):
def archive_url(url):
gevent.spawn(_archiveorg, url)
if url.startswith('https://twitter.com/'):
url = url.replace('https://twitter.com/', 'https://nitter.unixfox.eu/')
gevent.spawn(_archiveorg, url)
if url.startswith('https://instagram.com/'):
url = url.replace('https://instagram.com/', 'https://imginn.com/')
gevent.spawn(_archiveorg, url)

View File

@ -125,7 +125,7 @@ greentext_regex = re.compile("(\n|^)>([^ >][^\n]*)", flags=re.A)
allowed_domain_regex = re.compile("[a-z0-9\-.]+", flags=re.I|re.A)
twitter_to_nitter_regex = re.compile('(^|>|")https:\/\/twitter.com\/(?!i\/)', flags=re.A)
twitter_domain_regex = re.compile('(^|>|")https:\/\/twitter.com\/(?!i\/)', flags=re.A)
instagram_to_imgsed_regex = re.compile('(^|>|")https:\/\/instagram.com\/(?!reel\/)', flags=re.A)

View File

@ -728,9 +728,6 @@ domain_replacements = {
"https://x.com": "https://twitter.com",
"https://www.twitter.com": "https://twitter.com",
"https://fxtwitter.com": "https://twitter.com",
"https://nitter.net/": "https://twitter.com/",
"https://nitter.42l.fr/": "https://twitter.com/",
"https://nitter.unixfox.eu/": "https://twitter.com/",
"https://m.facebook.com": "https://facebook.com",
"https://en.m.wikipedia.org": "https://en.wikipedia.org",
"https://www.instagram.com": "https://instagram.com",

View File

@ -170,7 +170,6 @@ def settings_personal_post(v):
updated = updated or update_flag("hide_cw", "hide_cw")
updated = updated or update_flag("newtab", "newtab")
updated = updated or update_flag("newtabexternal", "newtabexternal")
updated = updated or update_flag("nitter", "nitter")
updated = updated or update_flag("imgsed", "imgsed")
updated = updated or update_flag("controversial", "controversial")
updated = updated or update_flag("show_sigs", "show_sigs")
@ -1029,6 +1028,20 @@ def settings_pronouns_change(v):
return {"message": "Pronouns successfully updated!"}
@app.post("/settings/twitter")
@limiter.limit('1/second', scope=rpath)
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def settings_twitter(v):
twitter = process_settings_plaintext("twitter", v.twitter, 50, "twitter.com")
v.twitter = twitter
g.db.add(v)
return {"message": "Twitter domain successfully updated!"}
@app.post("/settings/checkmark_text")
@limiter.limit('1/second', scope=rpath)

View File

@ -117,8 +117,10 @@
<section id="site-settings-external-services-section" class="settings-section-section">
<h5>External Services</h5>
<div class="settings-section rounded">
{{common.toggle_section("Use Nitter for Twitter Links", "nitter", "nitter", v.nitter, "Enable if you would like to automatically convert twitter.com links to nitter.unixfox.eu links.", false)}}
{{common.toggle_section("Use imgsed for Instagram Links", "imgsed", "imgsed", v.imgsed, "Enable if you would like to automatically convert instagram.com links to imgsed.com links.", false)}}
{{common.line_text_section('twitter', '/settings/twitter', 'twitter', 'Twitter Domain', v.twitter, 'Limit of 50 characters', 'Change the domain you would like to view twitter posts in.', 'Save', false, 5, 50, '[A-Za-z0-9.-]+', false, 'Change the domain you would like to view twitter posts in.')}}
<div class="d-lg-flex border-bottom">
<div class="title w-lg-25">
<label for="reddit">Reddit Domain</label>

View File

@ -52,10 +52,13 @@
</div>
{% endmacro %}
{% macro line_text_section(id, form_action, form_name, section_title, contents, below_text, placeholder_text, button_text, show_emojis, minlength, maxlength, pattern, disabled) %}
<div class="body d-lg-flex border-bottom">
<label class="text-black w-lg-25">{{section_title}}</label>
<div class="w-lg-100">
{% macro line_text_section(id, form_action, form_name, section_title, contents, below_text, placeholder_text, button_text, show_emojis, minlength, maxlength, pattern, disabled, extra_title) %}
<div class="d-lg-flex border-bottom">
<label class="title text-black w-lg-25">{{section_title}}</label>
<div class="body w-lg-100">
{% if extra_title %}
<p>{{extra_title}}</p>
{% endif %}
<form id="{{id}}-form" action="{{form_action}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
<input hidden name="formkey" value="{{v|formkey}}" class="notranslate" translate="no">
<input minlength={{minlength}} maxlength={{maxlength}} pattern="{{pattern}}" autocomplete="off" id="{{id}}-body" type="text" name="{{form_name}}" class="form-control {% if show_emojis %}allow-emojis{% endif %}" placeholder='{{placeholder_text}}' value="{% if contents %}{{contents}}{% endif %}" {% if disabled %}disabled{% endif %}>

View File

@ -0,0 +1,2 @@
alter table users drop column nitter;
alter table users add column twitter varchar(50) not null default 'twitter.com';

View File

@ -179,7 +179,6 @@ CREATE TABLE public.users (
extra_username character varying(30),
grinch boolean NOT NULL,
last_viewed_modmail_notifs integer NOT NULL,
nitter boolean DEFAULT false NOT NULL,
hole_creation_notifs boolean NOT NULL,
group_creation_notifs boolean NOT NULL,
effortpost_notifs boolean NOT NULL,
@ -3133,4 +3132,3 @@ ALTER TABLE ONLY public.comments
--
-- PostgreSQL database dump complete
--