add FORCE_CLASSIC_REPOST to disable boost
This commit is contained in:
parent
3bf6957968
commit
92e5bfb833
5 changed files with 31 additions and 16 deletions
|
@ -89,6 +89,7 @@ env = environ.FileAwareEnv(
|
|||
SSL_ONLY=(bool, False),
|
||||
NEODB_SENTRY_DSN=(str, ""),
|
||||
NEODB_FANOUT_LIMIT_DAYS=(int, 9),
|
||||
NEODB_FORCE_CLASSIC_REPOST=(bool, False),
|
||||
)
|
||||
|
||||
# ====== End of user configuration variables ======
|
||||
|
@ -231,6 +232,7 @@ DOWNLOADER_RETRIES = env("NEODB_DOWNLOADER_RETRIES")
|
|||
|
||||
DISABLE_CRON = env("NEODB_DISABLE_CRON")
|
||||
FANOUT_LIMIT_DAYS = env("NEODB_FANOUT_LIMIT_DAYS")
|
||||
FORCE_CLASSIC_REPOST = env("NEODB_FORCE_CLASSIC_REPOST")
|
||||
# ====== USER CONFIGUTRATION END ======
|
||||
|
||||
DATABASE_ROUTERS = ["takahe.db_routes.TakaheRouter"]
|
||||
|
|
|
@ -10,7 +10,7 @@ from oauth2_provider.decorators import protected_resource
|
|||
|
||||
from catalog.common.models import *
|
||||
from common.api import *
|
||||
from mastodon.api import boost_toot_later
|
||||
from mastodon.api import boost_toot_later, share_review
|
||||
|
||||
from .models import Mark, Review, ShelfType, TagManager, q_item_in_category
|
||||
|
||||
|
@ -204,7 +204,10 @@ def review_item(request, item_uuid: str, review: ReviewInSchema):
|
|||
created_time=review.created_time,
|
||||
)
|
||||
if post and review.post_to_fediverse:
|
||||
boost_toot_later(request.user, post.url)
|
||||
if settings.FORCE_CLASSIC_REPOST:
|
||||
share_review(review)
|
||||
else:
|
||||
boost_toot_later(request.user, post.url)
|
||||
return 200, {"message": "OK"}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ from catalog.collection.models import Collection as CatalogCollection
|
|||
from catalog.common import jsondata
|
||||
from catalog.common.models import Item, ItemCategory
|
||||
from catalog.common.utils import DEFAULT_ITEM_COVER, piece_cover_path
|
||||
from mastodon.api import boost_toot_later
|
||||
from mastodon.api import boost_toot_later, share_mark
|
||||
from takahe.utils import Takahe
|
||||
from users.models import APIdentity
|
||||
|
||||
|
@ -236,7 +236,10 @@ class Mark:
|
|||
post = Takahe.post_mark(self, post_as_new) # this will update linked post
|
||||
# async boost to mastodon
|
||||
if post and share_to_mastodon:
|
||||
boost_toot_later(self.owner, post.url)
|
||||
if settings.FORCE_CLASSIC_REPOST:
|
||||
share_mark(self)
|
||||
else:
|
||||
boost_toot_later(self.owner, post.url)
|
||||
return True
|
||||
|
||||
def delete(self):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.exceptions import BadRequest, ObjectDoesNotExist, PermissionDenied
|
||||
from django.http import Http404, HttpRequest, HttpResponse, HttpResponseRedirect
|
||||
|
@ -8,7 +9,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
|
||||
from catalog.models import Item
|
||||
from common.utils import AuthedHttpRequest, get_uuid_or_404
|
||||
from mastodon.api import share_collection
|
||||
from mastodon.api import boost_toot_later, share_collection
|
||||
from users.models import User
|
||||
from users.models.apidentity import APIdentity
|
||||
from users.views import render_user_blocked, render_user_not_found
|
||||
|
@ -120,22 +121,25 @@ def collection_remove_featured(request: AuthedHttpRequest, collection_uuid):
|
|||
|
||||
@login_required
|
||||
def collection_share(request: AuthedHttpRequest, collection_uuid):
|
||||
collection = (
|
||||
get_object_or_404(Collection, uid=get_uuid_or_404(collection_uuid))
|
||||
if collection_uuid
|
||||
else None
|
||||
collection = get_object_or_404(
|
||||
Collection, uid=get_uuid_or_404(collection_uuid) if collection_uuid else None
|
||||
)
|
||||
if collection and not collection.is_visible_to(request.user):
|
||||
raise PermissionDenied()
|
||||
if request.method == "GET":
|
||||
return render(request, "collection_share.html", {"collection": collection})
|
||||
elif request.method == "POST":
|
||||
visibility = int(request.POST.get("visibility", default=0))
|
||||
comment = request.POST.get("comment")
|
||||
if share_collection(collection, comment, request.user, visibility):
|
||||
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
|
||||
if settings.FORCE_CLASSIC_REPOST:
|
||||
visibility = int(request.POST.get("visibility", default=0))
|
||||
comment = request.POST.get("comment")
|
||||
if share_collection(collection, comment, request.user, visibility):
|
||||
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
|
||||
else:
|
||||
return render_relogin(request)
|
||||
else:
|
||||
return render_relogin(request)
|
||||
if collection.latest_post:
|
||||
boost_toot_later(request.user, collection.latest_post)
|
||||
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
|
||||
else:
|
||||
raise BadRequest()
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
from catalog.models import *
|
||||
from common.utils import AuthedHttpRequest, PageLinksGenerator, get_uuid_or_404
|
||||
from journal.models.renderers import convert_leading_space_in_md, render_md
|
||||
from mastodon.api import boost_toot_later
|
||||
from mastodon.api import boost_toot_later, share_review
|
||||
from users.models import User
|
||||
from users.models.apidentity import APIdentity
|
||||
|
||||
|
@ -85,7 +85,10 @@ def review_edit(request: AuthedHttpRequest, item_uuid, review_uuid=None):
|
|||
if not review:
|
||||
raise BadRequest()
|
||||
if form.cleaned_data["share_to_mastodon"] and post:
|
||||
boost_toot_later(request.user, post.url)
|
||||
if settings.FORCE_CLASSIC_REPOST:
|
||||
share_review(review)
|
||||
else:
|
||||
boost_toot_later(request.user, post.url)
|
||||
return redirect(reverse("journal:review_retrieve", args=[review.uuid]))
|
||||
else:
|
||||
raise BadRequest()
|
||||
|
|
Loading…
Add table
Reference in a new issue