ZReviewTender 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/Processors/SlackProcessor.rb +13 -2
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: efd264d3712595b3055699ded3b674352f0ec587ae69905af583397e64712661
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 257ed3ced4b87bd043f879b16e21d55e0be1447e18be139725a080b9df25cf86
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: b187b442517d24c7f4e4e509240907670bab76b15473c1744db5d82c3001e7a9cdde628d474b12f989d10ed062b74794b33d33a8ae9308430e6482f9d0ad20e7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a276fa52b6f373c9a1d10ed47eb30d76f174e03930da2839f3e43e55798bd5bd922d0cb879d03f0e962f6f24b9bccca2d468216a69940db1e690ba5a68e429ca
         
     | 
| 
         @@ -56,7 +56,7 @@ class SlackProcessor < Processor 
     | 
|
| 
       56 
56 
     | 
    
         
             
                        end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                        result = request(payload)
         
     | 
| 
       59 
     | 
    
         
            -
                        if result 
     | 
| 
      
 59 
     | 
    
         
            +
                        if !result
         
     | 
| 
       60 
60 
     | 
    
         
             
                            Helper.logError(result)
         
     | 
| 
       61 
61 
     | 
    
         
             
                        end
         
     | 
| 
       62 
62 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -87,14 +87,18 @@ class SlackProcessor < Processor 
     | 
|
| 
       87 
87 
     | 
    
         | 
| 
       88 
88 
     | 
    
         
             
                private
         
     | 
| 
       89 
89 
     | 
    
         
             
                def request(payload)
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                    isInCommingWebHook = false
         
     | 
| 
       90 
92 
     | 
    
         
             
                    if !botToken.nil? && botToken != ""
         
     | 
| 
       91 
93 
     | 
    
         
             
                        uri = URI("https://slack.com/api/chat.postMessage")
         
     | 
| 
       92 
94 
     | 
    
         
             
                        payload.channel = targetChannel
         
     | 
| 
       93 
95 
     | 
    
         
             
                        headers = {'Content-Type': 'application/json; charset=utf-8', 'Authorization': "Bearer #{botToken}"}
         
     | 
| 
      
 96 
     | 
    
         
            +
                        isInCommingWebHook = false
         
     | 
| 
       94 
97 
     | 
    
         
             
                    else
         
     | 
| 
       95 
98 
     | 
    
         
             
                        uri = URI(inCommingWebHookURL)
         
     | 
| 
       96 
99 
     | 
    
         
             
                        payload.channel = nil
         
     | 
| 
       97 
100 
     | 
    
         
             
                        headers = {'Content-Type': 'application/json; charset=utf-8'}
         
     | 
| 
      
 101 
     | 
    
         
            +
                        isInCommingWebHook = true
         
     | 
| 
       98 
102 
     | 
    
         
             
                    end
         
     | 
| 
       99 
103 
     | 
    
         | 
| 
       100 
104 
     | 
    
         
             
                    http = Net::HTTP.new(uri.host, uri.port)
         
     | 
| 
         @@ -102,7 +106,14 @@ class SlackProcessor < Processor 
     | 
|
| 
       102 
106 
     | 
    
         
             
                    req = Net::HTTP::Post.new(uri.request_uri, headers)
         
     | 
| 
       103 
107 
     | 
    
         
             
                    req.body = payload.to_json
         
     | 
| 
       104 
108 
     | 
    
         
             
                    res = http.request(req)
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                    if isInCommingWebHook
         
     | 
| 
      
 111 
     | 
    
         
            +
                        return res.body == "ok"
         
     | 
| 
      
 112 
     | 
    
         
            +
                    else
         
     | 
| 
      
 113 
     | 
    
         
            +
                        result = JSON.parse(res.body)
         
     | 
| 
      
 114 
     | 
    
         
            +
                        return result["ok"] == true
         
     | 
| 
      
 115 
     | 
    
         
            +
                    end
         
     | 
| 
      
 116 
     | 
    
         
            +
                    
         
     | 
| 
       106 
117 
     | 
    
         
             
                end
         
     | 
| 
       107 
118 
     | 
    
         | 
| 
       108 
119 
     | 
    
         
             
                private
         
     |