Permalink
Browse files

it's a binary, not a list; we need crypto

  • Loading branch information...
1 parent b6d9101 commit 75d2961b659e3da2f40e33b6b26fab8570521ab0 @scvalex committed Feb 25, 2012
Showing with 8 additions and 3 deletions.
  1. +1 −0 Makefile
  2. +3 −1 rel/reltool.config
  3. +3 −1 src/fix_id_email_scraper.erl
  4. +1 −1 src/fix_id_mnesia.erl
View
@@ -14,6 +14,7 @@ run: build
-eval 'application:start(compiler).' \
-eval 'application:start(lager).' \
-eval 'application:start(gen_smtp).' \
+ -eval 'application:start(crypto).' \
-eval 'application:start(mnesia).' \
-eval 'application:start(fix_id).'
View
@@ -14,7 +14,8 @@
lager,
gen_smtp,
mnesia,
- fix_id
+ fix_id,
+ crypto
]},
{rel, "start_clean", "",
[
@@ -38,6 +39,7 @@
{app, lager, [{incl_cond, include}]},
{app, gen_smtp, [{incl_cond, include}]},
{app, mnesia, [{incl_cond, include}]},
+ {app, crypto, [{incl_cond, include}]},
{app, fix_id, [{incl_cond, include}]}
]}.
@@ -158,7 +158,9 @@ handle_DATA(From, To, Data, State) ->
%% email data to console
lager:info("Message from ~s to ~p queued as ~s, body length ~p",
[From, To, Reference, byte_size(Data)]),
- ok = fix_id_mnesia:add_raw_email(From, To, Data),
+ ok = fix_id_mnesia:add_raw_email(erlang:binary_to_list(From),
+ [erlang:binary_to_list(Recp) || Recp <- To],
+ erlang:binary_to_list(Data)),
try mimemail:decode(Data) of
Result -> lager:info("Message decoded successfully!~n'~p'", [Result])
catch
View
@@ -96,7 +96,7 @@ create_tables(Tables) ->
%% Add a raw email to the database.
add_raw_email(From, To, Data) ->
- Sha = crypto:sha(From ++ To ++ Data),
+ Sha = crypto:sha(From ++ lists:append(To) ++ Data),
Email = #fix_id_raw_email{sha = Sha, from = From, to = To, data = Data},
{atomic, ok} = mnesia:transaction(fun() -> mnesia:write(Email) end),
ok.

0 comments on commit 75d2961

Please sign in to comment.