MCPcopy
hub / github.com/daptin/daptin / MailColumnValue

Method MailColumnValue

server/resource/mail_functions.go:25–44  ·  view source on GitHub ↗
(tableName, columnName string, messageBytes []byte, nameHint string)

Source from the content-addressed store, hash-verified

23const mailMessageFileType = "message/rfc822"
24
25func (dbResource *DbResource) MailColumnValue(tableName, columnName string, messageBytes []byte, nameHint string) interface{} {
26 encoded := base64.StdEncoding.EncodeToString(messageBytes)
27 tableResource := dbResource.Cruds[tableName]
28 if tableResource == nil || tableResource.TableInfo() == nil {
29 return encoded
30 }
31 column, ok := tableResource.TableInfo().GetColumnByName(columnName)
32 if !ok || column == nil || !column.IsForeignKey || column.ForeignKeyData.DataSource != "cloud_store" {
33 return encoded
34 }
35
36 return []interface{}{
37 map[string]interface{}{
38 "name": mailMessageFileName(nameHint, messageBytes),
39 "path": "",
40 "type": mailMessageFileType,
41 "contents": encoded,
42 },
43 }
44}
45
46func (dbResource *DbResource) MailColumnBytes(tableName, columnName string, columnValue interface{}) ([]byte, error) {
47 tableResource := dbResource.Cruds[tableName]

Callers 4

DaptinSmtpDbResourceFunction · 0.80
DoActionMethod · 0.80
CreateMessageMethod · 0.80
CopyMessagesMethod · 0.80

Calls 3

mailMessageFileNameFunction · 0.85
GetColumnByNameMethod · 0.80
TableInfoMethod · 0.65

Tested by

no test coverage detected