Revision 1331980d
Added by Marc Dequènes almost 11 years ago
lib/cyborghood/command_runner.rb | ||
---|---|---|
end
|
||
|
||
zone_data = cmdline.shift
|
||
unless zone_data.content_type == "text/plain"
|
||
unless zone_data.mime_type == "text/plain"
|
||
result.message = _("Zone data has wrong content-type.")
|
||
return result
|
||
end
|
lib/cyborghood/mail_order.rb | ||
---|---|---|
# analyse mail parts
|
||
order_txt = nil
|
||
if message.multipart?
|
||
if message.parts[0].content_type == "text/plain"
|
||
order_txt = message.parts[0].body_normalized
|
||
if message.parts[0].mime_type == "text/plain"
|
||
order_txt = message.parts[0].decoded
|
||
i = -1
|
||
message.parts.each do |part|
|
||
i += 1
|
||
next if i == 0
|
||
|
||
@shared_parameters[i] = CommandParameter.new(part.body_normalized, part.content_type)
|
||
@shared_parameters[i] = CommandParameter.new(part.decoded, part.mime_type)
|
||
|
||
filename = part.header['content-disposition'].params['filename'] || part.header['content-type'].params['name']
|
||
filename = part.header['content-disposition'].filename || part.content_type_parameters['name']
|
||
@shared_parameters[filename] = CommandParameterRef.new(i) if filename
|
||
end
|
||
end
|
||
else
|
||
order_txt = message.body_normalized if message.content_type == "text/plain"
|
||
order_txt = message.decoded if message.mime_type == "text/plain"
|
||
end
|
||
return Order.new(:error => _("Mail does not contain a proper text part for commands."), :user => @user) if order_txt.nil?
|
||
|
lib/cyborghood/order.rb | ||
---|---|---|
end
|
||
|
||
class CommandParameter < String
|
||
attr_reader :content_type
|
||
attr_reader :mime_type
|
||
|
||
def initialize(content, content_type = nil)
|
||
def initialize(content, mime_type = nil)
|
||
super(content)
|
||
@content_type = content_type
|
||
@mime_type = mime_type
|
||
end
|
||
|
||
def content
|
Also available in: Unified diff
[evol] adapted MailOrderParser from TMail to Mail