Merge pull request #52 from DmitryZagorulko/master
replace markdown symbols
This commit is contained in:
commit
f2ee467ee0
@ -6,10 +6,10 @@ import "time"
|
|||||||
type Connection struct {
|
type Connection struct {
|
||||||
ID int `gorm:"primary_key"`
|
ID int `gorm:"primary_key"`
|
||||||
ClientID string `gorm:"client_id type:varchar(70);not null;unique" json:"clientId,omitempty"`
|
ClientID string `gorm:"client_id type:varchar(70);not null;unique" json:"clientId,omitempty"`
|
||||||
APIKEY string `gorm:"api_key type:varchar(100);not null" json:"api_key,omitempty" binding:"required"`
|
APIKEY string `gorm:"api_key type:varchar(100);not null" json:"api_key,omitempty" binding:"required,max=100"`
|
||||||
APIURL string `gorm:"api_url type:varchar(255);not null" json:"api_url,omitempty" binding:"required,validatecrmurl"`
|
APIURL string `gorm:"api_url type:varchar(255);not null" json:"api_url,omitempty" binding:"required,validatecrmurl,max=255"`
|
||||||
MGURL string `gorm:"mg_url type:varchar(255);not null;" json:"mg_url,omitempty"`
|
MGURL string `gorm:"mg_url type:varchar(255);not null;" json:"mg_url,omitempty" binding:"max=255"`
|
||||||
MGToken string `gorm:"mg_token type:varchar(100);not null;unique" json:"mg_token,omitempty"`
|
MGToken string `gorm:"mg_token type:varchar(100);not null;unique" json:"mg_token,omitempty" binding:"max=100"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
Active bool `json:"active,omitempty"`
|
Active bool `json:"active,omitempty"`
|
||||||
@ -21,10 +21,10 @@ type Bot struct {
|
|||||||
ID int `gorm:"primary_key"`
|
ID int `gorm:"primary_key"`
|
||||||
ConnectionID int `gorm:"connection_id" json:"connectionId,omitempty"`
|
ConnectionID int `gorm:"connection_id" json:"connectionId,omitempty"`
|
||||||
Channel uint64 `gorm:"channel;not null;unique" json:"channel,omitempty"`
|
Channel uint64 `gorm:"channel;not null;unique" json:"channel,omitempty"`
|
||||||
ChannelSettingsHash string `gorm:"channel_settings_hash type:varchar(70)"`
|
ChannelSettingsHash string `gorm:"channel_settings_hash type:varchar(70)" binding:"max=70"`
|
||||||
Token string `gorm:"token type:varchar(100);not null;unique" json:"token,omitempty"`
|
Token string `gorm:"token type:varchar(100);not null;unique" json:"token,omitempty" binding:"max=100"`
|
||||||
Name string `gorm:"name type:varchar(40)" json:"name,omitempty"`
|
Name string `gorm:"name type:varchar(40)" json:"name,omitempty" binding:"max=40"`
|
||||||
Lang string `gorm:"lang type:varchar(2)" json:"lang,omitempty"`
|
Lang string `gorm:"lang type:varchar(2)" json:"lang,omitempty" binding:"max=2"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
@ -33,8 +33,8 @@ type Bot struct {
|
|||||||
type User struct {
|
type User struct {
|
||||||
ID int `gorm:"primary_key"`
|
ID int `gorm:"primary_key"`
|
||||||
ExternalID int `gorm:"external_id;not null;unique"`
|
ExternalID int `gorm:"external_id;not null;unique"`
|
||||||
UserPhotoURL string `gorm:"user_photo_url type:varchar(255)"`
|
UserPhotoURL string `gorm:"user_photo_url type:varchar(255)" binding:"max=255"`
|
||||||
UserPhotoID string `gorm:"user_photo_id type:varchar(100)"`
|
UserPhotoID string `gorm:"user_photo_id type:varchar(100)" binding:"max=100"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
@ -591,7 +591,7 @@ func mgWebhookHandler(c *gin.Context) {
|
|||||||
var mb string
|
var mb string
|
||||||
switch msg.Data.Type {
|
switch msg.Data.Type {
|
||||||
case v1.MsgTypeProduct:
|
case v1.MsgTypeProduct:
|
||||||
mb = fmt.Sprintf("*%s*\n", msg.Data.Product.Name)
|
mb = fmt.Sprintf("*%s*\n", replaceMarkdownSymbols(msg.Data.Product.Name))
|
||||||
|
|
||||||
if msg.Data.Product.Cost != nil && msg.Data.Product.Cost.Value != 0 {
|
if msg.Data.Product.Cost != nil && msg.Data.Product.Cost.Value != 0 {
|
||||||
mb += fmt.Sprintf(
|
mb += fmt.Sprintf(
|
||||||
@ -608,9 +608,9 @@ func mgWebhookHandler(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if msg.Data.Product.Url != "" {
|
if msg.Data.Product.Url != "" {
|
||||||
mb += msg.Data.Product.Url
|
mb += replaceMarkdownSymbols(msg.Data.Product.Url)
|
||||||
} else {
|
} else {
|
||||||
mb += msg.Data.Product.Img
|
mb += replaceMarkdownSymbols(msg.Data.Product.Img)
|
||||||
}
|
}
|
||||||
case v1.MsgTypeOrder:
|
case v1.MsgTypeOrder:
|
||||||
mb = getOrderMessage(msg.Data.Order)
|
mb = getOrderMessage(msg.Data.Order)
|
||||||
@ -678,7 +678,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
|
|||||||
mb := "*" + getLocalizedMessage("order")
|
mb := "*" + getLocalizedMessage("order")
|
||||||
|
|
||||||
if dataOrder.Number != "" {
|
if dataOrder.Number != "" {
|
||||||
mb += " " + dataOrder.Number
|
mb += " " + replaceMarkdownSymbols(dataOrder.Number)
|
||||||
}
|
}
|
||||||
|
|
||||||
if dataOrder.Date != "" {
|
if dataOrder.Date != "" {
|
||||||
@ -691,7 +691,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
|
|||||||
mb += fmt.Sprintf(
|
mb += fmt.Sprintf(
|
||||||
"%d. %s",
|
"%d. %s",
|
||||||
k+1,
|
k+1,
|
||||||
v.Name,
|
replaceMarkdownSymbols(v.Name),
|
||||||
)
|
)
|
||||||
|
|
||||||
if v.Quantity != nil {
|
if v.Quantity != nil {
|
||||||
@ -727,7 +727,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
|
|||||||
mb += fmt.Sprintf(
|
mb += fmt.Sprintf(
|
||||||
"\n*%s:*\n%s",
|
"\n*%s:*\n%s",
|
||||||
getLocalizedMessage("delivery"),
|
getLocalizedMessage("delivery"),
|
||||||
dataOrder.Delivery.Name,
|
replaceMarkdownSymbols(dataOrder.Delivery.Name),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,7 +747,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if dataOrder.Delivery.Address != "" {
|
if dataOrder.Delivery.Address != "" {
|
||||||
mb += ";\n" + dataOrder.Delivery.Address
|
mb += ";\n" + replaceMarkdownSymbols(dataOrder.Delivery.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
mb += "\n"
|
mb += "\n"
|
||||||
@ -759,7 +759,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
|
|||||||
getLocalizedMessage("payment"),
|
getLocalizedMessage("payment"),
|
||||||
)
|
)
|
||||||
for _, v := range dataOrder.Payments {
|
for _, v := range dataOrder.Payments {
|
||||||
mb += v.Name
|
mb += replaceMarkdownSymbols(v.Name)
|
||||||
|
|
||||||
if v.Amount != nil {
|
if v.Amount != nil {
|
||||||
if val, ok := currency[strings.ToLower(v.Amount.Currency)]; ok && v.Amount.Value != 0 {
|
if val, ok := currency[strings.ToLower(v.Amount.Currency)]; ok && v.Amount.Value != 0 {
|
||||||
@ -779,7 +779,7 @@ func getOrderMessage(dataOrder *v1.MessageDataOrder) string {
|
|||||||
if v.Status != nil && v.Status.Name != "" {
|
if v.Status != nil && v.Status.Name != "" {
|
||||||
mb += fmt.Sprintf(
|
mb += fmt.Sprintf(
|
||||||
" (%s)",
|
" (%s)",
|
||||||
v.Status.Name,
|
replaceMarkdownSymbols(v.Status.Name),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ var (
|
|||||||
"/api/integration-modules/{code}",
|
"/api/integration-modules/{code}",
|
||||||
"/api/integration-modules/{code}/edit",
|
"/api/integration-modules/{code}/edit",
|
||||||
}
|
}
|
||||||
|
markdownSymbols = []string{"*", "_", "`", "["}
|
||||||
)
|
)
|
||||||
|
|
||||||
// GenerateToken function
|
// GenerateToken function
|
||||||
@ -133,3 +134,11 @@ func getChannelSettingsHash() (hash string, err error) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func replaceMarkdownSymbols(s string) string {
|
||||||
|
for _, v := range markdownSymbols {
|
||||||
|
s = strings.Replace(s, v, "\\"+v, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
<input name="clientId" type="hidden" value="{{.Conn.ClientID}}">
|
<input name="clientId" type="hidden" value="{{.Conn.ClientID}}">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<input placeholder="CRM Url" id="api_url" name="api_url" type="text" class="validate" value="{{.Conn.APIURL}}">
|
<input placeholder="CRM Url" id="api_url" name="api_url" type="text" class="validate" value="{{.Conn.APIURL}}" maxlength="255">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<input placeholder="{{.Locale.ApiKey}}" id="api_key" name="api_key" type="text" class="validate" value="{{.Conn.APIKEY}}">
|
<input placeholder="{{.Locale.ApiKey}}" id="api_key" name="api_key" type="text" class="validate" value="{{.Conn.APIKEY}}" maxlength="100">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -40,7 +40,7 @@
|
|||||||
<input name="connectionId" type="hidden" value="{{.Conn.ID}}">
|
<input name="connectionId" type="hidden" value="{{.Conn.ID}}">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<input placeholder="{{.Locale.TableToken}}" id="token" name="token" type="text" class="validate">
|
<input placeholder="{{.Locale.TableToken}}" id="token" name="token" type="text" class="validate" maxlength="100">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
<div id="msg"></div>
|
<div id="msg"></div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<input placeholder="CRM Url" id="api_url" name="api_url" type="text" class="validate"
|
<input placeholder="CRM Url" id="api_url" name="api_url" type="text" class="validate" maxlength="255"
|
||||||
{{if .Conn.APIURL}} value="{{.Conn.APIURL}}" {{end}}>
|
{{if .Conn.APIURL}} value="{{.Conn.APIURL}}" {{end}}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="input-field col s12">
|
<div class="input-field col s12">
|
||||||
<input placeholder="{{.Locale.ApiKey}}" id="api_key" name="api_key" type="text" class="validate">
|
<input placeholder="{{.Locale.ApiKey}}" id="api_key" name="api_key" type="text" class="validate" maxlength="100">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
Loading…
Reference in New Issue
Block a user