Update channel member notify props to use native JSON (#18114)
* Update channel member notify props to use native JSON Created a new store method that patches the notify props field. https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=91d08676-4a0e-4f02-8dce-d24d4fc56449 ```release-note NONE ``` * cleanup ```release-note NONE ``` * forgot to commit ```release-note NONE ``` * Fix edge case ```release-note NONE ``` * address review comments ```release-note NONE ``` * fix incorrect order ```release-note NONE ``` * Address review comments ```release-note NONE ``` Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c4c1fda128
Коммит
7bbcf86531
@@ -89,3 +89,30 @@ func isQuotedWord(s string) bool {
|
||||
|
||||
return s[0] == '"' && s[len(s)-1] == '"'
|
||||
}
|
||||
|
||||
// constructMySQLJSONArgs returns the arg list to pass to a query along with
|
||||
// the string of placeholders which is needed to be to the JSON_SET function.
|
||||
// Use this function in this way:
|
||||
// UPDATE Table
|
||||
// SET Col = JSON_SET(Col, `+argString+`)
|
||||
// WHERE Id=?`, args...)
|
||||
// after appending the Id param to the args slice.
|
||||
func constructMySQLJSONArgs(props map[string]string) ([]interface{}, string) {
|
||||
if len(props) == 0 {
|
||||
return nil, ""
|
||||
}
|
||||
|
||||
// Unpack the keys and values to pass to MySQL.
|
||||
args := make([]interface{}, 0, len(props))
|
||||
for k, v := range props {
|
||||
args = append(args, "$."+k)
|
||||
args = append(args, v)
|
||||
}
|
||||
|
||||
// We calculate the number of ? to set in the query string.
|
||||
argString := strings.Repeat("?, ", len(props)*2)
|
||||
// Strip off the trailing comma.
|
||||
argString = strings.TrimSuffix(strings.TrimSpace(argString), ",")
|
||||
|
||||
return args, argString
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user