filter certain types of post

This commit is contained in:
rimu 2024-01-13 18:18:32 +13:00
parent 7c7d0b7a56
commit 1dad787bc4
5 changed files with 21 additions and 4 deletions

View file

@ -5,6 +5,8 @@ When it matures enough, PieFed will aim to work in a way consistent with the [Co
Please discuss your ideas in an issue at https://codeberg.org/rimu/pyfedi/issues before
starting any large pieces of work to ensure alignment with the roadmap, architecture and processes.
Check out [the Matrix chatroom](https://matrix.to/#/#piefed-community:matrix.org).
The general style and philosophy behind the way things have been constructed is well described by
[The Grug Brained Developer](https://grugbrain.dev/). If that page resonates with you then you'll
probably enjoy your time here! The codebase needs to be simple enough that new developers of all
@ -19,8 +21,9 @@ Mailing list, Matrix channel, etc still to come.
- Python
- Flask
- Jinja
- SCSS
- SCSS/SASS
- SQL - Postgresql
- Redis
Python developers with no Flask experience can quickly learn Flask by exploring the
[Flask Mega Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world)

View file

@ -4,7 +4,7 @@ A lemmy/kbin clone written in Python with Flask.
- Clean, simple code that is easy to understand and contribute to. No fancy design patterns or algorithms.
- Easy setup, easy to manage - few dependencies and extra software required.
- GPL.
- AGPL.
- First class moderation tools.
## Project goals

View file

@ -18,6 +18,7 @@ from app.constants import *
from urllib.parse import urlparse
from PIL import Image, ImageOps
from io import BytesIO
import pytesseract
from app.utils import get_request, allowlist_html, html_to_markdown, get_setting, ap_datetime, markdown_to_html, \
is_image_url, domain_from_url, gibberish, ensure_directory_exists, markdown_to_text, head_request, post_ranking, \
@ -551,7 +552,16 @@ def make_image_sizes_async(file_id, thumbnail_width, medium_width, directory):
db.session.commit()
# Alert regarding fascist meme content
text = pytesseract.image_to_string(Image.open(final_place).convert('L'))
if 'Anonymous' in text and ('No.' in text or ' N0' in text): # chan posts usually contain the text 'Anonymous' and ' No.12345'
post = Post.query.filter(image_id=file.id).first()
notification = Notification(title='Review this',
user_id=1,
author_id=post.user_id,
url=url_for('activitypub.post_ap', post_id=post.id))
db.session.add(notification)
db.session.commit()
# create a summary from markdown if present, otherwise use html if available

View file

@ -18,6 +18,8 @@ from app.utils import render_template, get_setting, gibberish, request_etag_matc
ap_datetime, ip_address, retrieve_block_list, shorten_string, markdown_to_text, user_filters_home, \
joined_communities, moderating_communities
from app.models import Community, CommunityMember, Post, Site, User, utcnow, Domain, Topic
from PIL import Image
import pytesseract
@bp.route('/', methods=['HEAD', 'GET', 'POST'])
@ -207,7 +209,8 @@ def robots():
@bp.route('/test')
def test():
return str(current_user.get_id())
return pytesseract.image_to_string(Image.open('test.png').convert('L'))
#ip = request.headers.get('X-Forwarded-For') or request.remote_addr
#if ',' in ip: # Remove all but first ip addresses

View file

@ -29,3 +29,4 @@ feedgen==0.9.0
celery==5.3.6
redis==5.0.1
Werkzeug==2.3.3
pytesseract==0.3.10