Class: CPEE::Callbacks::ExCallback
- Inherits:
-
Riddl::Implementation
- Object
- Riddl::Implementation
- CPEE::Callbacks::ExCallback
- Defined in:
- lib/cpee/implementation_callbacks.rb
Overview
}}}
Instance Method Summary collapse
Instance Method Details
#cleanup_encoding(val) ⇒ Object
{{{
116 117 118 119 120 121 122 |
# File 'lib/cpee/implementation_callbacks.rb', line 116 def cleanup_encoding(val) enc = CharlockHolmes::EncodingDetector.detect(val) if enc[:type] == :text && enc[:confidence] > 40 val.force_encoding(enc[:ruby_encoding]) end val end |
#response ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/cpee/implementation_callbacks.rb', line 123 def response id = @a[0] opts = @a[1] callback = @r[-1] if opts[:statemachine].final? id @status = 410 else if CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'callback' ret = {} ret['values'] = @p.map{ |e| # bei complex wenn kleiner 500KiB statt e.value.path e.value.read # bei complex wenn groesser 500KiB das file ueber nginx in einem verzeichnis verfuegbar machen, mimetype auf cpee/externallink # aendert, link auf den server in den content. Der eval macht das dann direkt. # Alt: [e.name, e.class == Riddl::Parameter::Simple ? [:simple,e.value] : [:complex,e.mimetype,e.value.path] ] [ e.name, if e.class == Riddl::Parameter::Simple [:simple,e.value] elsif e.class == Riddl::Parameter::Complex && e.value.size <= 512000 [:complex,e.mimetype,cleanup_encoding(e.value.read)] else # [:complex,'cpee-external-' + e.mimetype,cleanup_encoding(e.value.read)] [:complex, e.mimetype,cleanup_encoding(e.value.read)] end ] } ret['headers'] = @h CPEE::Message::send( :'callback-response', callback, opts[:url], id, {}, {}, ret, opts[:redis] ) elsif CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'vote' if @p.length == 1 && @p[0].name == 'continue' && @p[0].class == Riddl::Parameter::Simple CPEE::Message::send( :'vote-response', callback, opts[:url], id, {}, {}, @p[0].value, opts[:redis] ) else @status = 400 end else @status = 503 end end nil end |