WeiXinPush . @author itning @since 2021-05-06 18:10
| 15 | * @since 2021-05-06 18:10 |
| 16 | **/ |
| 17 | public class WeComPush extends AbstractPush { |
| 18 | |
| 19 | @Override |
| 20 | protected String generatePushUrl(PushMetaInfo metaInfo) { |
| 21 | return ApiList.WECHAT_PUSH + metaInfo.getToken(); |
| 22 | } |
| 23 | |
| 24 | @Override |
| 25 | protected boolean checkPushStatus(JsonObject jsonObject) { |
| 26 | if (jsonObject == null) { |
| 27 | return false; |
| 28 | } |
| 29 | JsonElement errcode = jsonObject.get("errcode"); |
| 30 | JsonElement errmsg = jsonObject.get("errmsg"); |
| 31 | if (null == errcode || null == errmsg) { |
| 32 | return false; |
| 33 | } |
| 34 | return errcode.getAsInt() == 0 && "ok".equals(errmsg.getAsString()); |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | protected String generatePushBody(PushMetaInfo metaInfo, String content) { |
| 39 | return new Gson().toJson(new MessageModel(content)); |
| 40 | } |
| 41 | |
| 42 | @Getter |
| 43 | static class MessageModel { |
| 44 | private final String msgtype = "markdown"; |
| 45 | private final Markdown markdown; |
| 46 | |
| 47 | public MessageModel(String content) { |
| 48 | this.markdown = new Markdown(content); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | @Getter |
| 53 | static class Markdown { |
| 54 | private final String content; |
| 55 | |
| 56 | public Markdown(String content) { |
| 57 | this.content = content.replaceAll("\r\n\r", ""); |
| 58 | } |
| 59 | } |
| 60 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…