Skip to content

Commit

Permalink
Basic compose app
Browse files Browse the repository at this point in the history
  • Loading branch information
avinasha committed Nov 14, 2012
1 parent 034e013 commit 15684dd
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
Binary file added apps/compose/assets/images/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/compose/assets/images/screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions apps/compose/assets/views/button/overlay.hbs
@@ -0,0 +1,9 @@
<label for = "to"> To: </label>
<input name="to" type="text"/>

<label for = "subject"> Subject: </label>
<input name="subject" type="text"/>

<label for = "body"> Body: </label>
<textarea name="body">
</textarea>
58 changes: 58 additions & 0 deletions apps/compose/compose.rb
@@ -0,0 +1,58 @@
module Compose
module ActionHandler
def button
mail_from = settings.from
mail_to = payload.overlay.to
mail_subject = payload.overlay.subject
mail_body = payload.overlay.body
ssl = settings.ssl == '1' ? true : false

return [500, 'Invalid From Address'] unless valid_email?(mail_from)
return [500, 'Invalid To Address'] unless valid_email?(payload.overlay.to)

mail = Mail.new do
from mail_from
to mail_to
subject mail_subject
body mail_body
end

mail.delivery_method(:smtp, {
address: settings.server,
port: settings.server_port.to_i,
user_name: settings.username,
password: settings.password,
authentication: 'plain',
enable_starttls_auto: true,
ssl: ssl
})

begin
mail.deliver
rescue Exception => e
return [500, e.message]
end

[200, "Message sent to #{mail_to}"]
end
end
end

module Compose
class Base < SupportBeeApp::Base
string :server, :required => true, :label => "SMTP Server Address"
string :server_port, :required => true, :label => "SMTP Server Port"
string :username, :required => true, :label => "Username"
password :password, :required => true, :label => "Password"
string :from, :required => true, :label => "From Address"
boolean :ssl, :default => true, :label => "SSL"

white_list :server, :server_port, :ssl

private

def valid_email?(email)
true
end
end
end
25 changes: 25 additions & 0 deletions apps/compose/config.yml
@@ -0,0 +1,25 @@
name: Compose
slug: compose
access: public

description: "
Initiate conversations with your customer right from inside SupportBee.
"

category: Feature

tags:
- compose

developer:
name: Avinasha S
email: me@avinasha.com
twitter: "@avishastry"
github: avinasha

action:
button:
overlay: true
screens:
- ticket
label: Compose

0 comments on commit 15684dd

Please sign in to comment.