Mastodon - Actually honor user's post visibility preference
This commit is contained in:
parent
4504bb9d73
commit
87ddc4b998
4 changed files with 11 additions and 6 deletions
|
|
@ -47,6 +47,9 @@ class User(BaseModel):
|
|||
else:
|
||||
return f"{self.mastodon_username}@{self.mastodon_server}"
|
||||
|
||||
def mastodon_visibility(self):
|
||||
return 'public' if self.mastodon_post_public else 'direct'
|
||||
|
||||
def __str__(self):
|
||||
return self.telegram_username
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import logging
|
||||
|
||||
from settings import MASTODON_INSTANCE, MASTODON_ACCESS_TOKEN, MASTODON_VISIBILITY
|
||||
from settings import MASTODON_INSTANCE, MASTODON_ACCESS_TOKEN
|
||||
|
||||
API_STATUSES = '/api/v1/statuses'
|
||||
API_STATUS_CONTEXT = '/api/v1/statuses/%(id)s/context'
|
||||
|
|
@ -48,13 +48,15 @@ class Mastodon:
|
|||
|
||||
return await response.json()
|
||||
|
||||
async def statusPost(self, status, in_reply_to_id=None):
|
||||
async def statusPost(self, status, user, in_reply_to_id=None):
|
||||
visibility = user.mastodon_visibility()
|
||||
|
||||
return await self.post(
|
||||
self.instance,
|
||||
API_STATUSES,
|
||||
data={
|
||||
'status': status,
|
||||
'visibility': MASTODON_VISIBILITY,
|
||||
'visibility': visibility,
|
||||
'in_reply_to_id': in_reply_to_id
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ async def order_mastodon_post(session, orders_pool, orders_str, repeats, due_at,
|
|||
post += f"ATTN - {user.mastodon_attn_list}\n"
|
||||
|
||||
m = Mastodon(session)
|
||||
return await m.statusPost(post)
|
||||
return await m.statusPost(post, user)
|
||||
|
||||
async def order_telegram_post(session, orders_pool, orders_str, repeats, due_at, m_url, verify_at=None):
|
||||
post = "Here are your orders -\n\n"
|
||||
|
|
@ -140,6 +140,7 @@ async def punishment_mastodon_post(session, orders_pool, punishment_str, reply_i
|
|||
m = Mastodon(session)
|
||||
return await m.statusPost(
|
||||
post,
|
||||
user,
|
||||
in_reply_to_id=reply_id
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ ENV = os.environ.get('ENV', 'dev')
|
|||
|
||||
MASTODON_INSTANCE = os.environ.get("MASTODON_INSTANCE")
|
||||
MASTODON_ACCESS_TOKEN = os.environ.get('MASTODON_ACCESS_TOKEN')
|
||||
MASTODON_VISIBILITY = os.environ.get('MASTODON_VISIBILITY', 'direct')
|
||||
MASTODON_CC_LIST = os.environ.get('MASTODON_CC_LIST', '')
|
||||
|
||||
MASTODON_OAUTH_SCOPES = os.environ.get('MASTODON_OAUTH_SCOPES', 'profile')
|
||||
|
|
|
|||
Loading…
Reference in a new issue