{"id":517,"date":"2016-08-11T16:48:26","date_gmt":"2016-08-11T08:48:26","guid":{"rendered":"http:\/\/julyclyde.org\/?p=517"},"modified":"2016-08-11T18:01:04","modified_gmt":"2016-08-11T10:01:04","slug":"sentry-%e5%85%ac%e5%8f%b8%e5%86%85im%e6%8f%92%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/julyclyde.org\/?p=517","title":{"rendered":"sentry-\u516c\u53f8\u5185IM\u63d2\u4ef6"},"content":{"rendered":"<p>\u8fd9\u63d2\u4ef6\u88ab\u5927\u5bb6\u50ac\u4e86\u5f88\u4e45\u4e86\uff0c\u52301\u6708\u5e95\u7ec8\u4e8e\u51b3\u5b9a\u52a8\u624b\u505a\u3002<\/p>\n<h1 id=\"sentry-daxiang\u63d2\u4ef6-\u51c6\u5907\u77e5\u8bc6\">\u51c6\u5907\u77e5\u8bc6<\/h1>\n<p>\u516c\u4f17\u53f7Pub\u670d\u52a1API\uff08\u5185\u7f51wiki\uff0c\u94fe\u63a5\u5df2\u5220\u9664\uff09<\/p>\n<p>\u7b7e\u540d\u8bf7\u6c42\u89c4\u8303\uff08\u5185\u7f51wiki\uff0c\u94fe\u63a5\u5df2\u5220\u9664\uff09<\/p>\n<p><a class=\"external-link\" href=\"http:\/\/docs.python-requests.org\/en\/latest\/user\/authentication\/#new-forms-of-authentication\" target=\"_blank\" rel=\"nofollow\">New Forms of Authentication<\/a><\/p>\n<h1 id=\"sentry-daxiang\u63d2\u4ef6-\u63d2\u4ef6\u7ec4\u6210\">\u63d2\u4ef6\u7ec4\u6210<\/h1>\n<ul>\n<li>setup.py \u5b89\u88c5\u811a\u672c\u3002<a href=\"https:\/\/julyclyde.org\/?p=515\">\u63d2\u4ef6\u6ce8\u518c\u53d1\u73b0\u673a\u5236\u8bf7\u53c2\u89c1<\/a><\/li>\n<li>sentry_IM\/__init__.py \u786e\u4fdd\u8fd9\u4e2a\u76ee\u5f55\u662fpython package\u7684\u6587\u4ef6\u3002\u987a\u4fbf\u67e5\u8be2\u4e00\u4e0bVERSION\u4f9b\u5f15\u7528<\/li>\n<li>sentry_IM\/requests_APISign.py \u4e0a\u8ff0New Forms of Authentication\u6587\u6863\u91cc\u63d0\u5230\u7684requests auth class\uff0c\u63d0\u4f9b\u516c\u53f8\u7684Authencation\u9a8c\u8bc1header<\/li>\n<li>sentry_IM\/send_IM.py \u53d1\u6d88\u606f\u7528\u7684Class<\/li>\n<li>sentry_IM\/plugin.py \u63d2\u4ef6\u672c\u8eab<\/li>\n<\/ul>\n<h1 id=\"sentry-daxiang\u63d2\u4ef6-\u7a0b\u5e8f\u8bb2\u89e3\">\u7a0b\u5e8f\u8bb2\u89e3<\/h1>\n<p>\u63d2\u4ef6\u672c\u8eab\u7ee7\u627f\u81easentry.plugins.bases.notify.NotificationPlugin\u7c7b\uff0c\u9700\u8981\u5b9e\u73b0\u5176notify(self, notification)\u65b9\u6cd5\u3002\u56e0\u57fa\u7c7b\u91ccnotify()\u8c03\u7528\u4e86notify_users()\uff0c\u6240\u4ee5pylint\u4f1a\u6709\u63d0\u793a\u3002<\/p>\n<p>\u53c2\u6570notification\u4e3a\u4e00\u4e2a\u5bf9\u8c61\uff0c\u53ef\u4ee5\u4ece\u4e2d\u53d6\u5f97event\uff0c\u7136\u540e\u4eceevent\u53d6\u5f97\u6240\u5c5e\u7684group\u4ee5\u53cagroup\u6240\u5c5e\u7684project\u3002\u6839\u636eproject\u53ef\u4ee5\u53d6\u5f97\u8981\u901a\u77e5\u7684\u4eba\u5458\u5217\u8868\u3002\uff08\u8fd9\u91cc\u6284\u88ad\u4e86MailPlugin\u7684\u53d1\u9001\u5217\u8868\uff09\u56e0\u4e3a\u8fd9\u4e2a\u51fd\u6570\u5f97\u5230\u7684\u4eba\u5458\u5217\u8868\u662fSentry\u91cc\u7684User id\uff0c\u6240\u4ee5\u8fd8\u9700\u8981\u518d\u6839\u636eid\u67e5\u8be2\u5230User\uff0c\u7136\u540e\u4ece\u5176Email\u5b57\u6bb5\u4e2d\u53d6\u5f97localpart<\/p>\n<p>\u6700\u540e\uff0c\u6839\u636e\u4e0a\u8ff0project.name\u3001event.message\u3001group.get_absolute_url() \u7ec4\u88c5\u5176\u901a\u77e5\u6d88\u606f\u6587\u672c\uff08URL\u5728IM\u5ba2\u6237\u7aef\u6e32\u67d3\u65f6\u624d\u53d8\u6210\u8d85\u94fe\u63a5\uff0c\u6211\u8fd9\u91cc\u53ea\u53d1URL\u672c\u8eab\uff09\uff0c\u751f\u6210send_IM.py \u7684\u5b9e\u4f8b\uff0c\u5bf9\u7740\u4e0a\u8ff0\u4eba\u5458\u5217\u8868\u53d1\u9001\u6d88\u606f\u6587\u672c\u3002<\/p>\n<p>IM\u63d2\u4ef6\u6240\u9700\u7684\u56db\u4e2a\u53c2\u6570\uff0c\u5728\u603b\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u5217\u51fa\uff0c\u7531\u63d2\u4ef6\u751f\u6210send_IM\u5b9e\u4f8b\u65f6\u4f20\u9012\uff0c\u7136\u540e\u7531\u5176\u4f20\u9012\u7ed9requests_APISign\u7684\u5b9e\u4f8b\uff0c\u5b8c\u6210\u5bf9HTTP\u8bf7\u6c42\u7684\u7b7e\u540d<\/p>\n<h1 id=\"sentry-daxiang\u63d2\u4ef6-\u914d\u7f6e\u662f\u5426\u5f00\u542f\">\u914d\u7f6e\u662f\u5426\u5f00\u542f<\/h1>\n<p>\u672c\u6765\u662f\u60f3\u50cfMailPlugin\u90a3\u6837\u76f4\u63a5\u5728Account\/Notification\u9875\u505a\u4e2a\u5217\u8868\u4f9b\u52fe\u9009\u3002\u4f46\u9605\u8bfb\u4ee3\u7801\u53d1\u73b0\uff0c\u8fd9\u4e2a\u529f\u80fd\u5e76\u4e0d\u662fMailPlugin\u81ea\u5df1\u7684\u529f\u80fd\uff0c\u800c\u662fsentry\u505a\u4e86\u7279\u6b8a\u5904\u7406\uff0c<a class=\"external-link\" href=\"https:\/\/github.com\/getsentry\/sentry\/blob\/7.7.0\/src\/sentry\/web\/frontend\/accounts.py#L244-L259\" target=\"_blank\" rel=\"nofollow\">\u5148\u83b7\u5f97\u7528\u6237\u8ba2\u9605\u7684projects_list<\/a>\uff0c\u7136\u540e<a class=\"external-link\" href=\"https:\/\/github.com\/getsentry\/sentry\/blob\/7.7.0\/src\/sentry\/web\/frontend\/accounts.py#L261-L268\" target=\"_blank\" rel=\"nofollow\">\u5faa\u73af\u751f\u6210ProjectEmailOptionsForm\u7684list<\/a>\uff0c\u968f\u540e<a class=\"external-link\" href=\"https:\/\/github.com\/getsentry\/sentry\/blob\/7.7.0\/src\/sentry\/web\/frontend\/accounts.py#L270-L276\" target=\"_blank\" rel=\"nofollow\">\u518d\u6267\u884c\u4ece\u5404\u63d2\u4ef6\u83b7\u53d6\u7684ext_forms[]\u914d\u7f6e\u8868\u5355<\/a>\u3002ext_forms\u91cc\u6bcf\u4e00\u4e2a\u63d2\u4ef6\u914d\u7f6e\u8868\u5355\u7684\u521d\u59cb\u5316\u53c2\u6570\u53ea\u6709plugin\u3001user\u548cprefix\uff0c\u8981\u60f3\u8868\u8fbe\u201c\u6240\u6709\u53ef\u8ba2\u9605\u7684projects\u201d\u8fd9\u4e2a\u6982\u5ff5\u4f1a\u76f8\u5f53\u5570\u55e6\u3002\u56e0\u6b64\uff0c\u6700\u7ec8\u786e\u5b9a\u4e3a\uff1a\u8868\u5355\u91cc\u53ea\u52fe\u9009per-User \u7ea7\u522b\u662f\u5426\u5f00\u542f\uff1b\u800c\u7528\u6237\u662f\u5426\u5c5e\u4e8e\u5177\u4f53\u67d0\u4e2aevent\/project\u7684\u53d1\u9001\u76ee\u6807\uff0c\u5219\u76f4\u63a5\u5171\u7528MailPlugin\u90a3\u8fb9\u7684\u9009\u62e9\uff0c\u7136\u540e\u518d\u7528\u4e0a\u8ff0per-User\u7ea7\u522b\u5f00\u5173\u505a\u4e00\u904d\u8fc7\u6ee4\u3002\u8fd9\u91cc\u4e24\u4e2a\u63d2\u4ef6\u4e4b\u95f4\u7565\u6709\u7c98\u8fde\uff0c\u4e3b\u8981\u662f\u7531\u4e8eUser-Project\u4e4b\u95f4\u53ea\u6709\u5355\u5411\u5bf9\u5e94\u5173\u7cfb\uff0c\u9006\u5411\u67e5\u8be2\u592a\u7f57\u55e6\u5bfc\u81f4\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-519\" src=\"https:\/\/julyclyde.org\/wordpress\/wp-content\/uploads\/2016\/08\/image2016-2-3-16-17-40.png\" alt=\"image2016-2-3 16-17-40\" width=\"606\" height=\"237\" srcset=\"https:\/\/julyclyde.org\/wordpress\/wp-content\/uploads\/2016\/08\/image2016-2-3-16-17-40.png 606w, https:\/\/julyclyde.org\/wordpress\/wp-content\/uploads\/2016\/08\/image2016-2-3-16-17-40-300x117.png 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/p>\n<h1 id=\"sentry-daxiang\u63d2\u4ef6-\u6700\u7ec8\u53d1\u9001\u6548\u679c\">\u6700\u7ec8\u53d1\u9001\u6548\u679c<\/h1>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-518\" src=\"https:\/\/julyclyde.org\/wordpress\/wp-content\/uploads\/2016\/08\/image2016-2-3-16-19-56.png\" alt=\"image2016-2-3 16-19-56\" width=\"481\" height=\"164\" srcset=\"https:\/\/julyclyde.org\/wordpress\/wp-content\/uploads\/2016\/08\/image2016-2-3-16-19-56.png 481w, https:\/\/julyclyde.org\/wordpress\/wp-content\/uploads\/2016\/08\/image2016-2-3-16-19-56-300x102.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/p>\n<p>Github\u5730\u5740\u00a0<a href=\"https:\/\/github.com\/julyclyde\/sentry-IM\">https:\/\/github.com\/julyclyde\/sentry-IM<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u63d2\u4ef6\u88ab\u5927\u5bb6\u50ac\u4e86\u5f88\u4e45\u4e86\uff0c\u52301\u6708\u5e95\u7ec8\u4e8e\u51b3\u5b9a\u52a8\u624b\u505a\u3002 \u51c6\u5907\u77e5\u8bc6 \u516c\u4f17\u53f7Pub\u670d\u52a1API\uff08\u5185\u7f51wiki\uff0c\u94fe\u63a5\u5df2\u5220\u9664\uff09 \u7b7e\u540d\u8bf7\u6c42\u89c4\u8303\uff08\u5185\u7f51wiki\uff0c\u94fe\u63a5\u5df2\u5220\u9664\uff09 New Forms of Authentication \u63d2\u4ef6\u7ec4\u6210 setup.py \u5b89\u88c5\u811a\u672c\u3002\u63d2\u4ef6\u6ce8\u518c\u53d1\u73b0\u673a\u5236\u8bf7\u53c2\u89c1 sentry_IM\/__init__.py \u786e\u4fdd\u8fd9\u4e2a\u76ee\u5f55\u662fpython package\u7684\u6587\u4ef6\u3002\u987a\u4fbf\u67e5\u8be2\u4e00\u4e0bVERSION\u4f9b\u5f15\u7528 sentry_IM\/requests_APISign.py \u4e0a\u8ff0New Forms of Authentication\u6587\u6863\u91cc\u63d0\u5230\u7684requests auth class\uff0c\u63d0\u4f9b\u516c\u53f8\u7684Authencation\u9a8c\u8bc1header sentry_IM\/send_IM.py \u53d1\u6d88\u606f\u7528\u7684Class sentry_IM\/plugin.py \u63d2\u4ef6\u672c\u8eab \u7a0b\u5e8f\u8bb2\u89e3 \u63d2\u4ef6\u672c\u8eab\u7ee7\u627f\u81easentry.plugins.bases.notify.NotificationPlugin\u7c7b\uff0c\u9700\u8981\u5b9e\u73b0\u5176notify(self, notification)\u65b9\u6cd5\u3002\u56e0\u57fa\u7c7b\u91ccnotify()\u8c03\u7528\u4e86notify_users()\uff0c\u6240\u4ee5pylint\u4f1a\u6709\u63d0\u793a\u3002 \u53c2\u6570notification\u4e3a\u4e00\u4e2a\u5bf9\u8c61\uff0c\u53ef\u4ee5\u4ece\u4e2d\u53d6\u5f97event\uff0c\u7136\u540e\u4eceevent\u53d6\u5f97\u6240\u5c5e\u7684group\u4ee5\u53cagroup\u6240\u5c5e\u7684project\u3002\u6839\u636eproject\u53ef\u4ee5\u53d6\u5f97\u8981\u901a\u77e5\u7684\u4eba\u5458\u5217\u8868\u3002\uff08\u8fd9\u91cc\u6284\u88ad\u4e86MailPlugin\u7684\u53d1\u9001\u5217\u8868\uff09\u56e0\u4e3a\u8fd9\u4e2a\u51fd\u6570\u5f97\u5230\u7684\u4eba\u5458\u5217\u8868\u662fSentry\u91cc\u7684User id\uff0c\u6240\u4ee5\u8fd8\u9700\u8981\u518d\u6839\u636eid\u67e5\u8be2\u5230User\uff0c\u7136\u540e\u4ece\u5176Email\u5b57\u6bb5\u4e2d\u53d6\u5f97localpart \u6700\u540e\uff0c\u6839\u636e\u4e0a\u8ff0project.name\u3001event.message\u3001group.get_absolute_url() \u7ec4\u88c5\u5176\u901a\u77e5\u6d88\u606f\u6587\u672c\uff08URL\u5728IM\u5ba2\u6237\u7aef\u6e32\u67d3\u65f6\u624d\u53d8\u6210\u8d85\u94fe\u63a5\uff0c\u6211\u8fd9\u91cc\u53ea\u53d1URL\u672c\u8eab\uff09\uff0c\u751f\u6210send_IM.py \u7684\u5b9e\u4f8b\uff0c\u5bf9\u7740\u4e0a\u8ff0\u4eba\u5458\u5217\u8868\u53d1\u9001\u6d88\u606f\u6587\u672c\u3002 IM\u63d2\u4ef6\u6240\u9700\u7684\u56db\u4e2a\u53c2\u6570\uff0c\u5728\u603b\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u5217\u51fa\uff0c\u7531\u63d2\u4ef6\u751f\u6210send_IM\u5b9e\u4f8b\u65f6\u4f20\u9012\uff0c\u7136\u540e\u7531\u5176\u4f20\u9012\u7ed9requests_APISign\u7684\u5b9e\u4f8b\uff0c\u5b8c\u6210\u5bf9HTTP\u8bf7\u6c42\u7684\u7b7e\u540d \u914d\u7f6e\u662f\u5426\u5f00\u542f \u672c\u6765\u662f\u60f3\u50cfMailPlugin\u90a3\u6837\u76f4\u63a5\u5728Account\/Notification\u9875\u505a\u4e2a\u5217\u8868\u4f9b\u52fe\u9009\u3002\u4f46\u9605\u8bfb\u4ee3\u7801\u53d1\u73b0\uff0c\u8fd9\u4e2a\u529f\u80fd\u5e76\u4e0d\u662fMailPlugin\u81ea\u5df1\u7684\u529f\u80fd\uff0c\u800c\u662fsentry\u505a\u4e86\u7279\u6b8a\u5904\u7406\uff0c\u5148\u83b7\u5f97\u7528\u6237\u8ba2\u9605\u7684projects_list\uff0c\u7136\u540e\u5faa\u73af\u751f\u6210ProjectEmailOptionsForm\u7684list\uff0c\u968f\u540e\u518d\u6267\u884c\u4ece\u5404\u63d2\u4ef6\u83b7\u53d6\u7684ext_forms[]\u914d\u7f6e\u8868\u5355\u3002ext_forms\u91cc\u6bcf\u4e00\u4e2a\u63d2\u4ef6\u914d\u7f6e\u8868\u5355\u7684\u521d\u59cb\u5316\u53c2\u6570\u53ea\u6709plugin\u3001user\u548cprefix\uff0c\u8981\u60f3\u8868\u8fbe\u201c\u6240\u6709\u53ef\u8ba2\u9605\u7684projects\u201d\u8fd9\u4e2a\u6982\u5ff5\u4f1a\u76f8\u5f53\u5570\u55e6\u3002\u56e0\u6b64\uff0c\u6700\u7ec8\u786e\u5b9a\u4e3a\uff1a\u8868\u5355\u91cc\u53ea\u52fe\u9009per-User \u7ea7\u522b\u662f\u5426\u5f00\u542f\uff1b\u800c\u7528\u6237\u662f\u5426\u5c5e\u4e8e\u5177\u4f53\u67d0\u4e2aevent\/project\u7684\u53d1\u9001\u76ee\u6807\uff0c\u5219\u76f4\u63a5\u5171\u7528MailPlugin\u90a3\u8fb9\u7684\u9009\u62e9\uff0c\u7136\u540e\u518d\u7528\u4e0a\u8ff0per-User\u7ea7\u522b\u5f00\u5173\u505a\u4e00\u904d\u8fc7\u6ee4\u3002\u8fd9\u91cc\u4e24\u4e2a\u63d2\u4ef6\u4e4b\u95f4\u7565\u6709\u7c98\u8fde\uff0c\u4e3b\u8981\u662f\u7531\u4e8eUser-Project\u4e4b\u95f4\u53ea\u6709\u5355\u5411\u5bf9\u5e94\u5173\u7cfb\uff0c\u9006\u5411\u67e5\u8be2\u592a\u7f57\u55e6\u5bfc\u81f4\u7684\u3002 \u6700\u7ec8\u53d1\u9001\u6548\u679c Github\u5730\u5740\u00a0https:\/\/github.com\/julyclyde\/sentry-IM<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,61],"class_list":["post-517","post","type-post","status-publish","format-standard","hentry","category-default","tag-python","tag-sentry"],"_links":{"self":[{"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/posts\/517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/julyclyde.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=517"}],"version-history":[{"count":0,"href":"https:\/\/julyclyde.org\/index.php?rest_route=\/wp\/v2\/posts\/517\/revisions"}],"wp:attachment":[{"href":"https:\/\/julyclyde.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/julyclyde.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/julyclyde.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}