|
47 | 47 | constant.MessageTypeAliyunSMS: func() WayValidator { return &WayDetailAliyunSMS{} }, |
48 | 48 | constant.MessageTypeTelegram: func() WayValidator { return &WayDetailTelegram{} }, |
49 | 49 | constant.MessageTypeBark: func() WayValidator { return &WayDetailBark{} }, |
| 50 | + constant.MessageTypePushMe: func() WayValidator { return &WayDetailPushMe{} }, |
50 | 51 | } |
51 | 52 | testerRegistry = map[string]func(interface{}) WayTester{ |
52 | 53 | constant.MessageTypeEmail: func(m interface{}) WayTester { return m.(*WayDetailEmail) }, |
|
59 | 60 | constant.MessageTypeAliyunSMS: func(m interface{}) WayTester { return m.(*WayDetailAliyunSMS) }, |
60 | 61 | constant.MessageTypeTelegram: func(m interface{}) WayTester { return m.(*WayDetailTelegram) }, |
61 | 62 | constant.MessageTypeBark: func(m interface{}) WayTester { return m.(*WayDetailBark) }, |
| 63 | + constant.MessageTypePushMe: func(m interface{}) WayTester { return m.(*WayDetailPushMe) }, |
62 | 64 | } |
63 | 65 | ) |
64 | 66 |
|
@@ -332,6 +334,39 @@ func (w *WayDetailBark) Test() (string, string) { |
332 | 334 | return "", string(res) |
333 | 335 | } |
334 | 336 |
|
| 337 | +// WayDetailPushMe PushMe渠道明细字段 |
| 338 | +type WayDetailPushMe struct { |
| 339 | + PushKey string `json:"push_key" validate:"required,max=100" label:"PushMe Push Key"` |
| 340 | + URL string `json:"url" validate:"max=200" label:"自定义API地址"` |
| 341 | + Date string `json:"date" validate:"max=50" label:"日期"` |
| 342 | + Type string `json:"type" validate:"max=50" label:"类型"` |
| 343 | +} |
| 344 | + |
| 345 | +func (w *WayDetailPushMe) Validate(authJson string) (string, interface{}) { |
| 346 | + var empty interface{} |
| 347 | + err := json.Unmarshal([]byte(authJson), w) |
| 348 | + if err != nil { |
| 349 | + return "PushMe参数反序列化失败!", empty |
| 350 | + } |
| 351 | + _, msg := app.CommonPlaygroundValid(*w) |
| 352 | + return msg, w |
| 353 | +} |
| 354 | + |
| 355 | +func (w *WayDetailPushMe) Test() (string, string) { |
| 356 | + testMsg := "This is a test message from message-nest." |
| 357 | + var cli = message.PushMe{ |
| 358 | + PushKey: w.PushKey, |
| 359 | + URL: w.URL, |
| 360 | + Date: w.Date, |
| 361 | + Type: w.Type, |
| 362 | + } |
| 363 | + res, err := cli.Request("Test Message", testMsg) |
| 364 | + if err != nil { |
| 365 | + return fmt.Sprintf("发送失败:%s", err), res |
| 366 | + } |
| 367 | + return "", res |
| 368 | +} |
| 369 | + |
335 | 370 | func (sw *SendWay) GetByID() (interface{}, error) { |
336 | 371 | return models.GetWayByID(sw.ID) |
337 | 372 | } |
|
0 commit comments