dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 1d833ecbe35cf3b05ad153417c7df949ed2fc7ab
parent 7938d5efb9c36df047f30e24b36e2d4cbf062d9a
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue,  6 Jun 2023 00:46:45 -0700

move code

Diffstat:
Mpkg/web/handlers/api/v1/topBarHandler.go | 34+++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/pkg/web/handlers/api/v1/topBarHandler.go b/pkg/web/handlers/api/v1/topBarHandler.go @@ -1106,6 +1106,23 @@ func convertNewLines(html string, canUseMultiline bool) string { return html } +// Auto convert pasted pgp public key into uploaded file +func convertPGPPublicKeyToFile(db *database.DkfDB, html string, authUserID database.UserID) string { + startIdx := strings.Index(html, pgpPKeyPrefix) + endIdx := strings.Index(html, pgpPKeySuffix) + if startIdx != -1 && endIdx != -1 { + pkeySubSlice := html[startIdx : endIdx+len(pgpPKeySuffix)] + unescapedPkey := html2.UnescapeString(pkeySubSlice) + tmp := convertInlinePGPPublicKey(unescapedPkey) + upload, _ := db.CreateUpload("pgp_pkey.txt", []byte(tmp), authUserID) + msgBefore := html[0:startIdx] + msgAfter := html[endIdx+len(pgpPKeySuffix):] + html = msgBefore + ` [` + upload.GetHTMLLink() + `] ` + msgAfter + html = strings.TrimSpace(html) + } + return html +} + func convertPGPClearsignToFile(db *database.DkfDB, html string, authUserID database.UserID) string { if b, _ := clearsign.Decode([]byte(html)); b != nil { startIdx := strings.Index(html, pgpSignedPrefix) @@ -1141,23 +1158,6 @@ func convertPGPMessageToFile(db *database.DkfDB, html string, authUserID databas return html } -// Auto convert pasted pgp public key into uploaded file -func convertPGPPublicKeyToFile(db *database.DkfDB, html string, authUserID database.UserID) string { - startIdx := strings.Index(html, pgpPKeyPrefix) - endIdx := strings.Index(html, pgpPKeySuffix) - if startIdx != -1 && endIdx != -1 { - pkeySubSlice := html[startIdx : endIdx+len(pgpPKeySuffix)] - unescapedPkey := html2.UnescapeString(pkeySubSlice) - tmp := convertInlinePGPPublicKey(unescapedPkey) - upload, _ := db.CreateUpload("pgp_pkey.txt", []byte(tmp), authUserID) - msgBefore := html[0:startIdx] - msgAfter := html[endIdx+len(pgpPKeySuffix):] - html = msgBefore + ` [` + upload.GetHTMLLink() + `] ` + msgAfter - html = strings.TrimSpace(html) - } - return html -} - // Auto convert pasted age message into uploaded file func convertAgeMessageToFile(db *database.DkfDB, html string, authUserID database.UserID) string { startIdx := strings.Index(html, agePrefix)