Browse Source

purchase handlers moved

Maxim Sokhatsky 12 years ago
parent
commit
a5982d3165
2 changed files with 16 additions and 22 deletions
  1. 16 0
      src/kvs_purchase.erl
  2. 0 22
      src/kvs_user.erl

+ 16 - 0
src/kvs_purchase.erl

@@ -21,3 +21,19 @@ give(UId, PId) ->
 
 
 products(UId) ->
 products(UId) ->
     kvs:all_by_index(user_product, <<"user_bin">>, list_to_binary(UId)).
     kvs:all_by_index(user_product, <<"user_bin">>, list_to_binary(UId)).
+
+handle_notice(["kvs_purchase", "user", UId, "buy"] = Route,
+    Message, #state{owner = Owner, type =Type} = State) ->
+    ?INFO(" queue_action(~p): buy_gift: Owner=~p, Route=~p, Message=~p", [self(), {Type, Owner}, Route, Message]),
+    {GId} = Message,
+    buy(UId, GId),
+    {noreply, State};
+
+handle_notice(["kvs_purchase", "user", UId, "give"] = Route,
+    Message, #state{owner = Owner, type =Type} = State) ->
+    ?INFO(" queue_action(~p): give_gift: Owner=~p, Route=~p, Message=~p", [self(), {Type, Owner}, Route, Message]),
+    {GId} = Message,
+    give(UId, GId),
+    {noreply, State};
+
+handle_notice(Route, Message, State) -> error_logger:info_msg("Unknown PURCHASE notice").

+ 0 - 22
src/kvs_user.erl

@@ -220,7 +220,6 @@ handle_notice(["system", "create_group"] = Route,
     mqs:notify([group, init], {GId, FId}),
     mqs:notify([group, init], {GId, FId}),
     kvs_users:init_mq(Group),
     kvs_users:init_mq(Group),
 
 
-
     {noreply, State};
     {noreply, State};
 
 
 handle_notice(["db", "group", GId, "remove_group"] = Route, 
 handle_notice(["db", "group", GId, "remove_group"] = Route, 
@@ -333,27 +332,6 @@ handle_notice(["subscription", "user", _UId, "update"] = Route,
     kvs_users:update_user(NewUser),
     kvs_users:update_user(NewUser),
     {noreply, State};
     {noreply, State};
 
 
-handle_notice(["gifts", "user", UId, "buy_gift"] = Route,
-    Message, #state{owner = Owner, type =Type} = State) ->
-    ?INFO(" queue_action(~p): buy_gift: Owner=~p, Route=~p, Message=~p", [self(), {Type, Owner}, Route, Message]),
-    {GId} = Message,
-    kvs_users:buy_gift(UId, GId),
-    {noreply, State};
-
-handle_notice(["gifts", "user", UId, "give_gift"] = Route,
-    Message, #state{owner = Owner, type =Type} = State) ->
-    ?INFO(" queue_action(~p): give_gift: Owner=~p, Route=~p, Message=~p", [self(), {Type, Owner}, Route, Message]),
-    {GId} = Message,
-    kvs_users:give_gift(UId, GId),
-    {noreply, State};
-
-handle_notice(["gifts", "user", UId, "mark_gift_as_deliving"] = Route,
-    Message, #state{owner = Owner, type =Type} = State) ->
-    ?INFO(" queue_action(~p): mark_gift_as_deliving: Owner=~p, Route=~p, Message=~p", [self(), {Type, Owner}, Route, Message]),
-    {GId, GTimestamp} = Message,
-    kvs_users:mark_gift_as_deliving(UId, GId, GTimestamp),
-    {noreply, State};
-
 handle_notice(["login", "user", UId, "update_after_login"] = Route,
 handle_notice(["login", "user", UId, "update_after_login"] = Route,
     Message, #state{owner = Owner, type =Type} = State) ->
     Message, #state{owner = Owner, type =Type} = State) ->
     ?INFO("queue_action(~p): update_after_login: Owner=~p, Route=~p, Message=~p", [self(), {Type, Owner}, Route, Message]),    
     ?INFO("queue_action(~p): update_after_login: Owner=~p, Route=~p, Message=~p", [self(), {Type, Owner}, Route, Message]),