implemented the new "buggy attachment" flag for conferences
This commit is contained in:
Vendored
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "auto",
|
"mode": "auto",
|
||||||
"program": "${workspaceFolder}",
|
"program": "${workspaceFolder}",
|
||||||
"args": ["-C", "${workspaceFolder}/test.yaml", "--buggy-attachments"]
|
"args": ["-C", "${workspaceFolder}/test.yaml"]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-1
@@ -107,7 +107,24 @@ func AttachmentSend(ctxt ui.AmContext) (string, any) {
|
|||||||
} else if info == nil {
|
} else if info == nil {
|
||||||
return "error", echo.NewHTTPError(http.StatusNotFound, "attachment not found")
|
return "error", echo.NewHTTPError(http.StatusNotFound, "attachment not found")
|
||||||
}
|
}
|
||||||
data, err := hdr.AttachmentData(ctxt.Ctx(), config.CommandLine.BuggyAttachments)
|
|
||||||
|
// Do we need the buggy-attachment workaround? If it's not selected on the command line, check the
|
||||||
|
// conference flags, which means we need to get the containing conference.
|
||||||
|
bugWorkaround := config.CommandLine.BuggyAttachments
|
||||||
|
if !bugWorkaround {
|
||||||
|
conf, err := database.AmGetConferenceContainingPost(ctxt.Ctx(), postId)
|
||||||
|
if err == nil {
|
||||||
|
flg, err := conf.Flags(ctxt.Ctx())
|
||||||
|
if err == nil {
|
||||||
|
bugWorkaround = flg.Get(database.ConferenceFlagBuggyAttachments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return "error", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := hdr.AttachmentData(ctxt.Ctx(), bugWorkaround)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "error", err
|
return "error", err
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-1
@@ -72,6 +72,7 @@ func EditConferenceForm(ctxt ui.AmContext) (string, any) {
|
|||||||
return "error", err
|
return "error", err
|
||||||
}
|
}
|
||||||
dlg.Field("pic_in_post").SetChecked(flags.Get(database.ConferenceFlagPicturesInPosts))
|
dlg.Field("pic_in_post").SetChecked(flags.Get(database.ConferenceFlagPicturesInPosts))
|
||||||
|
dlg.Field("bugattach").SetChecked(flags.Get(database.ConferenceFlagBuggyAttachments))
|
||||||
return dlg.Render(ctxt)
|
return dlg.Render(ctxt)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +114,7 @@ func EditConference(ctxt ui.AmContext) (string, any) {
|
|||||||
flags, err = conf.Flags(ctxt.Ctx())
|
flags, err = conf.Flags(ctxt.Ctx())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
flags.Set(database.ConferenceFlagPicturesInPosts, dlg.Field("pic_in_post").IsChecked())
|
flags.Set(database.ConferenceFlagPicturesInPosts, dlg.Field("pic_in_post").IsChecked())
|
||||||
|
flags.Set(database.ConferenceFlagBuggyAttachments, dlg.Field("bugattach").IsChecked())
|
||||||
err = conf.SaveFlags(ctxt.Ctx(), flags)
|
err = conf.SaveFlags(ctxt.Ctx(), flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -711,12 +713,22 @@ func ConferenceExport(ctxt ui.AmContext) (string, any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the value of the "bug workaround" flag. If not from the command line, then from the conference flags.
|
||||||
|
bugWorkaround := config.CommandLine.BuggyAttachments
|
||||||
|
if !bugWorkaround {
|
||||||
|
flg, err := conf.Flags(ctxt.Ctx())
|
||||||
|
if err != nil {
|
||||||
|
return "error", err
|
||||||
|
}
|
||||||
|
bugWorkaround = flg.Get(database.ConferenceFlagBuggyAttachments)
|
||||||
|
}
|
||||||
|
|
||||||
// The tricky bit! We use a dedicated goroutine to generate the streamed output and send it to the inlet end of a pipe.
|
// The tricky bit! We use a dedicated goroutine to generate the streamed output and send it to the inlet end of a pipe.
|
||||||
filename := time.Now().Format("exported-data-20060102.xml")
|
filename := time.Now().Format("exported-data-20060102.xml")
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
go func() {
|
go func() {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
err := exports.VCIFStreamTopicFile(context.Background(), w, topics, config.CommandLine.BuggyAttachments)
|
err := exports.VCIFStreamTopicFile(context.Background(), w, topics, bugWorkaround)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("ConferenceExport task failed with %v", err)
|
log.Errorf("ConferenceExport task failed with %v", err)
|
||||||
s := fmt.Sprintf("<!-- ***PROCESSING ERROR*** %v -->\r\n", err)
|
s := fmt.Sprintf("<!-- ***PROCESSING ERROR*** %v -->\r\n", err)
|
||||||
|
|||||||
+22
-1
@@ -98,7 +98,8 @@ const (
|
|||||||
|
|
||||||
// Flag values for conference property index ConferencePropFlags defined.
|
// Flag values for conference property index ConferencePropFlags defined.
|
||||||
const (
|
const (
|
||||||
ConferenceFlagPicturesInPosts = uint(0)
|
ConferenceFlagPicturesInPosts = uint(0) // show pictures in posts
|
||||||
|
ConferenceFlagBuggyAttachments = uint(1) // buggy attachment behavior
|
||||||
)
|
)
|
||||||
|
|
||||||
// conferenceCache is the cache for Conference objects.
|
// conferenceCache is the cache for Conference objects.
|
||||||
@@ -993,6 +994,26 @@ func AmGetConferenceByAlias(ctx context.Context, alias string) (*Conference, err
|
|||||||
return AmGetConference(ctx, confid)
|
return AmGetConference(ctx, confid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* AmGetConferenceContainingPost looks up a post ID and returns the conference containing it.
|
||||||
|
* Parameters:
|
||||||
|
* ctx - Standard Go context value.
|
||||||
|
* postId - The post ID to look up.
|
||||||
|
* Returns:
|
||||||
|
* Pointer to the conference, or nil.
|
||||||
|
* Standard Go error status.
|
||||||
|
*/
|
||||||
|
func AmGetConferenceContainingPost(ctx context.Context, postId int64) (*Conference, error) {
|
||||||
|
row := amdb.QueryRowContext(ctx, "SELECT t.confid FROM topics t, posts p WHERE p.postid = ? AND p.topicid = t.topicid", postId)
|
||||||
|
var confId int32
|
||||||
|
err := row.Scan(&confId)
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return nil, fmt.Errorf("post not found: %d", postId)
|
||||||
|
} else if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return AmGetConference(ctx, confId)
|
||||||
|
}
|
||||||
|
|
||||||
/* AmGetConferenceByAliasInCommunity returns a conference in a community given its alias.
|
/* AmGetConferenceByAliasInCommunity returns a conference in a community given its alias.
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ctx - Standard Go context value.
|
* ctx - Standard Go context value.
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ _(italicized items can be deferred)_
|
|||||||
- Import Messages
|
- Import Messages
|
||||||
- ~~Delete Conference~~
|
- ~~Delete Conference~~
|
||||||
- ~~Add to Hotlist/Remove from Hotlist~~
|
- ~~Add to Hotlist/Remove from Hotlist~~
|
||||||
|
- Actually implement pictures in posts
|
||||||
- Related to bugs in Export Messages caused by bad data:
|
- Related to bugs in Export Messages caused by bad data:
|
||||||
- Provide a per-conference flag that will set BuggyAttachment behavior
|
- ~~Provide a per-conference flag that will set BuggyAttachment behavior~~
|
||||||
- New feature: remove attachment from message (requires Conference.Nuke permission)
|
- New feature: remove attachment from message (requires Conference.Nuke permission)
|
||||||
|
|||||||
@@ -78,6 +78,10 @@ fields:
|
|||||||
name: "pic_in_post"
|
name: "pic_in_post"
|
||||||
caption: "Display users' pictures next to their posts"
|
caption: "Display users' pictures next to their posts"
|
||||||
subcaption: "(user can override)"
|
subcaption: "(user can override)"
|
||||||
|
- type: "checkbox"
|
||||||
|
name: "bugattach"
|
||||||
|
caption: "Buggy attachment behavior"
|
||||||
|
subcaption: "(only used for legacy data)"
|
||||||
- type: "button"
|
- type: "button"
|
||||||
name: "update"
|
name: "update"
|
||||||
caption: "Update"
|
caption: "Update"
|
||||||
|
|||||||
+7
-3
@@ -27,11 +27,15 @@ import (
|
|||||||
* amctxt - The associated AmContext.
|
* amctxt - The associated AmContext.
|
||||||
* command - The type of rendering to be done. Known values are:
|
* command - The type of rendering to be done. Known values are:
|
||||||
* "bytes" - Output "data" as a byte array.
|
* "bytes" - Output "data" as a byte array.
|
||||||
* "redirect" - Treat "data" as a URL to be redirected to and send a 302 Redirect.
|
* "error" - Output the error rendering page.
|
||||||
* "string" - Output "data" as a string.
|
|
||||||
* "template" - Treat "data" as a template name, and output that template.
|
|
||||||
* "framed" - Treat "data" as an inner template name, and output that template rendered
|
* "framed" - Treat "data" as an inner template name, and output that template rendered
|
||||||
* within the outer "frame.jet" template.
|
* within the outer "frame.jet" template.
|
||||||
|
* "ipban" - Output the IP address ban rendering page.
|
||||||
|
* "nocontent" - Output a 204 No Content response.
|
||||||
|
* "redirect" - Treat "data" as a URL to be redirected to and send a 302 Redirect.
|
||||||
|
* "stream" - Treat "data" as an io.Reader and use it to stream data.
|
||||||
|
* "string" - Output "data" as a string.
|
||||||
|
* "template" - Treat "data" as a template name, and output that template.
|
||||||
* data - The data to be output, as determined by the command.
|
* data - The data to be output, as determined by the command.
|
||||||
* Returns:
|
* Returns:
|
||||||
* Standard Go error status.
|
* Standard Go error status.
|
||||||
|
|||||||
Reference in New Issue
Block a user