Disable scope selection when replying to a direct post
authorr <r@freesoftwareextremist.com>
Thu, 18 Jun 2020 05:02:45 +0000 (05:02 +0000)
committerr <r@freesoftwareextremist.com>
Thu, 18 Jun 2020 05:04:18 +0000 (05:04 +0000)
model/post.go
service/service.go
templates/postform.tmpl

index 58997f770ca9a1f6fb767b08396d6534157d0f08..7cfead79d15c8ff4d4b9cd1c1eae5bb37275cd99 100644 (file)
@@ -13,7 +13,8 @@ type PostContext struct {
 }
 
 type ReplyContext struct {
-       InReplyToID   string
-       InReplyToName string
-       ReplyContent  string
+       InReplyToID     string
+       InReplyToName   string
+       ReplyContent    string
+       ForceVisibility bool
 }
index 2c4f0b00bdfeb1403be67b6344fe07e946c55917..2cc8e5a016c1152d79e3c78db71a75c22f2f7c6d 100644 (file)
@@ -313,12 +313,9 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
                        }
                }
 
-               if c.Session.Settings.CopyScope {
-                       s, err := c.GetStatus(ctx, id)
-                       if err != nil {
-                               return err
-                       }
-                       visibility = s.Visibility
+               isDirect := status.Visibility == "direct" 
+               if isDirect || c.Session.Settings.CopyScope {
+                       visibility = status.Visibility
                } else {
                        visibility = c.Session.Settings.DefaultVisibility
                }
@@ -327,9 +324,10 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
                        DefaultVisibility: visibility,
                        Formats:           svc.postFormats,
                        ReplyContext: &model.ReplyContext{
-                               InReplyToID:   id,
-                               InReplyToName: status.Account.Acct,
-                               ReplyContent:  content,
+                               InReplyToID:     id,
+                               InReplyToName:   status.Account.Acct,
+                               ReplyContent:    content,
+                               ForceVisibility: isDirect,
                        },
                        DarkMode: c.Session.Settings.DarkMode,
                }
@@ -351,7 +349,7 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
                idNumbers[statuses[i].ID] = i + 1
 
                statuses[i].IDReplies = replies
-               addToReplyMap(replies, statuses[i].InReplyToID, statuses[i].ID, i + 1)
+               addToReplyMap(replies, statuses[i].InReplyToID, statuses[i].ID, i+1)
        }
 
        commonData := svc.getCommonData(c, "post by "+status.Account.DisplayName)
index 9c674e9d9e9b0743cce7da4bf3364039eaba5280..3bb245770d48c5d6fe53193c00a743d6dba78086 100644 (file)
@@ -24,7 +24,7 @@
                {{end}}
                <span class="post-form-field">
                        <label for="post-visilibity"> Scope </label>
-                       <select id="post-visilibity" name="visibility">
+                       <select id="post-visilibity" name="visibility" {{if .ReplyContext}}{{if .ReplyContext.ForceVisibility}}disabled{{end}}{{end}}>
                                <option value="public" {{if eq .DefaultVisibility "public"}}selected{{end}}>Public</option>
                                <option value="unlisted" {{if eq .DefaultVisibility "unlisted"}}selected{{end}}>Unlisted</option>
                                <option value="private" {{if eq .DefaultVisibility "private"}}selected{{end}}>Private</option>