Allows to add content warnings when writing a toot

This commit is contained in:
Manuel Cortez 2022-11-11 16:21:15 -06:00
parent 2c298577cc
commit 3a3cb3963c
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
3 changed files with 19 additions and 3 deletions

View File

@ -32,7 +32,9 @@ class toot(messages.basicTweet):
def add_toot(self, event, update_gui=True, *args, **kwargs):
text = self.message.text.GetValue()
attachments = self.attachments[::]
tootdata = dict(text=text, attachments=attachments)
tootdata = dict(text=text, attachments=attachments, sensitive=self.message.sensitive.GetValue(), spoiler_text=None)
if tootdata.get("sensitive") == True:
tootdata.update(spoiler_text=self.message.spoiler.GetValue())
self.thread.append(tootdata)
self.attachments = []
if update_gui:

View File

@ -148,7 +148,7 @@ class Session(base.baseSession):
for obj in toots:
text = obj.get("text")
if len(obj["attachments"]) == 0:
item = self.api_call(call_name="status_post", status=text, _sound="tweet_send.ogg", in_reply_to_id=in_reply_to_id, visibility=visibility)
item = self.api_call(call_name="status_post", status=text, _sound="tweet_send.ogg", in_reply_to_id=in_reply_to_id, visibility=visibility, sensitive=obj["sensitive"], spoiler_text=obj["spoiler_text"])
if item != None:
in_reply_to_id = item["id"]
else:
@ -160,6 +160,6 @@ class Session(base.baseSession):
for i in obj["attachments"]:
img = self.api_call("media_post", media_file=i["file"], description=i["description"])
media_ids.append(img.id)
item = self.api_call(call_name="status_post", status=text, _sound="tweet_send.ogg", in_reply_to_id=in_reply_to_id, media_ids=media_ids, visibility=visibility, poll=poll)
item = self.api_call(call_name="status_post", status=text, _sound="tweet_send.ogg", in_reply_to_id=in_reply_to_id, media_ids=media_ids, visibility=visibility, poll=poll, sensitive=obj["sensitive"], spoiler_text=obj["spoiler_text"])
if item != None:
in_reply_to_id = item["id"]

View File

@ -48,6 +48,17 @@ class Toot(wx.Dialog):
self.visibility.SetSelection(0)
visibility_sizer.Add(self.visibility, 0, 0, 0)
self.add = wx.Button(self, wx.ID_ANY, _("A&dd"))
self.sensitive = wx.CheckBox(self, wx.ID_ANY, _("Sensitive content"))
self.sensitive.SetValue(False)
self.sensitive.Bind(wx.EVT_CHECKBOX, self.on_sensitivity_changed)
main_sizer.Add(self.sensitive, 0, wx.ALL, 5)
spoiler_box = wx.BoxSizer(wx.HORIZONTAL)
spoiler_label = wx.StaticText(self, wx.ID_ANY, _("Content warning"))
self.spoiler = wx.TextCtrl(self, wx.ID_ANY)
self.spoiler.Enable(False)
spoiler_box.Add(spoiler_label, 0, wx.ALL, 5)
spoiler_box.Add(self.spoiler, 0, wx.ALL, 10)
main_sizer.Add(spoiler_box, 0, wx.ALL, 5)
toot_actions_sizer.Add(self.add, 0, 0, 0)
self.add_toot = wx.Button(self, wx.ID_ANY, _("Add t&oot"))
toot_actions_sizer.Add(self.add_toot, 0, 0, 0)
@ -72,6 +83,9 @@ class Toot(wx.Dialog):
self.SetEscapeId(self.close.GetId())
self.Layout()
def on_sensitivity_changed(self, *args, **kwargs):
self.spoiler.Enable(self.sensitive.GetValue())
def set_title(self, chars):
self.SetTitle(_("Toot - {} characters").format(chars))