Skip to content

Commit

Permalink
Merge pull request #1 from Insurlytech/feature/leotrack-237-suppressi…
Browse files Browse the repository at this point in the history
…on-des-appels

add event to handle addMissedCall, remove filter on MissedCall to ret…
  • Loading branch information
MerwanL committed Jul 9, 2018
2 parents 7e7ac7b + 9a8b103 commit 290de8b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
15 changes: 14 additions & 1 deletion com.zetapush.core.visio/recipe.zms
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ recipe com.zetapush.core.visio 1.0.0;
// =====================
// IMPORTS
// =====================

import recipe com.zetapush.core.room 1.0.0 in zpRecipeRoom;
import recipe com.zetapush.core.utils 1.0.0 in zpRecipeUtils;
import recipe com.zetapush.core.group 1.0.0 in zpRecipeGroup;
import recipe com.zetapush.core.room 1.0.0 in zpRecipeRoom;
import recipe com.zetapush.core.role 1.0.0 in zpRecipeRole;

// =====================
// CONSTANTES
Expand All @@ -32,6 +34,12 @@ const TIMEOUT_CALL_SECONDS = 30;
const ROOM_ID_ENTROPY = 32; // To generate call id
const NUMBER_OF_CHARS_IN_ROOM_ID = 32; // To generate call id

// =====================
// EVENTS
// =====================

const EVENT__ADD_MISSED_CALL = 'ZetaPushEvent__Visio_AddMissedCall';

// =====================
// SERVICES
// =====================
Expand All @@ -50,5 +58,10 @@ service database = new gda(__default).forbiddenVerbs(__all);
/** Weak service for our tests */
service auth = new weak(__default).forbiddenVerbs(__all);

/**
* Event trigger service
*/
service zpServiceTrigger = trigger(__default).forbiddenVerbs(__all);



6 changes: 6 additions & 0 deletions com.zetapush.core.visio/src/api/call/addToMissedCall.zms
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ macroscript addToMissedCall(
/** Call object */ @NotNull Call callObject
) {

/** Execute all registered macros */
zpRecipeUtils::zpServiceTrigger.trigger({
event: EVENT__ADD_MISSED_CALL,
data: { callObject }
});

} broadcast ( callObject.called ) { callObject } on channel __selfName
11 changes: 11 additions & 0 deletions com.zetapush.core.visio/src/api/call/removeFromMissedCall.zms
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Macroscript that used to send the call object as a missed call.
* The client need to listen this macroscript to handle missed calls
*/
macroscript removeFromMissedCall(
/** ID of the call */ @NotNull string id
) {

sudo zpRecipeUtils::GLOBAL_OWNER database.removeRow({table : TABLE_DATABASE_CALL, key : id});

} broadcast (id) {} on channel __selfName
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ macroscript getMissedCallByUser(
table : TABLE_DATABASE_CALL,
stop : '~',
page,
function : x -> ((x[COLUMN_CALL_OBJECT].caller == userKey ||
x[COLUMN_CALL_OBJECT].called == userKey ||
coll:contains(listGroupId, x[COLUMN_CALL_OBJECT].caller) ||
coll:contains(listGroupId, x[COLUMN_CALL_OBJECT].called)) &&
x[COLUMN_CALL_OBJECT].state == STATE_CALL_MISSED)
function : x -> (x[COLUMN_CALL_OBJECT].state == STATE_CALL_MISSED)

});

Expand Down
3 changes: 3 additions & 0 deletions com.zetapush.core.visio/src/impl/__annotations__.zms
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* MISSED CALL LISTENERS */
/** Handle an Add Missed Call Event */
macroscript_annotation AddMissedCallListener = @EventListener(eventName = EVENT__ADD_MISSED_CALL, triggerService = zpServiceTrigger);

0 comments on commit 290de8b

Please sign in to comment.