Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add event to handle addMissedCall, remove filter on MissedCall to ret… #4

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion com.zetapush.core.visio/recipe.zms
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ 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;

// =====================
// CONSTANTES
Expand All @@ -32,6 +33,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 +57,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);