From 366a5a426ce7901ff5ab890260ddbc4a7e452d8b Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Tue, 18 Jun 2019 10:01:09 +0300 Subject: [PATCH 01/20] dev merge devlyzer --- .gitignore | 40 +- apps/rebar.config | 2 +- apps/roster/include/rest_static.hrl | 2 +- apps/roster/include/roster.hrl | 29 +- apps/roster/priv/macbert/Model/Auth.swift | 17 - apps/roster/priv/macbert/Model/Job.swift | 15 - apps/roster/priv/macbert/Model/Member.swift | 20 - apps/roster/priv/macbert/Model/Profile.swift | 11 - apps/roster/priv/macbert/Model/Schedule.swift | 7 - apps/roster/priv/macbert/Model/hist.swift | 13 - .../priv/macbert/Model/messageEvent.swift | 8 - apps/roster/priv/macbert/Model/ok.swift | 4 - apps/roster/priv/macbert/Model/reader.swift | 9 - apps/roster/priv/macbert/Source/Decoder.swift | 364 ------- apps/roster/priv/macbert/Spec/Auth_Spec.swift | 47 - .../priv/macbert/Spec/Contact_Spec.swift | 51 - apps/roster/priv/macbert/Spec/Desc_Spec.swift | 13 - .../priv/macbert/Spec/Feature_Spec.swift | 8 - apps/roster/priv/macbert/Spec/Job_Spec.swift | 45 - .../priv/macbert/Spec/Member_Spec.swift | 58 -- .../priv/macbert/Spec/Message_Spec.swift | 60 -- .../priv/macbert/Spec/Profile_Spec.swift | 31 - apps/roster/priv/macbert/Spec/Room_Spec.swift | 60 -- .../priv/macbert/Spec/Roster_Spec.swift | 45 - .../priv/macbert/Spec/Schedule_Spec.swift | 12 - apps/roster/priv/macbert/Spec/Star_Spec.swift | 17 - .../macbert/Spec/boundaryEvent_Spec.swift | 19 - apps/roster/priv/macbert/Spec/hist_Spec.swift | 20 - apps/roster/priv/macbert/Spec/io_Spec.swift | 17 - .../priv/macbert/Spec/messageEvent_Spec.swift | 16 - apps/roster/priv/macbert/Spec/ok_Spec.swift | 5 - .../priv/macbert/Spec/reader_Spec.swift | 14 - .../priv/macbert/Spec/receiveTask_Spec.swift | 10 - .../priv/macbert/Spec/serviceTask_Spec.swift | 10 - apps/roster/priv/macbert/Spec/task_Spec.swift | 10 - .../priv/macbert/Spec/userTask_Spec.swift | 10 - apps/roster/priv/macbert/json-bert.js | 935 +++++++++++++++++- apps/roster/src/processes/job.erl | 25 +- apps/roster/src/protocol/roster_acl.erl | 5 +- apps/roster/src/protocol/roster_message.erl | 3 +- apps/roster/src/protocol/roster_profile.erl | 6 +- apps/roster/src/protocol/roster_room.erl | 2 +- apps/roster/src/protocol/roster_roster.erl | 4 +- apps/roster/src/protocol/roster_search.erl | 8 - apps/roster/src/rest/rest_chat_csv.erl | 12 +- apps/roster/src/rest/rest_cri.erl | 1 + apps/roster/src/rest/rest_transcribe.erl | 8 +- apps/roster/src/roster.erl | 29 +- apps/roster/src/roster_data.erl | 2 +- apps/roster/src/roster_db.erl | 483 +-------- apps/roster/src/roster_validator.erl | 135 +-- apps/service/rebar.config | 2 +- priv/protobuf/service_auth/Auth.proto | 30 - priv/protobuf/service_auth/Desc.proto | 19 - priv/protobuf/service_auth/Service.proto | 22 - priv/protobuf/service_auth/Tag.proto | 18 - priv/protobuf/service_auth/authOs.proto | 17 - priv/protobuf/service_auth/presence.proto | 16 - priv/protobuf/service_auth/serverType.proto | 19 - priv/protobuf/service_friend/Desc.proto | 19 - priv/protobuf/service_friend/Feature.proto | 17 - priv/protobuf/service_message/Feature.proto | 17 - priv/protobuf/service_message/Service.proto | 22 - priv/protobuf/service_message/Tag.proto | 18 - priv/protobuf/service_message/p2p.proto | 15 - priv/protobuf/service_profile/Desc.proto | 19 - priv/protobuf/service_profile/Tag.proto | 18 - priv/protobuf/service_roster/Desc.proto | 19 - priv/protobuf/service_roster/Service.proto | 22 - priv/protobuf/service_roster/serverType.proto | 19 - priv/protobuf/service_roster/tagType.proto | 17 - rebar.config | 47 +- rebar.config.script | 10 + rebar.lock | 52 +- sys.config | 3 +- 75 files changed, 1157 insertions(+), 2097 deletions(-) delete mode 100644 apps/roster/priv/macbert/Model/Auth.swift delete mode 100644 apps/roster/priv/macbert/Model/Job.swift delete mode 100644 apps/roster/priv/macbert/Model/Member.swift delete mode 100644 apps/roster/priv/macbert/Model/Profile.swift delete mode 100644 apps/roster/priv/macbert/Model/Schedule.swift delete mode 100644 apps/roster/priv/macbert/Model/hist.swift delete mode 100644 apps/roster/priv/macbert/Model/messageEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/ok.swift delete mode 100644 apps/roster/priv/macbert/Model/reader.swift delete mode 100644 apps/roster/priv/macbert/Source/Decoder.swift delete mode 100644 apps/roster/priv/macbert/Spec/Auth_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Contact_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Desc_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Feature_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Job_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Member_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Message_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Profile_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Room_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Roster_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Schedule_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Star_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/boundaryEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/hist_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/io_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/messageEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/ok_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/reader_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/receiveTask_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/serviceTask_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/task_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/userTask_Spec.swift delete mode 100644 priv/protobuf/service_auth/Auth.proto delete mode 100644 priv/protobuf/service_auth/Desc.proto delete mode 100644 priv/protobuf/service_auth/Service.proto delete mode 100644 priv/protobuf/service_auth/Tag.proto delete mode 100644 priv/protobuf/service_auth/authOs.proto delete mode 100644 priv/protobuf/service_auth/presence.proto delete mode 100644 priv/protobuf/service_auth/serverType.proto delete mode 100644 priv/protobuf/service_friend/Desc.proto delete mode 100644 priv/protobuf/service_friend/Feature.proto delete mode 100644 priv/protobuf/service_message/Feature.proto delete mode 100644 priv/protobuf/service_message/Service.proto delete mode 100644 priv/protobuf/service_message/Tag.proto delete mode 100644 priv/protobuf/service_message/p2p.proto delete mode 100644 priv/protobuf/service_profile/Desc.proto delete mode 100644 priv/protobuf/service_profile/Tag.proto delete mode 100644 priv/protobuf/service_roster/Desc.proto delete mode 100644 priv/protobuf/service_roster/Service.proto delete mode 100644 priv/protobuf/service_roster/serverType.proto delete mode 100644 priv/protobuf/service_roster/tagType.proto create mode 100644 rebar.config.script diff --git a/.gitignore b/.gitignore index 727e3341c..dc6aa32ab 100644 --- a/.gitignore +++ b/.gitignore @@ -17,39 +17,11 @@ workspace.xml .DS_Store _build -# Excessive for iOS models -apps/roster/priv/macbert/Model/PublishService.swift -apps/roster/priv/macbert/Model/Whitelist.swift -apps/roster/priv/macbert/Model/feed.swift -apps/roster/priv/macbert/Spec/PublishService_Spec.swift -apps/roster/priv/macbert/Spec/Whitelist_Spec.swift -apps/roster/priv/macbert/Spec/feed_Spec.swift - .applist 0.3 -priv/protobuf/service_friend/Contact.proto -priv/protobuf/service_friend/Friend.proto -priv/protobuf/service_friend/Roster.proto -priv/protobuf/service_friend/contactStatus.proto -priv/protobuf/service_friend/friendStatus.proto -priv/protobuf/service_friend/muc.proto -priv/protobuf/service_friend/p2p.proto -priv/protobuf/service_friend/rosterStatus.proto -priv/protobuf/service_room/History.proto -priv/protobuf/service_room/Job.proto -priv/protobuf/service_room/Message.proto -priv/protobuf/service_room/act.proto -priv/protobuf/service_room/historyType.proto -priv/protobuf/service_room/jobType.proto -priv/protobuf/service_room/messageEvent.proto -priv/protobuf/service_room/messageStatus.proto -priv/protobuf/service_room/messageType.proto -apps/roster/priv/macbert/Model/FakeNumbers.swift -apps/roster/priv/macbert/Model/Presence.swift -apps/roster/priv/macbert/Model/cx.swift -apps/roster/priv/macbert/Model/load.swift -apps/roster/priv/macbert/Spec/FakeNumbers_Spec.swift -apps/roster/priv/macbert/Spec/Presence_Spec.swift -apps/roster/priv/macbert/Spec/cx_Spec.swift -apps/roster/priv/macbert/Spec/load_Spec.swift -apps/service/priv/ +priv/protobuf/* +apps/roster/priv/macbert/Model/* +apps/roster/priv/macbert/Spec/* +apps/roster/priv/macbert/Source/* + +apps/service/priv/* diff --git a/apps/rebar.config b/apps/rebar.config index c337a9c61..0993ff015 100644 --- a/apps/rebar.config +++ b/apps/rebar.config @@ -1,2 +1,2 @@ -{sub_dirs, [ "roster", "service" ]}. +{sub_dirs, [ "roster" ]}. {deps_dir, ["../deps"]}. diff --git a/apps/roster/include/rest_static.hrl b/apps/roster/include/rest_static.hrl index dcc94d45d..537e16c2b 100644 --- a/apps/roster/include/rest_static.hrl +++ b/apps/roster/include/rest_static.hrl @@ -24,7 +24,7 @@ feed_id = [] :: [] | binary(), call_id = [] :: [] | binary(), type = [] :: [] | binary(), - recipients = [] :: [] | binary(), + recipients = [] :: [] | list(), duration = 0 :: [] | integer(), start_time = 0 :: [] | integer(), status = [] :: [] | binary(), diff --git a/apps/roster/include/roster.hrl b/apps/roster/include/roster.hrl index bdfa61080..d3fcbeea3 100644 --- a/apps/roster/include/roster.hrl +++ b/apps/roster/include/roster.hrl @@ -75,8 +75,8 @@ -record('Feature', {id = [] :: [] | binary(), key = [] :: binary(), - value = <<>> :: binary(), - group = ?DUMMY_GROUP :: binary()}). + value = <<>> :: [] | binary(), + group = ?DUMMY_GROUP :: [] | binary()}). -record('Service', {id = [] :: [] | binary(), type = [] :: email | vox | aws | wallet, @@ -97,7 +97,7 @@ names = [] :: [] | binary(), surnames = [] :: [] | binary(), alias = [] :: [] | binary(), - reader = 0 :: [] | integer(), + reader = 0 :: [] | integer() | #reader{}, update = 0 :: [] | integer(), settings = [] :: [] | list(#'Feature'{}), services = [] :: [] | list(#'Service'{}), @@ -122,7 +122,7 @@ -record('Message', {id = [] :: [] | integer(), container = chain :: chain | cur | [], - feed_id = [] :: #muc{} | #p2p{}, + feed_id = [] :: [] | #muc{} | #p2p{}, prev = [] :: [] | integer(), next = [] :: [] | integer(), msg_id = [] :: [] | binary(), @@ -192,9 +192,9 @@ created = 0 :: [] | integer(), settings = [] :: list(#'Feature'{}), services = [] :: list(#'Service'{}), - presence = [] :: [] | online | offline | binary(), + presence = [] :: [] | online | offline | binary(), status = [] :: [] | request | authorization | ignore | internal - | friend | last_msg | ban | banned | deleted }). + | friend | last_msg | ban | banned | deleted | not_existence}). -record('ExtendedStar', {star = [] :: #'Star'{} | [], from = [] :: #'Contact'{} | #'Room'{} | []}). @@ -204,7 +204,9 @@ user_id = [] :: [] | binary(), phone = [] :: [] | binary() | {fake, binary()}, token = [] :: [] | binary(), - type = [] :: [] | atom(), + type = [] :: [] | update | clear | delete | deleted | logout + | verify | verified | expired | reg | resend + | voice | push | get | {ver | reg, string()}, sms_code = [] :: [] | binary(), attempts = [] :: [] | integer(), services = [] :: list(term()), @@ -227,7 +229,8 @@ avatar = [] :: [] | binary(), update = 0 :: [] | integer(), status = [] :: [] | get | create | del | remove | nick - | add | update | list | patch | last_msg }). + | search | contact | add | update + | list | patch | last_msg }). -record('Profile', {phone = [] :: [] | binary(), services = [] :: [] | list(#'Service'{}), @@ -284,17 +287,17 @@ -record('Index', {id = [] :: [] | term(), roster = [] :: list(term())}). --record('Whitelist', {phone = [] :: [] | binary(), +-record('Whitelist', {phone = [] :: [] | integer() | binary(), created = 0 :: [] | integer()}). -record(error, {code = [] :: [] | atom()}). --record(ok, {code = [] :: [] | binary()}). +-record(ok, {code = [] :: [] | sms_sent | call_in_progress | push | cleared | logout | binary()}). -record(error2, {code = [] :: [] | atom(), src=[] :: [] | binary() | integer() }). -record(ok2, {code = [] :: [] | atom(), src=[] :: [] | {binary(), binary()} | binary() }). -record(io, {code = [] :: [] | #ok{} | #error{} | #ok2{} | #error2{}, - data = <<>> :: [] | <<>> | #'Roster'{} | { atom(), binary() | integer() }}). + data = <<>> :: [] | <<>> | binary() | #'Roster'{} | { atom(), binary() | integer() }}). -record('Ack', {table = 'Message' :: atom(), id = [] :: [] | binary()}). @@ -319,7 +322,7 @@ topic = [] :: [] | binary(), qos = 0 :: [] | integer()}). --record('FakeNumbers', {phone = [] :: [] | binary(), - created = 0 :: [] | integer()}). +-record('FakeNumbers', {phone = [] :: [] | integer() | binary(), + created = 0 :: [] | integer() | list()}). -endif. \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Auth.swift b/apps/roster/priv/macbert/Model/Auth.swift deleted file mode 100644 index 2352012a1..000000000 --- a/apps/roster/priv/macbert/Model/Auth.swift +++ /dev/null @@ -1,17 +0,0 @@ - -class Auth { - var client_id: String? - var dev_key: String? - var user_id: String? - var phone: AnyObject? - var token: String? - var type: StringAtom? - var sms_code: String? - var attempts: Int64? - var services: [AnyObject]? - var settings: [Feature]? - var push: String? - var os: AnyObject? - var created: Int64? - var last_online: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Job.swift b/apps/roster/priv/macbert/Model/Job.swift deleted file mode 100644 index 224046c0a..000000000 --- a/apps/roster/priv/macbert/Model/Job.swift +++ /dev/null @@ -1,15 +0,0 @@ - -class Job { - var id: Int64? - var container: AnyObject? - var feed_id: act? - var prev: Int64? - var next: Int64? - var context: AnyObject? - var proc: AnyObject? - var time: Int64? - var data: AnyObject? - var events: [messageEvent]? - var settings: [Feature]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Member.swift b/apps/roster/priv/macbert/Model/Member.swift deleted file mode 100644 index 748d88eca..000000000 --- a/apps/roster/priv/macbert/Model/Member.swift +++ /dev/null @@ -1,20 +0,0 @@ - -class Member { - var id: Int64? - var container: AnyObject? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? - var phone_id: String? - var avatar: String? - var names: String? - var surnames: String? - var alias: String? - var reader: Int64? - var update: Int64? - var settings: [Feature]? - var services: [Service]? - var presence: AnyObject? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Profile.swift b/apps/roster/priv/macbert/Model/Profile.swift deleted file mode 100644 index f32b4e552..000000000 --- a/apps/roster/priv/macbert/Model/Profile.swift +++ /dev/null @@ -1,11 +0,0 @@ - -class Profile { - var phone: String? - var services: [Service]? - var rosters: [AnyObject]? - var settings: [Feature]? - var update: Int64? - var balance: Int64? - var presence: AnyObject? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Schedule.swift b/apps/roster/priv/macbert/Model/Schedule.swift deleted file mode 100644 index 465c77196..000000000 --- a/apps/roster/priv/macbert/Model/Schedule.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class Schedule { - var id: Int64? - var proc: Int64? - var data: [AnyObject]? - var state: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/hist.swift b/apps/roster/priv/macbert/Model/hist.swift deleted file mode 100644 index f46c4d04d..000000000 --- a/apps/roster/priv/macbert/Model/hist.swift +++ /dev/null @@ -1,13 +0,0 @@ - -class hist { - var id: Int64? - var container: StringAtom? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? - var name: String? - var task: StringAtom? - var docs: [AnyObject]? - var time: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/messageEvent.swift b/apps/roster/priv/macbert/Model/messageEvent.swift deleted file mode 100644 index 6dc379344..000000000 --- a/apps/roster/priv/macbert/Model/messageEvent.swift +++ /dev/null @@ -1,8 +0,0 @@ - -class messageEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var payload: String? - var timeout: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/ok.swift b/apps/roster/priv/macbert/Model/ok.swift deleted file mode 100644 index 935a071b5..000000000 --- a/apps/roster/priv/macbert/Model/ok.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class ok { - var code: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/reader.swift b/apps/roster/priv/macbert/Model/reader.swift deleted file mode 100644 index b1e34c1db..000000000 --- a/apps/roster/priv/macbert/Model/reader.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class reader { - var id: AnyObject? - var pos: Int64? - var cache: Int64? - var args: AnyObject? - var feed: AnyObject? - var dir: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Source/Decoder.swift b/apps/roster/priv/macbert/Source/Decoder.swift deleted file mode 100644 index 7f92a585e..000000000 --- a/apps/roster/priv/macbert/Source/Decoder.swift +++ /dev/null @@ -1,364 +0,0 @@ -func parseObject(name: String, body:[Model], tuple: BertTuple) -> AnyObject? -{ - switch name { - case "chain": - if body.count != 6 { return nil } - let a_chain = chain() - a_chain.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_chain.top = body[1].parse(bert: tuple.elements[2]) as? Int64 - a_chain.rear = body[2].parse(bert: tuple.elements[3]) as? Int64 - a_chain.count = body[3].parse(bert: tuple.elements[4]) as? Int64 - return a_chain - case "push": - if body.count != 6 { return nil } - let a_push = push() - a_push.model = body[0].parse(bert: tuple.elements[1]) as? AnyObject - a_push.type = body[1].parse(bert: tuple.elements[2]) as? String - a_push.title = body[2].parse(bert: tuple.elements[3]) as? String - a_push.alert = body[3].parse(bert: tuple.elements[4]) as? String - a_push.badge = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_push.sound = body[5].parse(bert: tuple.elements[6]) as? String - return a_push - case "Search": - if body.count != 6 { return nil } - let a_Search = Search() - a_Search.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Search.ref = body[1].parse(bert: tuple.elements[2]) as? String - a_Search.field = body[2].parse(bert: tuple.elements[3]) as? String - a_Search.type = body[3].parse(bert: tuple.elements[4]) as? AnyObject - a_Search.value = body[4].parse(bert: tuple.elements[5]) as? [AnyObject] - a_Search.status = body[5].parse(bert: tuple.elements[6]) as? AnyObject - return a_Search - case "p2p": - if body.count != 2 { return nil } - let a_p2p = p2p() - a_p2p.from = body[0].parse(bert: tuple.elements[1]) as? String - a_p2p.to = body[1].parse(bert: tuple.elements[2]) as? String - return a_p2p - case "muc": - if body.count != 1 { return nil } - let a_muc = muc() - a_muc.name = body[0].parse(bert: tuple.elements[1]) as? String - return a_muc - case "mqi": - if body.count != 3 { return nil } - let a_mqi = mqi() - a_mqi.feed_id = body[0].parse(bert: tuple.elements[1]) as? muc - a_mqi.query = body[1].parse(bert: tuple.elements[2]) as? String - a_mqi.status = body[2].parse(bert: tuple.elements[3]) as? AnyObject - return a_mqi - case "Feature": - if body.count != 4 { return nil } - let a_Feature = Feature() - a_Feature.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Feature.key = body[1].parse(bert: tuple.elements[2]) as? String - a_Feature.value = body[2].parse(bert: tuple.elements[3]) as? String - a_Feature.group = body[3].parse(bert: tuple.elements[4]) as? String - return a_Feature - case "Service": - if body.count != 7 { return nil } - let a_Service = Service() - a_Service.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Service.type = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_Service.data = body[2].parse(bert: tuple.elements[3]) as? AnyObject - a_Service.login = body[3].parse(bert: tuple.elements[4]) as? String - a_Service.password = body[4].parse(bert: tuple.elements[5]) as? String - a_Service.expiration = body[5].parse(bert: tuple.elements[6]) as? Int64 - a_Service.status = body[6].parse(bert: tuple.elements[7]) as? AnyObject - return a_Service - case "Member": - if body.count != 17 { return nil } - let a_Member = Member() - a_Member.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Member.container = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_Member.feed_id = body[2].parse(bert: tuple.elements[3]) as? AnyObject - a_Member.prev = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_Member.next = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_Member.feeds = body[5].parse(bert: tuple.elements[6]) as? [AnyObject] - a_Member.phone_id = body[6].parse(bert: tuple.elements[7]) as? String - a_Member.avatar = body[7].parse(bert: tuple.elements[8]) as? String - a_Member.names = body[8].parse(bert: tuple.elements[9]) as? String - a_Member.surnames = body[9].parse(bert: tuple.elements[10]) as? String - a_Member.alias = body[10].parse(bert: tuple.elements[11]) as? String - a_Member.reader = body[11].parse(bert: tuple.elements[12]) as? Int64 - a_Member.update = body[12].parse(bert: tuple.elements[13]) as? Int64 - a_Member.settings = body[13].parse(bert: tuple.elements[14]) as? [Feature] - a_Member.services = body[14].parse(bert: tuple.elements[15]) as? [Service] - a_Member.presence = body[15].parse(bert: tuple.elements[16]) as? AnyObject - a_Member.status = body[16].parse(bert: tuple.elements[17]) as? AnyObject - return a_Member - case "Desc": - if body.count != 5 { return nil } - let a_Desc = Desc() - a_Desc.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Desc.mime = body[1].parse(bert: tuple.elements[2]) as? String - a_Desc.payload = body[2].parse(bert: tuple.elements[3]) as? String - a_Desc.parentid = body[3].parse(bert: tuple.elements[4]) as? String - a_Desc.data = body[4].parse(bert: tuple.elements[5]) as? [Feature] - return a_Desc - case "StickerPack": - if body.count != 9 { return nil } - let a_StickerPack = StickerPack() - a_StickerPack.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_StickerPack.name = body[1].parse(bert: tuple.elements[2]) as? String - a_StickerPack.keywords = body[2].parse(bert: tuple.elements[3]) as? [AnyObject] - a_StickerPack.description = body[3].parse(bert: tuple.elements[4]) as? String - a_StickerPack.author = body[4].parse(bert: tuple.elements[5]) as? String - a_StickerPack.stickers = body[5].parse(bert: tuple.elements[6]) as? [Desc] - a_StickerPack.created = body[6].parse(bert: tuple.elements[7]) as? Int64 - a_StickerPack.updated = body[7].parse(bert: tuple.elements[8]) as? Int64 - a_StickerPack.downloaded = body[8].parse(bert: tuple.elements[9]) as? Int64 - return a_StickerPack - case "Message": - if body.count != 16 { return nil } - let a_Message = Message() - a_Message.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Message.container = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_Message.feed_id = body[2].parse(bert: tuple.elements[3]) as? AnyObject - a_Message.prev = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_Message.next = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_Message.msg_id = body[5].parse(bert: tuple.elements[6]) as? String - a_Message.from = body[6].parse(bert: tuple.elements[7]) as? String - a_Message.to = body[7].parse(bert: tuple.elements[8]) as? String - a_Message.created = body[8].parse(bert: tuple.elements[9]) as? Int64 - a_Message.files = body[9].parse(bert: tuple.elements[10]) as? [Desc] - a_Message.type = body[10].parse(bert: tuple.elements[11]) as? [AnyObject] - a_Message.link = body[11].parse(bert: tuple.elements[12]) as? AnyObject - a_Message.seenby = body[12].parse(bert: tuple.elements[13]) as? [AnyObject] - a_Message.repliedby = body[13].parse(bert: tuple.elements[14]) as? [AnyObject] - a_Message.mentioned = body[14].parse(bert: tuple.elements[15]) as? [AnyObject] - a_Message.status = body[15].parse(bert: tuple.elements[16]) as? AnyObject - return a_Message - case "Link": - if body.count != 6 { return nil } - let a_Link = Link() - a_Link.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Link.name = body[1].parse(bert: tuple.elements[2]) as? String - a_Link.room_id = body[2].parse(bert: tuple.elements[3]) as? String - a_Link.created = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_Link.type = body[4].parse(bert: tuple.elements[5]) as? AnyObject - a_Link.status = body[5].parse(bert: tuple.elements[6]) as? AnyObject - return a_Link - case "Room": - if body.count != 18 { return nil } - let a_Room = Room() - a_Room.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Room.name = body[1].parse(bert: tuple.elements[2]) as? String - a_Room.links = body[2].parse(bert: tuple.elements[3]) as? [Link] - a_Room.description = body[3].parse(bert: tuple.elements[4]) as? String - a_Room.settings = body[4].parse(bert: tuple.elements[5]) as? [Feature] - a_Room.members = body[5].parse(bert: tuple.elements[6]) as? [Member] - a_Room.admins = body[6].parse(bert: tuple.elements[7]) as? [Member] - a_Room.data = body[7].parse(bert: tuple.elements[8]) as? [Desc] - a_Room.type = body[8].parse(bert: tuple.elements[9]) as? AnyObject - a_Room.tos = body[9].parse(bert: tuple.elements[10]) as? String - a_Room.tos_update = body[10].parse(bert: tuple.elements[11]) as? Int64 - a_Room.unread = body[11].parse(bert: tuple.elements[12]) as? Int64 - a_Room.mentions = body[12].parse(bert: tuple.elements[13]) as? [AnyObject] - a_Room.readers = body[13].parse(bert: tuple.elements[14]) as? [AnyObject] - a_Room.last_msg = body[14].parse(bert: tuple.elements[15]) as? AnyObject - a_Room.update = body[15].parse(bert: tuple.elements[16]) as? Int64 - a_Room.created = body[16].parse(bert: tuple.elements[17]) as? Int64 - a_Room.status = body[17].parse(bert: tuple.elements[18]) as? AnyObject - return a_Room - case "Tag": - if body.count != 4 { return nil } - let a_Tag = Tag() - a_Tag.roster_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Tag.name = body[1].parse(bert: tuple.elements[2]) as? String - a_Tag.color = body[2].parse(bert: tuple.elements[3]) as? String - a_Tag.status = body[3].parse(bert: tuple.elements[4]) as? AnyObject - return a_Tag - case "Star": - if body.count != 6 { return nil } - let a_Star = Star() - a_Star.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Star.client_id = body[1].parse(bert: tuple.elements[2]) as? String - a_Star.roster_id = body[2].parse(bert: tuple.elements[3]) as? Int64 - a_Star.message = body[3].parse(bert: tuple.elements[4]) as? Message - a_Star.tags = body[4].parse(bert: tuple.elements[5]) as? [Tag] - a_Star.status = body[5].parse(bert: tuple.elements[6]) as? AnyObject - return a_Star - case "Typing": - if body.count != 2 { return nil } - let a_Typing = Typing() - a_Typing.phone_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Typing.comments = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_Typing - case "Contact": - if body.count != 14 { return nil } - let a_Contact = Contact() - a_Contact.phone_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Contact.avatar = body[1].parse(bert: tuple.elements[2]) as? String - a_Contact.names = body[2].parse(bert: tuple.elements[3]) as? String - a_Contact.surnames = body[3].parse(bert: tuple.elements[4]) as? String - a_Contact.nick = body[4].parse(bert: tuple.elements[5]) as? String - a_Contact.reader = body[5].parse(bert: tuple.elements[6]) as? AnyObject - a_Contact.unread = body[6].parse(bert: tuple.elements[7]) as? Int64 - a_Contact.last_msg = body[7].parse(bert: tuple.elements[8]) as? Message - a_Contact.update = body[8].parse(bert: tuple.elements[9]) as? Int64 - a_Contact.created = body[9].parse(bert: tuple.elements[10]) as? Int64 - a_Contact.settings = body[10].parse(bert: tuple.elements[11]) as? [Feature] - a_Contact.services = body[11].parse(bert: tuple.elements[12]) as? [Service] - a_Contact.presence = body[12].parse(bert: tuple.elements[13]) as? AnyObject - a_Contact.status = body[13].parse(bert: tuple.elements[14]) as? AnyObject - return a_Contact - case "ExtendedStar": - if body.count != 2 { return nil } - let a_ExtendedStar = ExtendedStar() - a_ExtendedStar.star = body[0].parse(bert: tuple.elements[1]) as? Star - a_ExtendedStar.from = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_ExtendedStar - case "Auth": - if body.count != 14 { return nil } - let a_Auth = Auth() - a_Auth.client_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Auth.dev_key = body[1].parse(bert: tuple.elements[2]) as? String - a_Auth.user_id = body[2].parse(bert: tuple.elements[3]) as? String - a_Auth.phone = body[3].parse(bert: tuple.elements[4]) as? AnyObject - a_Auth.token = body[4].parse(bert: tuple.elements[5]) as? String - a_Auth.type = body[5].parse(bert: tuple.elements[6]) as? StringAtom - a_Auth.sms_code = body[6].parse(bert: tuple.elements[7]) as? String - a_Auth.attempts = body[7].parse(bert: tuple.elements[8]) as? Int64 - a_Auth.services = body[8].parse(bert: tuple.elements[9]) as? [AnyObject] - a_Auth.settings = body[9].parse(bert: tuple.elements[10]) as? [Feature] - a_Auth.push = body[10].parse(bert: tuple.elements[11]) as? String - a_Auth.os = body[11].parse(bert: tuple.elements[12]) as? AnyObject - a_Auth.created = body[12].parse(bert: tuple.elements[13]) as? Int64 - a_Auth.last_online = body[13].parse(bert: tuple.elements[14]) as? Int64 - return a_Auth - case "Roster": - if body.count != 13 { return nil } - let a_Roster = Roster() - a_Roster.id = body[0].parse(bert: tuple.elements[1]) as? AnyObject - a_Roster.names = body[1].parse(bert: tuple.elements[2]) as? String - a_Roster.surnames = body[2].parse(bert: tuple.elements[3]) as? String - a_Roster.email = body[3].parse(bert: tuple.elements[4]) as? String - a_Roster.nick = body[4].parse(bert: tuple.elements[5]) as? String - a_Roster.userlist = body[5].parse(bert: tuple.elements[6]) as? [AnyObject] - a_Roster.roomlist = body[6].parse(bert: tuple.elements[7]) as? [Room] - a_Roster.favorite = body[7].parse(bert: tuple.elements[8]) as? [Star] - a_Roster.tags = body[8].parse(bert: tuple.elements[9]) as? [Tag] - a_Roster.phone = body[9].parse(bert: tuple.elements[10]) as? String - a_Roster.avatar = body[10].parse(bert: tuple.elements[11]) as? String - a_Roster.update = body[11].parse(bert: tuple.elements[12]) as? Int64 - a_Roster.status = body[12].parse(bert: tuple.elements[13]) as? AnyObject - return a_Roster - case "Profile": - if body.count != 8 { return nil } - let a_Profile = Profile() - a_Profile.phone = body[0].parse(bert: tuple.elements[1]) as? String - a_Profile.services = body[1].parse(bert: tuple.elements[2]) as? [Service] - a_Profile.rosters = body[2].parse(bert: tuple.elements[3]) as? [AnyObject] - a_Profile.settings = body[3].parse(bert: tuple.elements[4]) as? [Feature] - a_Profile.update = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_Profile.balance = body[5].parse(bert: tuple.elements[6]) as? Int64 - a_Profile.presence = body[6].parse(bert: tuple.elements[7]) as? AnyObject - a_Profile.status = body[7].parse(bert: tuple.elements[8]) as? AnyObject - return a_Profile - case "Presence": - if body.count != 2 { return nil } - let a_Presence = Presence() - a_Presence.uid = body[0].parse(bert: tuple.elements[1]) as? String - a_Presence.status = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_Presence - case "Friend": - if body.count != 4 { return nil } - let a_Friend = Friend() - a_Friend.phone_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Friend.friend_id = body[1].parse(bert: tuple.elements[2]) as? String - a_Friend.settings = body[2].parse(bert: tuple.elements[3]) as? [Feature] - a_Friend.status = body[3].parse(bert: tuple.elements[4]) as? AnyObject - return a_Friend - case "act": - if body.count != 2 { return nil } - let a_act = act() - a_act.name = body[0].parse(bert: tuple.elements[1]) as? String - a_act.data = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_act - case "Job": - if body.count != 12 { return nil } - let a_Job = Job() - a_Job.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Job.container = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_Job.feed_id = body[2].parse(bert: tuple.elements[3]) as? act - a_Job.prev = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_Job.next = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_Job.context = body[5].parse(bert: tuple.elements[6]) as? AnyObject - a_Job.proc = body[6].parse(bert: tuple.elements[7]) as? AnyObject - a_Job.time = body[7].parse(bert: tuple.elements[8]) as? Int64 - a_Job.data = body[8].parse(bert: tuple.elements[9]) as? AnyObject - a_Job.events = body[9].parse(bert: tuple.elements[10]) as? [messageEvent] - a_Job.settings = body[10].parse(bert: tuple.elements[11]) as? [Feature] - a_Job.status = body[11].parse(bert: tuple.elements[12]) as? AnyObject - return a_Job - case "History": - if body.count != 6 { return nil } - let a_History = History() - a_History.roster_id = body[0].parse(bert: tuple.elements[1]) as? String - a_History.feed = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_History.size = body[2].parse(bert: tuple.elements[3]) as? Int64 - a_History.entity_id = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_History.data = body[4].parse(bert: tuple.elements[5]) as? [AnyObject] - a_History.status = body[5].parse(bert: tuple.elements[6]) as? AnyObject - return a_History - case "error": - if body.count != 1 { return nil } - let a_error = error() - a_error.code = body[0].parse(bert: tuple.elements[1]) as? StringAtom - return a_error - case "ok": - if body.count != 1 { return nil } - let a_ok = ok() - a_ok.code = body[0].parse(bert: tuple.elements[1]) as? String - return a_ok - case "error2": - if body.count != 2 { return nil } - let a_error2 = error2() - a_error2.code = body[0].parse(bert: tuple.elements[1]) as? StringAtom - a_error2.src = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_error2 - case "ok2": - if body.count != 2 { return nil } - let a_ok2 = ok2() - a_ok2.code = body[0].parse(bert: tuple.elements[1]) as? StringAtom - a_ok2.src = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_ok2 - case "io": - if body.count != 2 { return nil } - let a_io = io() - a_io.code = body[0].parse(bert: tuple.elements[1]) as? AnyObject - a_io.data = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_io - case "Ack": - if body.count != 2 { return nil } - let a_Ack = Ack() - a_Ack.table = body[0].parse(bert: tuple.elements[1]) as? StringAtom - a_Ack.id = body[1].parse(bert: tuple.elements[2]) as? String - return a_Ack - case "errors": - if body.count != 2 { return nil } - let a_errors = errors() - a_errors.code = body[0].parse(bert: tuple.elements[1]) as? [AnyObject] - a_errors.data = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_errors - case "PushService": - if body.count != 6 { return nil } - let a_PushService = PushService() - a_PushService.recipients = body[0].parse(bert: tuple.elements[1]) as? [AnyObject] - a_PushService.id = body[1].parse(bert: tuple.elements[2]) as? String - a_PushService.ttl = body[2].parse(bert: tuple.elements[3]) as? Int64 - a_PushService.module = body[3].parse(bert: tuple.elements[4]) as? String - a_PushService.priority = body[4].parse(bert: tuple.elements[5]) as? String - a_PushService.payload = body[5].parse(bert: tuple.elements[6]) as? String - return a_PushService - case "PublishService": - if body.count != 3 { return nil } - let a_PublishService = PublishService() - a_PublishService.message = body[0].parse(bert: tuple.elements[1]) as? String - a_PublishService.topic = body[1].parse(bert: tuple.elements[2]) as? String - a_PublishService.qos = body[2].parse(bert: tuple.elements[3]) as? Int64 - return a_PublishService - default: return nil - } -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Spec/Auth_Spec.swift b/apps/roster/priv/macbert/Spec/Auth_Spec.swift deleted file mode 100644 index 44b108bb9..000000000 --- a/apps/roster/priv/macbert/Spec/Auth_Spec.swift +++ /dev/null @@ -1,47 +0,0 @@ -func get_Auth() -> Model { - return Model(value:Tuple(name:"Auth",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - Model(value:Tuple(name:nil,body:[ - Model(value:Atom(constant:"fake")), - Model(value:Binary())]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"ios")), - Model(value:Atom(constant:"android")), - Model(value:Atom(constant:"web"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/Contact_Spec.swift b/apps/roster/priv/macbert/Spec/Contact_Spec.swift deleted file mode 100644 index 5271e6a07..000000000 --- a/apps/roster/priv/macbert/Spec/Contact_Spec.swift +++ /dev/null @@ -1,51 +0,0 @@ -func get_Contact() -> Model { - return Model(value:Tuple(name:"Contact",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - Model(value:List(constant:nil, model:Model(value:Number())))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - get_Message()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil,model:get_Feature())), - Model(value:List(constant:nil,model:get_Service())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"online")), - Model(value:Atom(constant:"offline")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"request")), - Model(value:Atom(constant:"authorization")), - Model(value:Atom(constant:"ignore")), - Model(value:Atom(constant:"internal")), - Model(value:Atom(constant:"friend")), - Model(value:Atom(constant:"last_msg")), - Model(value:Atom(constant:"ban")), - Model(value:Atom(constant:"banned")), - Model(value:Atom(constant:"deleted"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Desc_Spec.swift b/apps/roster/priv/macbert/Spec/Desc_Spec.swift deleted file mode 100644 index 941751467..000000000 --- a/apps/roster/priv/macbert/Spec/Desc_Spec.swift +++ /dev/null @@ -1,13 +0,0 @@ -func get_Desc() -> Model { - return Model(value:Tuple(name:"Desc",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Binary()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil,model:get_Feature()))]))} diff --git a/apps/roster/priv/macbert/Spec/Feature_Spec.swift b/apps/roster/priv/macbert/Spec/Feature_Spec.swift deleted file mode 100644 index eaf569a31..000000000 --- a/apps/roster/priv/macbert/Spec/Feature_Spec.swift +++ /dev/null @@ -1,8 +0,0 @@ -func get_Feature() -> Model { - return Model(value:Tuple(name:"Feature",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Binary()), - Model(value:Binary()), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/Job_Spec.swift b/apps/roster/priv/macbert/Spec/Job_Spec.swift deleted file mode 100644 index 68ba975da..000000000 --- a/apps/roster/priv/macbert/Spec/Job_Spec.swift +++ /dev/null @@ -1,45 +0,0 @@ -func get_Job() -> Model { - return Model(value:Tuple(name:"Job",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"chain")), - Model(value:List(constant:""))])), - get_act(), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - get_process()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - Model(value:List(constant:nil,model:get_Message()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_messageEvent()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"init")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"pending")), - Model(value:Atom(constant:"stop")), - Model(value:Atom(constant:"complete")), - Model(value:Atom(constant:"restart"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Member_Spec.swift b/apps/roster/priv/macbert/Spec/Member_Spec.swift deleted file mode 100644 index cf7a14112..000000000 --- a/apps/roster/priv/macbert/Spec/Member_Spec.swift +++ /dev/null @@ -1,58 +0,0 @@ -func get_Member() -> Model { - return Model(value:Tuple(name:"Member",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"chain")), - Model(value:Atom(constant:"cur")), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - get_muc(), - get_p2p(), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil)), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Service()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"online")), - Model(value:Atom(constant:"offline"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"admin")), - Model(value:Atom(constant:"member")), - Model(value:Atom(constant:"removed")), - Model(value:Atom(constant:"patch")), - Model(value:Atom(constant:"owner"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Message_Spec.swift b/apps/roster/priv/macbert/Spec/Message_Spec.swift deleted file mode 100644 index 7cde1159f..000000000 --- a/apps/roster/priv/macbert/Spec/Message_Spec.swift +++ /dev/null @@ -1,60 +0,0 @@ -func get_Message() -> Model { - return Model(value:Tuple(name:"Message",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"chain")), - Model(value:Atom(constant:"cur")), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - get_muc(), - get_p2p()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil,model:get_Desc())), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - Model(value:Atom(constant:"sys")), - Model(value:Atom(constant:"reply")), - Model(value:Atom(constant:"forward")), - Model(value:Atom(constant:"read")), - Model(value:Atom(constant:"edited")), - Model(value:Atom(constant:"cursor"))])))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - get_Message()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - Model(value:Binary()), - Model(value:Number())]))))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Number())))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Number())))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"async")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"clear")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"edit"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Profile_Spec.swift b/apps/roster/priv/macbert/Spec/Profile_Spec.swift deleted file mode 100644 index 063942855..000000000 --- a/apps/roster/priv/macbert/Spec/Profile_Spec.swift +++ /dev/null @@ -1,31 +0,0 @@ -func get_Profile() -> Model { - return Model(value:Tuple(name:"Profile",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Service()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_Roster(), - Model(value:Binary())]))))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Number()), - Model(value:Number()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"offline")), - Model(value:Atom(constant:"online")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"remove")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"patch")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"create"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Room_Spec.swift b/apps/roster/priv/macbert/Spec/Room_Spec.swift deleted file mode 100644 index a84bb1410..000000000 --- a/apps/roster/priv/macbert/Spec/Room_Spec.swift +++ /dev/null @@ -1,60 +0,0 @@ -func get_Room() -> Model { - return Model(value:Tuple(name:"Room",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Link()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil,model:get_Feature())), - Model(value:List(constant:nil,model:get_Member())), - Model(value:List(constant:nil,model:get_Member())), - Model(value:List(constant:nil,model:get_Desc())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"group")), - Model(value:Atom(constant:"channel")), - Model(value:Atom(constant:"call"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil, model:Model(value:Number()))), - Model(value:List(constant:nil, model:Model(value:Number()))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - get_Message()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"create")), - Model(value:Atom(constant:"leave")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"remove")), - Model(value:Atom(constant:"removed")), - Model(value:Atom(constant:"join")), - Model(value:Atom(constant:"joined")), - Model(value:Atom(constant:"info")), - Model(value:Atom(constant:"patch")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"last_msg")), - Model(value:Atom(constant:"mute")), - Model(value:Atom(constant:"unmute"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Roster_Spec.swift b/apps/roster/priv/macbert/Spec/Roster_Spec.swift deleted file mode 100644 index 9fc58594c..000000000 --- a/apps/roster/priv/macbert/Spec/Roster_Spec.swift +++ /dev/null @@ -1,45 +0,0 @@ -func get_Roster() -> Model { - return Model(value:Tuple(name:"Roster",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_Contact(), - Model(value:Number())])))), - Model(value:List(constant:nil,model:get_Room())), - Model(value:List(constant:nil,model:get_Star())), - Model(value:List(constant:nil,model:get_Tag())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"create")), - Model(value:Atom(constant:"del")), - Model(value:Atom(constant:"remove")), - Model(value:Atom(constant:"nick")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"list")), - Model(value:Atom(constant:"patch")), - Model(value:Atom(constant:"last_msg"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Schedule_Spec.swift b/apps/roster/priv/macbert/Spec/Schedule_Spec.swift deleted file mode 100644 index 09fbf55e6..000000000 --- a/apps/roster/priv/macbert/Spec/Schedule_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_Schedule() -> Model { - return Model(value:Tuple(name:"Schedule",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Star_Spec.swift b/apps/roster/priv/macbert/Spec/Star_Spec.swift deleted file mode 100644 index a4671f16b..000000000 --- a/apps/roster/priv/macbert/Spec/Star_Spec.swift +++ /dev/null @@ -1,17 +0,0 @@ -func get_Star() -> Model { - return Model(value:Tuple(name:"Star",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - get_Message(), - Model(value:List(constant:nil,model:get_Tag())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"remove"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/boundaryEvent_Spec.swift b/apps/roster/priv/macbert/Spec/boundaryEvent_Spec.swift deleted file mode 100644 index e40ced10e..000000000 --- a/apps/roster/priv/macbert/Spec/boundaryEvent_Spec.swift +++ /dev/null @@ -1,19 +0,0 @@ -func get_boundaryEvent() -> Model { - return Model(value:Tuple(name:"boundaryEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Number()), - Model(value:Number())]))])), - Model(value:Binary()), - Model(value:Binary()), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/hist_Spec.swift b/apps/roster/priv/macbert/Spec/hist_Spec.swift deleted file mode 100644 index 5859163c6..000000000 --- a/apps/roster/priv/macbert/Spec/hist_Spec.swift +++ /dev/null @@ -1,20 +0,0 @@ -func get_hist() -> Model { - return Model(value:Tuple(name:"hist",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil)), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Atom()), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))} diff --git a/apps/roster/priv/macbert/Spec/io_Spec.swift b/apps/roster/priv/macbert/Spec/io_Spec.swift deleted file mode 100644 index 15b432801..000000000 --- a/apps/roster/priv/macbert/Spec/io_Spec.swift +++ /dev/null @@ -1,17 +0,0 @@ -func get_io() -> Model { - return Model(value:Tuple(name:"io",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - get_ok(), - get_error(), - get_ok2(), - get_error2()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - get_Roster(), - Model(value:Tuple(name:nil,body:[ - Model(value:Atom()), - Model(value:Chain(types:[ - Model(value:Binary()), - Model(value:Number())]))]))]))]))} diff --git a/apps/roster/priv/macbert/Spec/messageEvent_Spec.swift b/apps/roster/priv/macbert/Spec/messageEvent_Spec.swift deleted file mode 100644 index c9af1dbf7..000000000 --- a/apps/roster/priv/macbert/Spec/messageEvent_Spec.swift +++ /dev/null @@ -1,16 +0,0 @@ -func get_messageEvent() -> Model { - return Model(value:Tuple(name:"messageEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Number()), - Model(value:Number())]))]))]))} diff --git a/apps/roster/priv/macbert/Spec/ok_Spec.swift b/apps/roster/priv/macbert/Spec/ok_Spec.swift deleted file mode 100644 index 0ad3df7da..000000000 --- a/apps/roster/priv/macbert/Spec/ok_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_ok() -> Model { - return Model(value:Tuple(name:"ok",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/reader_Spec.swift b/apps/roster/priv/macbert/Spec/reader_Spec.swift deleted file mode 100644 index 923d86e70..000000000 --- a/apps/roster/priv/macbert/Spec/reader_Spec.swift +++ /dev/null @@ -1,14 +0,0 @@ -func get_reader() -> Model { - return Model(value:Tuple(name:"reader",body:[ - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:Number(constant:"0")), - Model(value:Number(constant:"1"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/receiveTask_Spec.swift b/apps/roster/priv/macbert/Spec/receiveTask_Spec.swift deleted file mode 100644 index 81cf3c76b..000000000 --- a/apps/roster/priv/macbert/Spec/receiveTask_Spec.swift +++ /dev/null @@ -1,10 +0,0 @@ -func get_receiveTask() -> Model { - return Model(value:Tuple(name:"receiveTask",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/serviceTask_Spec.swift b/apps/roster/priv/macbert/Spec/serviceTask_Spec.swift deleted file mode 100644 index 586517f5d..000000000 --- a/apps/roster/priv/macbert/Spec/serviceTask_Spec.swift +++ /dev/null @@ -1,10 +0,0 @@ -func get_serviceTask() -> Model { - return Model(value:Tuple(name:"serviceTask",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/task_Spec.swift b/apps/roster/priv/macbert/Spec/task_Spec.swift deleted file mode 100644 index d1734eecb..000000000 --- a/apps/roster/priv/macbert/Spec/task_Spec.swift +++ /dev/null @@ -1,10 +0,0 @@ -func get_task() -> Model { - return Model(value:Tuple(name:"task",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/userTask_Spec.swift b/apps/roster/priv/macbert/Spec/userTask_Spec.swift deleted file mode 100644 index 2912b0912..000000000 --- a/apps/roster/priv/macbert/Spec/userTask_Spec.swift +++ /dev/null @@ -1,10 +0,0 @@ -func get_userTask() -> Model { - return Model(value:Tuple(name:"userTask",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/json-bert.js b/apps/roster/priv/macbert/json-bert.js index 8a7b1286c..00feb50fe 100644 --- a/apps/roster/priv/macbert/json-bert.js +++ b/apps/roster/priv/macbert/json-bert.js @@ -39,6 +39,669 @@ function encode(x) { } else return scalar(x); } +function encwriter(d) { + var tup = atom('writer'); + var id = 'id' in d && d.id ? encode(d.id) : nil(); + var count = 'count' in d && d.count ? number(d.count) : nil(); + var cache = 'cache' in d && d.cache ? encode(d.cache) : nil(); + var args = 'args' in d && d.args ? encode(d.args) : nil(); + var first = 'first' in d && d.first ? encode(d.first) : nil(); + return tuple(tup,id,count,cache,args,first); } + +function lenwriter() { return 6; } +function decwriter(d) { + var r={}; r.tup = 'writer'; + r.id = d && d.v[1] ? decode(d.v[1]) : undefined; + r.count = d && d.v[2] ? d.v[2].v : undefined; + r.cache = d && d.v[3] ? decode(d.v[3]) : undefined; + r.args = d && d.v[4] ? decode(d.v[4]) : undefined; + r.first = d && d.v[5] ? decode(d.v[5]) : undefined; + return clean(r); } + +function encreader(d) { + var tup = atom('reader'); + var id = 'id' in d && d.id ? encode(d.id) : nil(); + var pos = 'pos' in d && d.pos ? number(d.pos) : nil(); + var cache = 'cache' in d && d.cache ? encode(d.cache) : nil(); + var args = 'args' in d && d.args ? encode(d.args) : nil(); + var feed = 'feed' in d && d.feed ? encode(d.feed) : nil(); + var dir = 'dir' in d && d.dir ? encode(d.dir) : nil(); + return tuple(tup,id,pos,cache,args,feed,dir); } + +function lenreader() { return 7; } +function decreader(d) { + var r={}; r.tup = 'reader'; + r.id = d && d.v[1] ? decode(d.v[1]) : undefined; + r.pos = d && d.v[2] ? d.v[2].v : undefined; + r.cache = d && d.v[3] ? decode(d.v[3]) : undefined; + r.args = d && d.v[4] ? decode(d.v[4]) : undefined; + r.feed = d && d.v[5] ? decode(d.v[5]) : undefined; + r.dir = d && d.v[6] ? decode(d.v[6]) : undefined; + return clean(r); } + +function enccur(d) { + var tup = atom('cur'); + var id = 'id' in d && d.id ? encode(d.id) : nil(); + var top = 'top' in d && d.top ? number(d.top) : nil(); + var bot = 'bot' in d && d.bot ? number(d.bot) : nil(); + var dir = 'dir' in d && d.dir ? encode(d.dir) : nil(); + var reader = 'reader' in d && d.reader ? encode(d.reader) : nil(); + var writer = 'writer' in d && d.writer ? encode(d.writer) : nil(); + var left = 'left' in d && d.left ? encode(d.left) : nil(); + var right = 'right' in d && d.right ? encode(d.right) : nil(); + var args = []; if ('args' in d && d.args) + { d.args.forEach(function(x){ + args.push(encode(x))}); + args={t:108,v:args}; } else { args = nil() }; + var money = 'money' in d && d.money ? encode(d.money) : nil(); + var status = 'status' in d && d.status ? encode(d.status) : nil(); + return tuple(tup,id,top,bot,dir,reader,writer,left,right,args,money,status); } + +function lencur() { return 12; } +function deccur(d) { + var r={}; r.tup = 'cur'; + r.id = d && d.v[1] ? decode(d.v[1]) : undefined; + r.top = d && d.v[2] ? d.v[2].v : undefined; + r.bot = d && d.v[3] ? d.v[3].v : undefined; + r.dir = d && d.v[4] ? decode(d.v[4]) : undefined; + r.reader = d && d.v[5] ? decode(d.v[5]) : undefined; + r.writer = d && d.v[6] ? decode(d.v[6]) : undefined; + r.left = d && d.v[7] ? decode(d.v[7]) : undefined; + r.right = d && d.v[8] ? decode(d.v[8]) : undefined; + r.args = []; + (d && d.v[9] && d.v[9].v) ? + d.v[9].v.forEach(function(x){r.args.push(decode(x))}) : + r.args = undefined; + r.money = d && d.v[10] ? decode(d.v[10]) : undefined; + r.status = d && d.v[11] ? decode(d.v[11]) : undefined; + return clean(r); } + +function enciter(d) { + var tup = atom('iter'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + var container = 'container' in d && d.container ? atom(d.container) : nil(); + var feed = 'feed' in d && d.feed ? encode(d.feed) : nil(); + var next = 'next' in d && d.next ? number(d.next) : nil(); + var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); + return tuple(tup,id,container,feed,next,prev); } + +function leniter() { return 6; } +function deciter(d) { + var r={}; r.tup = 'iter'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + r.container = d && d.v[2] ? d.v[2].v : undefined; + r.feed = d && d.v[3] ? decode(d.v[3]) : undefined; + r.next = d && d.v[4] ? d.v[4].v : undefined; + r.prev = d && d.v[5] ? d.v[5].v : undefined; + return clean(r); } + +function enccontainer(d) { + var tup = atom('container'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + var top = 'top' in d && d.top ? number(d.top) : nil(); + var rear = 'rear' in d && d.rear ? number(d.rear) : nil(); + var count = 'count' in d && d.count ? number(d.count) : nil(); + return tuple(tup,id,top,rear,count); } + +function lencontainer() { return 5; } +function deccontainer(d) { + var r={}; r.tup = 'container'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + r.top = d && d.v[2] ? d.v[2].v : undefined; + r.rear = d && d.v[3] ? d.v[3].v : undefined; + r.count = d && d.v[4] ? d.v[4].v : undefined; + return clean(r); } + +function enciterator(d) { + var tup = atom('iterator'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + var container = 'container' in d && d.container ? atom(d.container) : nil(); + var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); + var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); + var next = 'next' in d && d.next ? number(d.next) : nil(); + var feeds = []; if ('feeds' in d && d.feeds) + { d.feeds.forEach(function(x){ + feeds.push(encode(x))}); + feeds={t:108,v:feeds}; } else { feeds = nil() }; + return tuple(tup,id,container,feed_id,prev,next,feeds); } + +function leniterator() { return 7; } +function deciterator(d) { + var r={}; r.tup = 'iterator'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + r.container = d && d.v[2] ? d.v[2].v : undefined; + r.feed_id = d && d.v[3] ? decode(d.v[3]) : undefined; + r.prev = d && d.v[4] ? d.v[4].v : undefined; + r.next = d && d.v[5] ? d.v[5].v : undefined; + r.feeds = []; + (d && d.v[6] && d.v[6].v) ? + d.v[6].v.forEach(function(x){r.feeds.push(decode(x))}) : + r.feeds = undefined; + return clean(r); } + +function enclog(d) { + var tup = atom('log'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + var top = 'top' in d && d.top ? number(d.top) : nil(); + var rear = 'rear' in d && d.rear ? number(d.rear) : nil(); + var count = 'count' in d && d.count ? number(d.count) : nil(); + return tuple(tup,id,top,rear,count); } + +function lenlog() { return 5; } +function declog(d) { + var r={}; r.tup = 'log'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + r.top = d && d.v[2] ? d.v[2].v : undefined; + r.rear = d && d.v[3] ? d.v[3].v : undefined; + r.count = d && d.v[4] ? d.v[4].v : undefined; + return clean(r); } + +function encoperation(d) { + var tup = atom('operation'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + var container = 'container' in d && d.container ? atom(d.container) : nil(); + var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); + var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); + var next = 'next' in d && d.next ? number(d.next) : nil(); + var feeds = []; if ('feeds' in d && d.feeds) + { d.feeds.forEach(function(x){ + feeds.push(encode(x))}); + feeds={t:108,v:feeds}; } else { feeds = nil() }; + var body = 'body' in d && d.body ? encode(d.body) : nil(); + var name = 'name' in d && d.name ? encode(d.name) : nil(); + var status = 'status' in d && d.status ? encode(d.status) : nil(); + return tuple(tup,id,container,feed_id,prev,next,feeds,body,name,status); } + +function lenoperation() { return 10; } +function decoperation(d) { + var r={}; r.tup = 'operation'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + r.container = d && d.v[2] ? d.v[2].v : undefined; + r.feed_id = d && d.v[3] ? decode(d.v[3]) : undefined; + r.prev = d && d.v[4] ? d.v[4].v : undefined; + r.next = d && d.v[5] ? d.v[5].v : undefined; + r.feeds = []; + (d && d.v[6] && d.v[6].v) ? + d.v[6].v.forEach(function(x){r.feeds.push(decode(x))}) : + r.feeds = undefined; + r.body = d && d.v[7] ? decode(d.v[7]) : undefined; + r.name = d && d.v[8] ? decode(d.v[8]) : undefined; + r.status = d && d.v[9] ? decode(d.v[9]) : undefined; + return clean(r); } + +function enckvs(d) { + var tup = atom('kvs'); + var mod = 'mod' in d && d.mod ? encode(d.mod) : nil(); + return tuple(tup,mod); } + +function lenkvs() { return 2; } +function deckvs(d) { + var r={}; r.tup = 'kvs'; + r.mod = d && d.v[1] ? decode(d.v[1]) : undefined; + return clean(r); } + +function encfeed(d) { + var tup = atom('feed'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + var top = 'top' in d && d.top ? number(d.top) : nil(); + var rear = 'rear' in d && d.rear ? number(d.rear) : nil(); + var count = 'count' in d && d.count ? number(d.count) : nil(); + var aclver = 'aclver' in d && d.aclver ? encode(d.aclver) : nil(); + return tuple(tup,id,top,rear,count,aclver); } + +function lenfeed() { return 6; } +function decfeed(d) { + var r={}; r.tup = 'feed'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + r.top = d && d.v[2] ? d.v[2].v : undefined; + r.rear = d && d.v[3] ? d.v[3].v : undefined; + r.count = d && d.v[4] ? d.v[4].v : undefined; + r.aclver = d && d.v[5] ? decode(d.v[5]) : undefined; + return clean(r); } + +function enctask(d) { + var tup = atom('task'); + var name = 'name' in d && d.name ? atom(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var prompt = []; if ('prompt' in d && d.prompt) + { d.prompt.forEach(function(x){ + prompt.push(encode(x))}); + prompt={t:108,v:prompt}; } else { prompt = nil() }; + var roles = 'roles' in d && d.roles ? bin(d.roles) : nil(); + return tuple(tup,name,module,prompt,roles); } + +function lentask() { return 5; } +function dectask(d) { + var r={}; r.tup = 'task'; + r.name = d && d.v[1] ? d.v[1].v : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.prompt = []; + (d && d.v[3] && d.v[3].v) ? + d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : + r.prompt = undefined; + r.roles = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; + return clean(r); } + +function encuserTask(d) { + var tup = atom('userTask'); + var name = 'name' in d && d.name ? atom(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var prompt = []; if ('prompt' in d && d.prompt) + { d.prompt.forEach(function(x){ + prompt.push(encode(x))}); + prompt={t:108,v:prompt}; } else { prompt = nil() }; + var roles = 'roles' in d && d.roles ? bin(d.roles) : nil(); + return tuple(tup,name,module,prompt,roles); } + +function lenuserTask() { return 5; } +function decuserTask(d) { + var r={}; r.tup = 'userTask'; + r.name = d && d.v[1] ? d.v[1].v : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.prompt = []; + (d && d.v[3] && d.v[3].v) ? + d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : + r.prompt = undefined; + r.roles = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; + return clean(r); } + +function encserviceTask(d) { + var tup = atom('serviceTask'); + var name = 'name' in d && d.name ? atom(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var prompt = []; if ('prompt' in d && d.prompt) + { d.prompt.forEach(function(x){ + prompt.push(encode(x))}); + prompt={t:108,v:prompt}; } else { prompt = nil() }; + var roles = 'roles' in d && d.roles ? bin(d.roles) : nil(); + return tuple(tup,name,module,prompt,roles); } + +function lenserviceTask() { return 5; } +function decserviceTask(d) { + var r={}; r.tup = 'serviceTask'; + r.name = d && d.v[1] ? d.v[1].v : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.prompt = []; + (d && d.v[3] && d.v[3].v) ? + d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : + r.prompt = undefined; + r.roles = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; + return clean(r); } + +function encreceiveTask(d) { + var tup = atom('receiveTask'); + var name = 'name' in d && d.name ? atom(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var prompt = []; if ('prompt' in d && d.prompt) + { d.prompt.forEach(function(x){ + prompt.push(encode(x))}); + prompt={t:108,v:prompt}; } else { prompt = nil() }; + var roles = 'roles' in d && d.roles ? bin(d.roles) : nil(); + return tuple(tup,name,module,prompt,roles); } + +function lenreceiveTask() { return 5; } +function decreceiveTask(d) { + var r={}; r.tup = 'receiveTask'; + r.name = d && d.v[1] ? d.v[1].v : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.prompt = []; + (d && d.v[3] && d.v[3].v) ? + d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : + r.prompt = undefined; + r.roles = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; + return clean(r); } + +function encmessageEvent(d) { + var tup = atom('messageEvent'); + var name = 'name' in d && d.name ? encode(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var prompt = []; if ('prompt' in d && d.prompt) + { d.prompt.forEach(function(x){ + prompt.push(encode(x))}); + prompt={t:108,v:prompt}; } else { prompt = nil() }; + var payload = 'payload' in d && d.payload ? bin(d.payload) : nil(); + var timeout = 'timeout' in d && d.timeout ? encode(d.timeout) : nil(); + return tuple(tup,name,module,prompt,payload,timeout); } + +function lenmessageEvent() { return 6; } +function decmessageEvent(d) { + var r={}; r.tup = 'messageEvent'; + r.name = d && d.v[1] ? decode(d.v[1]) : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.prompt = []; + (d && d.v[3] && d.v[3].v) ? + d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : + r.prompt = undefined; + r.payload = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; + r.timeout = d && d.v[5] ? decode(d.v[5]) : undefined; + return clean(r); } + +function encboundaryEvent(d) { + var tup = atom('boundaryEvent'); + var name = 'name' in d && d.name ? atom(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var prompt = []; if ('prompt' in d && d.prompt) + { d.prompt.forEach(function(x){ + prompt.push(encode(x))}); + prompt={t:108,v:prompt}; } else { prompt = nil() }; + var payload = 'payload' in d && d.payload ? bin(d.payload) : nil(); + var timeout = 'timeout' in d && d.timeout ? encode(d.timeout) : nil(); + var timeDate = 'timeDate' in d && d.timeDate ? bin(d.timeDate) : nil(); + var timeDuration = 'timeDuration' in d && d.timeDuration ? bin(d.timeDuration) : nil(); + var timeCycle = 'timeCycle' in d && d.timeCycle ? bin(d.timeCycle) : nil(); + return tuple(tup,name,module,prompt,payload,timeout,timeDate,timeDuration,timeCycle); } + +function lenboundaryEvent() { return 9; } +function decboundaryEvent(d) { + var r={}; r.tup = 'boundaryEvent'; + r.name = d && d.v[1] ? d.v[1].v : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.prompt = []; + (d && d.v[3] && d.v[3].v) ? + d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : + r.prompt = undefined; + r.payload = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; + r.timeout = d && d.v[5] ? decode(d.v[5]) : undefined; + r.timeDate = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; + r.timeDuration = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; + r.timeCycle = d && d.v[8] ? utf8_arr(d.v[8].v) : undefined; + return clean(r); } + +function enctimeoutEvent(d) { + var tup = atom('timeoutEvent'); + var name = 'name' in d && d.name ? atom(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var prompt = []; if ('prompt' in d && d.prompt) + { d.prompt.forEach(function(x){ + prompt.push(encode(x))}); + prompt={t:108,v:prompt}; } else { prompt = nil() }; + var payload = 'payload' in d && d.payload ? bin(d.payload) : nil(); + var timeout = 'timeout' in d && d.timeout ? encode(d.timeout) : nil(); + var timeDate = 'timeDate' in d && d.timeDate ? bin(d.timeDate) : nil(); + var timeDuration = 'timeDuration' in d && d.timeDuration ? bin(d.timeDuration) : nil(); + var timeCycle = 'timeCycle' in d && d.timeCycle ? bin(d.timeCycle) : nil(); + return tuple(tup,name,module,prompt,payload,timeout,timeDate,timeDuration,timeCycle); } + +function lentimeoutEvent() { return 9; } +function dectimeoutEvent(d) { + var r={}; r.tup = 'timeoutEvent'; + r.name = d && d.v[1] ? d.v[1].v : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.prompt = []; + (d && d.v[3] && d.v[3].v) ? + d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : + r.prompt = undefined; + r.payload = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; + r.timeout = d && d.v[5] ? decode(d.v[5]) : undefined; + r.timeDate = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; + r.timeDuration = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; + r.timeCycle = d && d.v[8] ? utf8_arr(d.v[8].v) : undefined; + return clean(r); } + +function encbeginEvent(d) { + var tup = atom('beginEvent'); + var name = 'name' in d && d.name ? atom(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var prompt = []; if ('prompt' in d && d.prompt) + { d.prompt.forEach(function(x){ + prompt.push(encode(x))}); + prompt={t:108,v:prompt}; } else { prompt = nil() }; + return tuple(tup,name,module,prompt); } + +function lenbeginEvent() { return 4; } +function decbeginEvent(d) { + var r={}; r.tup = 'beginEvent'; + r.name = d && d.v[1] ? d.v[1].v : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.prompt = []; + (d && d.v[3] && d.v[3].v) ? + d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : + r.prompt = undefined; + return clean(r); } + +function encendEvent(d) { + var tup = atom('endEvent'); + var name = 'name' in d && d.name ? atom(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var prompt = []; if ('prompt' in d && d.prompt) + { d.prompt.forEach(function(x){ + prompt.push(encode(x))}); + prompt={t:108,v:prompt}; } else { prompt = nil() }; + return tuple(tup,name,module,prompt); } + +function lenendEvent() { return 4; } +function decendEvent(d) { + var r={}; r.tup = 'endEvent'; + r.name = d && d.v[1] ? d.v[1].v : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.prompt = []; + (d && d.v[3] && d.v[3].v) ? + d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : + r.prompt = undefined; + return clean(r); } + +function encsequenceFlow(d) { + var tup = atom('sequenceFlow'); + var source = 'source' in d && d.source ? atom(d.source) : nil(); + var target = 'target' in d && d.target ? encode(d.target) : nil(); + return tuple(tup,source,target); } + +function lensequenceFlow() { return 3; } +function decsequenceFlow(d) { + var r={}; r.tup = 'sequenceFlow'; + r.source = d && d.v[1] ? d.v[1].v : undefined; + r.target = d && d.v[2] ? decode(d.v[2]) : undefined; + return clean(r); } + +function enchist(d) { + var tup = atom('hist'); + var container = 'container' in d && d.container ? atom(d.container) : nil(); + var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); + var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); + var next = 'next' in d && d.next ? number(d.next) : nil(); + var feeds = []; if ('feeds' in d && d.feeds) + { d.feeds.forEach(function(x){ + feeds.push(encode(x))}); + feeds={t:108,v:feeds}; } else { feeds = nil() }; + var name = 'name' in d && d.name ? bin(d.name) : nil(); + var task = 'task' in d && d.task ? encode(d.task) : nil(); + var docs = []; if ('docs' in d && d.docs) + { d.docs.forEach(function(x){ + docs.push(encode(x))}); + docs={t:108,v:docs}; } else { docs = nil() }; + var time = 'time' in d && d.time ? encode(d.time) : nil(); + return tuple(tup,container,feed_id,prev,next,feeds,name,task,docs,time); } + +function lenhist() { return 10; } +function dechist(d) { + var r={}; r.tup = 'hist'; + r.container = d && d.v[1] ? d.v[1].v : undefined; + r.feed_id = d && d.v[2] ? decode(d.v[2]) : undefined; + r.prev = d && d.v[3] ? d.v[3].v : undefined; + r.next = d && d.v[4] ? d.v[4].v : undefined; + r.feeds = []; + (d && d.v[5] && d.v[5].v) ? + d.v[5].v.forEach(function(x){r.feeds.push(decode(x))}) : + r.feeds = undefined; + r.name = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; + r.task = d && d.v[7] ? decode(d.v[7]) : undefined; + r.docs = []; + (d && d.v[8] && d.v[8].v) ? + d.v[8].v.forEach(function(x){r.docs.push(decode(x))}) : + r.docs = undefined; + r.time = d && d.v[9] ? decode(d.v[9]) : undefined; + return clean(r); } + +function encprocess(d) { + var tup = atom('process'); + var container = 'container' in d && d.container ? atom(d.container) : nil(); + var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); + var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); + var next = 'next' in d && d.next ? number(d.next) : nil(); + var name = 'name' in d && d.name ? encode(d.name) : nil(); + var feeds = []; if ('feeds' in d && d.feeds) + { d.feeds.forEach(function(x){ + feeds.push(encode(x))}); + feeds={t:108,v:feeds}; } else { feeds = nil() }; + var roles = []; if ('roles' in d && d.roles) + { d.roles.forEach(function(x){ + roles.push(encode(x))}); + roles={t:108,v:roles}; } else { roles = nil() }; + var tasks = []; if ('tasks' in d && d.tasks) + { d.tasks.forEach(function(x){ + tasks.push(encode(x))}); + tasks={t:108,v:tasks}; } else { tasks = nil() }; + var events = []; if ('events' in d && d.events) + { d.events.forEach(function(x){ + events.push(encode(x))}); + events={t:108,v:events}; } else { events = nil() }; + var hist = 'hist' in d && d.hist ? encode(d.hist) : nil(); + var flows = []; if ('flows' in d && d.flows) + { d.flows.forEach(function(x){ + flows.push(encode(x))}); + flows={t:108,v:flows}; } else { flows = nil() }; + var rules = 'rules' in d && d.rules ? encode(d.rules) : nil(); + var docs = []; if ('docs' in d && d.docs) + { d.docs.forEach(function(x){ + docs.push(encode(x))}); + docs={t:108,v:docs}; } else { docs = nil() }; + var options = 'options' in d && d.options ? encode(d.options) : nil(); + var task = 'task' in d && d.task ? atom(d.task) : nil(); + var timer = 'timer' in d && d.timer ? encode(d.timer) : nil(); + var notifications = 'notifications' in d && d.notifications ? encode(d.notifications) : nil(); + var result = 'result' in d && d.result ? bin(d.result) : nil(); + var started = 'started' in d && d.started ? encode(d.started) : nil(); + var beginEvent = 'beginEvent' in d && d.beginEvent ? atom(d.beginEvent) : nil(); + var endEvent = 'endEvent' in d && d.endEvent ? atom(d.endEvent) : nil(); + return tuple(tup,container,feed_id,prev,next,name,feeds,roles,tasks,events,hist, + flows,rules,docs,options,task,timer,notifications,result,started,beginEvent,endEvent); } + +function lenprocess() { return 22; } +function decprocess(d) { + var r={}; r.tup = 'process'; + r.container = d && d.v[1] ? d.v[1].v : undefined; + r.feed_id = d && d.v[2] ? decode(d.v[2]) : undefined; + r.prev = d && d.v[3] ? d.v[3].v : undefined; + r.next = d && d.v[4] ? d.v[4].v : undefined; + r.name = d && d.v[5] ? decode(d.v[5]) : undefined; + r.feeds = []; + (d && d.v[6] && d.v[6].v) ? + d.v[6].v.forEach(function(x){r.feeds.push(decode(x))}) : + r.feeds = undefined; + r.roles = []; + (d && d.v[7] && d.v[7].v) ? + d.v[7].v.forEach(function(x){r.roles.push(decode(x))}) : + r.roles = undefined; + r.tasks = []; + (d && d.v[8] && d.v[8].v) ? + d.v[8].v.forEach(function(x){r.tasks.push(decode(x))}) : + r.tasks = undefined; + r.events = []; + (d && d.v[9] && d.v[9].v) ? + d.v[9].v.forEach(function(x){r.events.push(decode(x))}) : + r.events = undefined; + r.hist = d && d.v[10] ? decode(d.v[10]) : undefined; + r.flows = []; + (d && d.v[11] && d.v[11].v) ? + d.v[11].v.forEach(function(x){r.flows.push(decode(x))}) : + r.flows = undefined; + r.rules = d && d.v[12] ? decode(d.v[12]) : undefined; + r.docs = []; + (d && d.v[13] && d.v[13].v) ? + d.v[13].v.forEach(function(x){r.docs.push(decode(x))}) : + r.docs = undefined; + r.options = d && d.v[14] ? decode(d.v[14]) : undefined; + r.task = d && d.v[15] ? d.v[15].v : undefined; + r.timer = d && d.v[16] ? decode(d.v[16]) : undefined; + r.notifications = d && d.v[17] ? decode(d.v[17]) : undefined; + r.result = d && d.v[18] ? utf8_arr(d.v[18].v) : undefined; + r.started = d && d.v[19] ? decode(d.v[19]) : undefined; + r.beginEvent = d && d.v[20] ? d.v[20].v : undefined; + r.endEvent = d && d.v[21] ? d.v[21].v : undefined; + return clean(r); } + +function encComp(d) { + var tup = atom('Comp'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + return tuple(tup,id); } + +function lenComp() { return 2; } +function decComp(d) { + var r={}; r.tup = 'Comp'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + return clean(r); } + +function encProc(d) { + var tup = atom('Proc'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + return tuple(tup,id); } + +function lenProc() { return 2; } +function decProc(d) { + var r={}; r.tup = 'Proc'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + return clean(r); } + +function encLoad(d) { + var tup = atom('Load'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + return tuple(tup,id); } + +function lenLoad() { return 2; } +function decLoad(d) { + var r={}; r.tup = 'Load'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + return clean(r); } + +function encHist(d) { + var tup = atom('Hist'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + return tuple(tup,id); } + +function lenHist() { return 2; } +function decHist(d) { + var r={}; r.tup = 'Hist'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + return clean(r); } + +function encMake(d) { + var tup = atom('Make'); + var proc = 'proc' in d && d.proc ? encode(d.proc) : nil(); + var docs = []; if ('docs' in d && d.docs) + { d.docs.forEach(function(x){ + docs.push(encode(x))}); + docs={t:108,v:docs}; } else { docs = nil() }; + return tuple(tup,proc,docs); } + +function lenMake() { return 3; } +function decMake(d) { + var r={}; r.tup = 'Make'; + r.proc = d && d.v[1] ? decode(d.v[1]) : undefined; + r.docs = []; + (d && d.v[2] && d.v[2].v) ? + d.v[2].v.forEach(function(x){r.docs.push(decode(x))}) : + r.docs = undefined; + return clean(r); } + +function encAmen(d) { + var tup = atom('Amen'); + var id = 'id' in d && d.id ? number(d.id) : nil(); + var docs = []; if ('docs' in d && d.docs) + { d.docs.forEach(function(x){ + docs.push(encode(x))}); + docs={t:108,v:docs}; } else { docs = nil() }; + return tuple(tup,id,docs); } + +function lenAmen() { return 3; } +function decAmen(d) { + var r={}; r.tup = 'Amen'; + r.id = d && d.v[1] ? d.v[1].v : undefined; + r.docs = []; + (d && d.v[2] && d.v[2].v) ? + d.v[2].v.forEach(function(x){r.docs.push(decode(x))}) : + r.docs = undefined; + return clean(r); } + function encchain(d) { var tup = atom('chain'); var id = 'id' in d && d.id ? number(d.id) : nil(); @@ -203,7 +866,7 @@ function encMember(d) { var names = 'names' in d && d.names ? bin(d.names) : nil(); var surnames = 'surnames' in d && d.surnames ? bin(d.surnames) : nil(); var alias = 'alias' in d && d.alias ? bin(d.alias) : nil(); - var reader = 'reader' in d && d.reader ? number(d.reader) : nil(); + var reader = 'reader' in d && d.reader ? encode(d.reader) : nil(); var update = 'update' in d && d.update ? number(d.update) : nil(); var settings = []; if ('settings' in d && d.settings) { d.settings.forEach(function(x){ @@ -235,7 +898,7 @@ function decMember(d) { r.names = d && d.v[9] ? utf8_arr(d.v[9].v) : undefined; r.surnames = d && d.v[10] ? utf8_arr(d.v[10].v) : undefined; r.alias = d && d.v[11] ? utf8_arr(d.v[11].v) : undefined; - r.reader = d && d.v[12] ? d.v[12].v : undefined; + r.reader = d && d.v[12] ? decode(d.v[12]) : undefined; r.update = d && d.v[13] ? d.v[13].v : undefined; r.settings = []; (d && d.v[14] && d.v[14].v) ? @@ -647,7 +1310,7 @@ function decAuth(d) { r.user_id = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; r.phone = d && d.v[4] ? decode(d.v[4]) : undefined; r.token = d && d.v[5] ? utf8_arr(d.v[5].v) : undefined; - r.type = d && d.v[6] ? d.v[6].v : undefined; + r.type = d && d.v[6] ? decode(d.v[6]) : undefined; r.sms_code = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; r.attempts = d && d.v[8] ? d.v[8].v : undefined; r.services = []; @@ -927,14 +1590,14 @@ function decIndex(d) { function encWhitelist(d) { var tup = atom('Whitelist'); - var phone = 'phone' in d && d.phone ? bin(d.phone) : nil(); + var phone = 'phone' in d && d.phone ? encode(d.phone) : nil(); var created = 'created' in d && d.created ? number(d.created) : nil(); return tuple(tup,phone,created); } function lenWhitelist() { return 3; } function decWhitelist(d) { var r={}; r.tup = 'Whitelist'; - r.phone = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; + r.phone = d && d.v[1] ? decode(d.v[1]) : undefined; r.created = d && d.v[2] ? d.v[2].v : undefined; return clean(r); } @@ -951,13 +1614,13 @@ function decerror(d) { function encok(d) { var tup = atom('ok'); - var code = 'code' in d && d.code ? bin(d.code) : nil(); + var code = 'code' in d && d.code ? atom(d.code) : nil(); return tuple(tup,code); } function lenok() { return 2; } function decok(d) { var r={}; r.tup = 'ok'; - r.code = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; + r.code = d && d.v[1] ? decode(d.v[1]) : undefined; return clean(r); } function encerror2(d) { @@ -1075,14 +1738,264 @@ function decPublishService(d) { function encFakeNumbers(d) { var tup = atom('FakeNumbers'); - var phone = 'phone' in d && d.phone ? bin(d.phone) : nil(); - var created = 'created' in d && d.created ? number(d.created) : nil(); + var phone = 'phone' in d && d.phone ? encode(d.phone) : nil(); + var created = 'created' in d && d.created ? encode(d.created) : nil(); return tuple(tup,phone,created); } function lenFakeNumbers() { return 3; } function decFakeNumbers(d) { var r={}; r.tup = 'FakeNumbers'; - r.phone = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.created = d && d.v[2] ? d.v[2].v : undefined; + r.phone = d && d.v[1] ? decode(d.v[1]) : undefined; + r.created = d && d.v[2] ? decode(d.v[2]) : undefined; + return clean(r); } + +function enchandler(d) { + var tup = atom('handler'); + var name = 'name' in d && d.name ? atom(d.name) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var class = 'class' in d && d.class ? encode(d.class) : nil(); + var group = 'group' in d && d.group ? atom(d.group) : nil(); + var config = 'config' in d && d.config ? encode(d.config) : nil(); + var state = 'state' in d && d.state ? encode(d.state) : nil(); + var seq = 'seq' in d && d.seq ? encode(d.seq) : nil(); + return tuple(tup,name,module,class,group,config,state,seq); } + +function lenhandler() { return 8; } +function dechandler(d) { + var r={}; r.tup = 'handler'; + r.name = d && d.v[1] ? d.v[1].v : undefined; + r.module = d && d.v[2] ? d.v[2].v : undefined; + r.class = d && d.v[3] ? decode(d.v[3]) : undefined; + r.group = d && d.v[4] ? d.v[4].v : undefined; + r.config = d && d.v[5] ? decode(d.v[5]) : undefined; + r.state = d && d.v[6] ? decode(d.v[6]) : undefined; + r.seq = d && d.v[7] ? decode(d.v[7]) : undefined; + return clean(r); } + +function encpi(d) { + var tup = atom('pi'); + var name = 'name' in d && d.name ? encode(d.name) : nil(); + var table = 'table' in d && d.table ? atom(d.table) : nil(); + var sup = 'sup' in d && d.sup ? atom(d.sup) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var state = 'state' in d && d.state ? encode(d.state) : nil(); + return tuple(tup,name,table,sup,module,state); } + +function lenpi() { return 6; } +function decpi(d) { + var r={}; r.tup = 'pi'; + r.name = d && d.v[1] ? decode(d.v[1]) : undefined; + r.table = d && d.v[2] ? d.v[2].v : undefined; + r.sup = d && d.v[3] ? d.v[3].v : undefined; + r.module = d && d.v[4] ? d.v[4].v : undefined; + r.state = d && d.v[5] ? decode(d.v[5]) : undefined; + return clean(r); } + +function enccx(d) { + var tup = atom('cx'); + var handlers = []; if ('handlers' in d && d.handlers) + { d.handlers.forEach(function(x){ + handlers.push(encode(x))}); + handlers={t:108,v:handlers}; } else { handlers = nil() }; + var actions = []; if ('actions' in d && d.actions) + { d.actions.forEach(function(x){ + actions.push(encode(x))}); + actions={t:108,v:actions}; } else { actions = nil() }; + var req = 'req' in d && d.req ? encode(d.req) : nil(); + var module = 'module' in d && d.module ? atom(d.module) : nil(); + var lang = 'lang' in d && d.lang ? atom(d.lang) : nil(); + var path = 'path' in d && d.path ? bin(d.path) : nil(); + var session = 'session' in d && d.session ? bin(d.session) : nil(); + var formatter = 'formatter' in d && d.formatter ? atom(d.formatter) : nil(); + var params = []; if ('params' in d && d.params) + { d.params.forEach(function(x){ + params.push(encode(x))}); + params={t:108,v:params}; } else { params = nil() }; + var node = 'node' in d && d.node ? atom(d.node) : nil(); + var client_pid = 'client_pid' in d && d.client_pid ? encode(d.client_pid) : nil(); + var state = 'state' in d && d.state ? encode(d.state) : nil(); + var from = 'from' in d && d.from ? bin(d.from) : nil(); + var vsn = 'vsn' in d && d.vsn ? bin(d.vsn) : nil(); + return tuple(tup,handlers,actions,req,module,lang,path,session,formatter,params,node, + client_pid,state,from,vsn); } + +function lencx() { return 15; } +function deccx(d) { + var r={}; r.tup = 'cx'; + r.handlers = []; + (d && d.v[1] && d.v[1].v) ? + d.v[1].v.forEach(function(x){r.handlers.push(decode(x))}) : + r.handlers = undefined; + r.actions = []; + (d && d.v[2] && d.v[2].v) ? + d.v[2].v.forEach(function(x){r.actions.push(decode(x))}) : + r.actions = undefined; + r.req = d && d.v[3] ? decode(d.v[3]) : undefined; + r.module = d && d.v[4] ? d.v[4].v : undefined; + r.lang = d && d.v[5] ? d.v[5].v : undefined; + r.path = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; + r.session = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; + r.formatter = d && d.v[8] ? decode(d.v[8]) : undefined; + r.params = []; + (d && d.v[9] && d.v[9].v) ? + d.v[9].v.forEach(function(x){r.params.push(decode(x))}) : + r.params = undefined; + r.node = d && d.v[10] ? d.v[10].v : undefined; + r.client_pid = d && d.v[11] ? decode(d.v[11]) : undefined; + r.state = d && d.v[12] ? decode(d.v[12]) : undefined; + r.from = d && d.v[13] ? utf8_arr(d.v[13].v) : undefined; + r.vsn = d && d.v[14] ? utf8_arr(d.v[14].v) : undefined; + return clean(r); } + +function encbin(d) { + var tup = atom('bin'); + var data = 'data' in d && d.data ? encode(d.data) : nil(); + return tuple(tup,data); } + +function lenbin() { return 2; } +function decbin(d) { + var r={}; r.tup = 'bin'; + r.data = d && d.v[1] ? decode(d.v[1]) : undefined; + return clean(r); } + +function encclient(d) { + var tup = atom('client'); + var data = 'data' in d && d.data ? encode(d.data) : nil(); + return tuple(tup,data); } + +function lenclient() { return 2; } +function decclient(d) { + var r={}; r.tup = 'client'; + r.data = d && d.v[1] ? decode(d.v[1]) : undefined; + return clean(r); } + +function encserver(d) { + var tup = atom('server'); + var data = 'data' in d && d.data ? encode(d.data) : nil(); + return tuple(tup,data); } + +function lenserver() { return 2; } +function decserver(d) { + var r={}; r.tup = 'server'; + r.data = d && d.v[1] ? decode(d.v[1]) : undefined; + return clean(r); } + +function encinit(d) { + var tup = atom('init'); + var token = 'token' in d && d.token ? encode(d.token) : nil(); + return tuple(tup,token); } + +function leninit() { return 2; } +function decinit(d) { + var r={}; r.tup = 'init'; + r.token = d && d.v[1] ? decode(d.v[1]) : undefined; + return clean(r); } + +function encpickle(d) { + var tup = atom('pickle'); + var source = 'source' in d && d.source ? encode(d.source) : nil(); + var pickled = 'pickled' in d && d.pickled ? encode(d.pickled) : nil(); + var args = 'args' in d && d.args ? encode(d.args) : nil(); + return tuple(tup,source,pickled,args); } + +function lenpickle() { return 4; } +function decpickle(d) { + var r={}; r.tup = 'pickle'; + r.source = d && d.v[1] ? decode(d.v[1]) : undefined; + r.pickled = d && d.v[2] ? decode(d.v[2]) : undefined; + r.args = d && d.v[3] ? decode(d.v[3]) : undefined; + return clean(r); } + +function encflush(d) { + var tup = atom('flush'); + var data = 'data' in d && d.data ? encode(d.data) : nil(); + return tuple(tup,data); } + +function lenflush() { return 2; } +function decflush(d) { + var r={}; r.tup = 'flush'; + r.data = d && d.v[1] ? decode(d.v[1]) : undefined; + return clean(r); } + +function encdirect(d) { + var tup = atom('direct'); + var data = 'data' in d && d.data ? encode(d.data) : nil(); + return tuple(tup,data); } + +function lendirect() { return 2; } +function decdirect(d) { + var r={}; r.tup = 'direct'; + r.data = d && d.v[1] ? decode(d.v[1]) : undefined; + return clean(r); } + +function encev(d) { + var tup = atom('ev'); + var module = 'module' in d && d.module ? encode(d.module) : nil(); + var msg = 'msg' in d && d.msg ? encode(d.msg) : nil(); + var trigger = 'trigger' in d && d.trigger ? encode(d.trigger) : nil(); + var name = 'name' in d && d.name ? encode(d.name) : nil(); + return tuple(tup,module,msg,trigger,name); } + +function lenev() { return 5; } +function decev(d) { + var r={}; r.tup = 'ev'; + r.module = d && d.v[1] ? decode(d.v[1]) : undefined; + r.msg = d && d.v[2] ? decode(d.v[2]) : undefined; + r.trigger = d && d.v[3] ? decode(d.v[3]) : undefined; + r.name = d && d.v[4] ? decode(d.v[4]) : undefined; + return clean(r); } + +function encftp(d) { + var tup = atom('ftp'); + var id = 'id' in d && d.id ? encode(d.id) : nil(); + var sid = 'sid' in d && d.sid ? encode(d.sid) : nil(); + var filename = 'filename' in d && d.filename ? encode(d.filename) : nil(); + var meta = 'meta' in d && d.meta ? encode(d.meta) : nil(); + var size = 'size' in d && d.size ? encode(d.size) : nil(); + var offset = 'offset' in d && d.offset ? encode(d.offset) : nil(); + var block = 'block' in d && d.block ? encode(d.block) : nil(); + var data = 'data' in d && d.data ? encode(d.data) : nil(); + var status = 'status' in d && d.status ? encode(d.status) : nil(); + return tuple(tup,id,sid,filename,meta,size,offset,block,data,status); } + +function lenftp() { return 10; } +function decftp(d) { + var r={}; r.tup = 'ftp'; + r.id = d && d.v[1] ? decode(d.v[1]) : undefined; + r.sid = d && d.v[2] ? decode(d.v[2]) : undefined; + r.filename = d && d.v[3] ? decode(d.v[3]) : undefined; + r.meta = d && d.v[4] ? decode(d.v[4]) : undefined; + r.size = d && d.v[5] ? decode(d.v[5]) : undefined; + r.offset = d && d.v[6] ? decode(d.v[6]) : undefined; + r.block = d && d.v[7] ? decode(d.v[7]) : undefined; + r.data = d && d.v[8] ? decode(d.v[8]) : undefined; + r.status = d && d.v[9] ? decode(d.v[9]) : undefined; + return clean(r); } + +function encftpack(d) { + var tup = atom('ftpack'); + var id = 'id' in d && d.id ? encode(d.id) : nil(); + var sid = 'sid' in d && d.sid ? encode(d.sid) : nil(); + var filename = 'filename' in d && d.filename ? encode(d.filename) : nil(); + var meta = 'meta' in d && d.meta ? encode(d.meta) : nil(); + var size = 'size' in d && d.size ? encode(d.size) : nil(); + var offset = 'offset' in d && d.offset ? encode(d.offset) : nil(); + var block = 'block' in d && d.block ? encode(d.block) : nil(); + var data = 'data' in d && d.data ? encode(d.data) : nil(); + var status = 'status' in d && d.status ? encode(d.status) : nil(); + return tuple(tup,id,sid,filename,meta,size,offset,block,data,status); } + +function lenftpack() { return 10; } +function decftpack(d) { + var r={}; r.tup = 'ftpack'; + r.id = d && d.v[1] ? decode(d.v[1]) : undefined; + r.sid = d && d.v[2] ? decode(d.v[2]) : undefined; + r.filename = d && d.v[3] ? decode(d.v[3]) : undefined; + r.meta = d && d.v[4] ? decode(d.v[4]) : undefined; + r.size = d && d.v[5] ? decode(d.v[5]) : undefined; + r.offset = d && d.v[6] ? decode(d.v[6]) : undefined; + r.block = d && d.v[7] ? decode(d.v[7]) : undefined; + r.data = d && d.v[8] ? decode(d.v[8]) : undefined; + r.status = d && d.v[9] ? decode(d.v[9]) : undefined; return clean(r); } diff --git a/apps/roster/src/processes/job.erl b/apps/roster/src/processes/job.erl index c2c6497ce..77a4f9b4c 100644 --- a/apps/roster/src/processes/job.erl +++ b/apps/roster/src/processes/job.erl @@ -70,14 +70,13 @@ action({request,'Final'}, #process{id=Id, options=Opt}=Proc) -> worker(#process{id=Id}=P) -> - case kvs:get(feed,process) of - {ok,Feed} when Feed#feed.top =:= Id -> - case bpe:hist(Id) of - [H|_] ->%kvs:info(?MODULE,"Worker Start: ~p~n",[Id]), - worker_do(calendar:time_difference(H#hist.time,calendar:local_time()),P); - __ -> skip end; - __ -> skip end - . + try + {ok, #feed{top = Id }} = kvs:get(feed,process), + #hist{time = HistTime} = hd(bpe:hist(Id)), + worker_do(calendar:time_difference(HistTime,calendar:local_time()),P) + catch + _-> skip + end. worker_do({Days,Time},P) when Days >= 14 -> skip; worker_do({Days,Time},#process{id=Id}=P) when P#process.task =:= 'Action' -> @@ -126,7 +125,9 @@ next(R,Current) -> clear_schedule()-> [kvs:delete('Schedule', Time) || #'Schedule'{id=Time} <- kvs:all('Schedule'), Time < roster:now_msec()]. -clear_hist(#process{id=Id}=P)-> case bpe:hist(Id) of - [H|T] -> [kvs:remove(hist,Id) || #'hist'{id=Id} <- T]; - __ -> skip end. - +clear_hist(#process{id=Id}=P)-> + try + [kvs:remove(hist,Id) || #'hist'{id=Id} <- tl(bpe:hist(Id))] + catch + _-> skip + end. \ No newline at end of file diff --git a/apps/roster/src/protocol/roster_acl.erl b/apps/roster/src/protocol/roster_acl.erl index 570bea6ef..6078c0982 100644 --- a/apps/roster/src/protocol/roster_acl.erl +++ b/apps/roster/src/protocol/roster_acl.erl @@ -11,6 +11,7 @@ -export([init/1, check_acl/2, reload_acl/1, reload_acl/0, description/0]). -define(ACL_RULE_TAB, roster_acl_rule). +-dialyzer({nowarn_function, description/0}). -record(state, {config, nomatch = deny, vnodes = []}). %%-------------------------------------------------------------------- @@ -72,13 +73,13 @@ check_acl({#mqtt_client{client_id = <<"emqttd_", _/binary>> = Client}, publish, allow; check_acl({#mqtt_client{client_id = <<"emqttd_", _/binary>>}, publish, <<"auth/", _/binary>>}, #state{}) -> deny; -check_acl({#mqtt_client{client_id = <<"emqttd_", _/binary>> = Client}, publish, <<"events/", _/binary>>} = Who, #state{}) -> +check_acl({#mqtt_client{client_id = <<"emqttd_", _/binary>> = Client}, publish, <<"events/", _/binary>>} = _Who, #state{}) -> case kvs:get('Auth', Client) of {ok, #'Auth'{type = expired}} -> deny; {ok, _} -> allow; {error, _} -> deny end; -check_acl({Client, PubSub, Topic} = Who, #state{nomatch = Default}) -> +check_acl({Client, PubSub, Topic} = _Who, #state{nomatch = Default}) -> case match(Client, Topic, lookup(PubSub)) of {matched, allow} -> allow; {matched, deny} -> deny; diff --git a/apps/roster/src/protocol/roster_message.erl b/apps/roster/src/protocol/roster_message.erl index cb5158237..5a1364a08 100644 --- a/apps/roster/src/protocol/roster_message.erl +++ b/apps/roster/src/protocol/roster_message.erl @@ -149,8 +149,7 @@ info(#'Message'{status = edit, id = Id, msg_id = ClMID, feed_id = Feed, from = F roster:put_readers(write_top, Ent, R), n2o_async:pid(system, ?MODULE) ! {send_push, From1, To1, Internal, ?MSG_EDIT_ACTION}, %% publish - roster:send_feed(C, Feed, Internal), <<>>; - E -> E + roster:send_feed(C, Feed, Internal), <<>> end, prometheus_histogram:observe(roster_msg_latency, [edit], roster:osd(MSG_LTNCY)), {reply, {bert, IO}, Req, State}; diff --git a/apps/roster/src/protocol/roster_profile.erl b/apps/roster/src/protocol/roster_profile.erl index 5b63acf1b..eb8fe4de4 100644 --- a/apps/roster/src/protocol/roster_profile.erl +++ b/apps/roster/src/protocol/roster_profile.erl @@ -126,11 +126,11 @@ del_roster(UID,RosterId) -> roster:unsubscribe_p2p(UID, RosterId), roster:remove_member(PId), roster:unsubscribe_muc(PId), - [roster:update_writer(#muc{name=Name},{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = "Deleted"}]}) + [roster:update_writer(#muc{name=Name},{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = <<"Deleted">>}]}) || #'Room'{id=Name} <- Rooms], - [roster:update_writer(roster:feed_key(p2p,PId,FId),{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = "Deleted"}]}) + [roster:update_writer(roster:feed_key(p2p,PId,FId),{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = <<"Deleted">>}]}) || #'Contact'{phone_id = FId} <- Conts], - roster:update_chains({'Message',from},{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = "Deleted"}]}), + roster:update_chains({'Message',from},{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = <<"Deleted">>}]}), kvs:delete('Index', {nick, string:lowercase(Nick)}), case roster:is_online(user_id,PId) of offline -> roster:delete_sessions(user_id, PId); online -> roster:force_logout(user_id,PId) end, % TODO Add force_logout/2 diff --git a/apps/roster/src/protocol/roster_room.erl b/apps/roster/src/protocol/roster_room.erl index 184a9fb36..f0244c4d6 100644 --- a/apps/roster/src/protocol/roster_room.erl +++ b/apps/roster/src/protocol/roster_room.erl @@ -225,7 +225,7 @@ info(#'Room'{status = remove, members = Members, admins = Admins0, id = Room}, R lists:ukeymerge(#'Room'.id, [StoredRoom#'Room'{status = removed}], Rooms)}, Feed), kvs:put(M2 = M#'Member'{status = removed, update = roster:now_msec()}), {[M2 | Ms], [Alias, <<",">> | Alss], [Roster2 | Rs]}; - false -> Acc end end, {[], [], []}, Members ++ Admins), + [] -> Acc end end, {[], [], []}, Members ++ Admins), {Admins2, Members2} = roster:split_members(Mmbrs), Admins3 = lists:ukeymerge(#'Member'.id, lists:ukeysort(#'Member'.id, Admins2), [AdmMember]), Msg = roster:add_message(#'Message'{feed_id = #muc{name = Room}, from = APId, to = Room, diff --git a/apps/roster/src/protocol/roster_roster.erl b/apps/roster/src/protocol/roster_roster.erl index bdc3bdb1d..b509a392d 100644 --- a/apps/roster/src/protocol/roster_roster.erl +++ b/apps/roster/src/protocol/roster_roster.erl @@ -81,7 +81,7 @@ info(#'Roster'{nick = NickToBeValidated, status = nick} = Data, Req, #cx{params OldNickLow = list_to_binary(string:to_lower(nitro:to_list(OldNick))), NickLow = list_to_binary(string:to_lower(nitro:to_list(Nick))), NickValidationError = case NickLow of - [] -> false; + <<>> -> false; _ -> %% check is nick taken by another user case kvs:get('Index', {nick, NickLow}) of @@ -97,7 +97,7 @@ info(#'Roster'{nick = NickToBeValidated, status = nick} = Data, Req, #cx{params %% index processing case NickLow of OldNickLow -> skip; - [] -> n2o_async:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}); + <<>> -> n2o_async:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}); _ -> n2o_async:send(system, ?MODULE, {update_index, #'Roster'{id = ActedRosterId, nick = NickLow}}), n2o_async:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}) diff --git a/apps/roster/src/protocol/roster_search.erl b/apps/roster/src/protocol/roster_search.erl index 95cbc651a..2a403d391 100644 --- a/apps/roster/src/protocol/roster_search.erl +++ b/apps/roster/src/protocol/roster_search.erl @@ -61,14 +61,6 @@ info(#'Search'{id = From, ref = Ref, field = <<"phone">>, type = '==', value = P %roster:info(?MODULE, "Res.Search/phone:~p", [Res]), {reply, {bert, {io, {ok, Ref}, Res}}, Req, State}; -%% TBD is this method neccesery? -info(#'Search'{id = From, ref = Ref, field = K, type = 'like', value = V, status = roster}, Req, - #cx{params = <<"emqttd_", _/binary>> = ClientId} = State) when is_atom(K), Ref /=[] -> - roster:info(?MODULE, "~p:~p:Search/names:~p", [From, ClientId, V]), - L = [binary_to_list(string:lowercase(V)) ++ F - || F <- ets:match(K, {binary_to_list(string:lowercase(V)) ++ '$1'})], - {reply, {bert, {io, {ok, Ref}, L}}, Req, State}; - info(#'Search'{} = Data, Req, State) -> roster:info(?MODULE, "Search/unknown:~p", [Data]), {reply, {bert, {io, {error,invalid_data}}}, Req, State}. diff --git a/apps/roster/src/rest/rest_chat_csv.erl b/apps/roster/src/rest/rest_chat_csv.erl index c49a7ac09..822f1973c 100644 --- a/apps/roster/src/rest/rest_chat_csv.erl +++ b/apps/roster/src/rest/rest_chat_csv.erl @@ -27,7 +27,6 @@ %% Custom data types -type type_chat_element() :: {MsgDate::integer(), Username::string(), Message::string()}. -type type_chat() :: [type_chat_element()]. --type type_chat_history() :: list(#'Message'{}). -type type_user_data() :: {binary(), string()}. %%%============================================================================= @@ -164,8 +163,7 @@ extract_user_id(PhoneId) -> match_member_to_phone_id(Members, PhoneId) -> case lists:dropwhile(fun({Id, _}) -> Id /= PhoneId end, Members) of [] -> throw({no_username_match, PhoneId}); - [{_, Username} | _] -> Username; - _ -> throw({no_username_match, PhoneId}) + [{_, Username} | _] -> Username end. -spec get_username_by_id(Id::non_neg_integer()) -> string(). @@ -175,7 +173,7 @@ get_username_by_id(Id) -> {error, _} -> throw({no_username, Id}) end. --spec get_group_chat_members(RoomId::binary()) -> list(#'Member'{}). +-spec get_group_chat_members(RoomId::binary()) -> list({binary(), list()}) | no_return(). get_group_chat_members(RoomId) -> case roster:members({muc, RoomId}) of [] -> @@ -188,14 +186,14 @@ get_group_chat_members(RoomId) -> phone_id = PhoneId} <- Members] end. --spec get_group_chat_name(RoomId::binary()) -> string(). +-spec get_group_chat_name(RoomId::binary()) -> binary() | no_return(). get_group_chat_name(RoomId) -> case kvs:get('Room', RoomId) of {ok, #'Room'{name = RoomName}} -> RoomName; {error, _} -> throw({no_muc_name, RoomId}) end. --spec get_chat_history(Feed::tuple()) -> list(#'Message'{}). +-spec get_chat_history(Feed::tuple()) -> list(#'Message'{}) | no_return(). get_chat_history(Feed) -> case roster_db:get_chain('Message', roster:feed_key(Feed)) of [] -> throw({no_chat_history, Feed}); @@ -236,4 +234,4 @@ format_timezone({{_, _, _}, {_, _, _}} = Date, TimeZone) -> {error, unknown_tz} -> throw({unknown_timezone, TimeZone}); LocalDate -> LocalDate end; -format_timezone(Timestamp, _) -> Timestamp. \ No newline at end of file +format_timezone(Timestamp, _) -> Timestamp. diff --git a/apps/roster/src/rest/rest_cri.erl b/apps/roster/src/rest/rest_cri.erl index 5ec01ce34..662d7ff48 100644 --- a/apps/roster/src/rest/rest_cri.erl +++ b/apps/roster/src/rest/rest_cri.erl @@ -7,6 +7,7 @@ -include_lib("roster/include/static/roster_text.hrl"). -include_lib("roster/include/static/roster_var.hrl"). -include_lib("roster/include/static/main_var.hrl"). +-dialyzer({nowarn_function, strict_list/1}). -export([ description/0, diff --git a/apps/roster/src/rest/rest_transcribe.erl b/apps/roster/src/rest/rest_transcribe.erl index dede61b15..4029f528b 100644 --- a/apps/roster/src/rest/rest_transcribe.erl +++ b/apps/roster/src/rest/rest_transcribe.erl @@ -34,9 +34,9 @@ handle_request('GET', #{room := RoomId, message := MessageId}, Req) -> send_response(Transcription, Req) catch throw:{msg_not_found, Id} -> - rest_response_helper:error_response(Req, ?HTTP_CODE_404, io_lib:format("Message with ID=~i not found", [Id])); + rest_response_helper:error_response_api(Req, ?HTTP_CODE_404, io_lib:format("Message with ID=~i not found", [Id])); _:_ -> - rest_response_helper:error_response(Req, ?HTTP_CODE_404, "Something went wrong!") + rest_response_helper:error_response_api(Req, ?HTTP_CODE_404, "Something went wrong!") end; {error, wrong_data} -> rest_response_helper:error_400_response(Req) @@ -55,9 +55,9 @@ handle_request('GET', #{user := UserId, message := MessageId}, Req) -> send_response(Transcription, Req) catch throw:{msg_not_found, Id} -> - rest_response_helper:error_response(Req, ?HTTP_CODE_404, io_lib:format("Message with ID=~i not found", [Id])); + rest_response_helper:error_response_api(Req, ?HTTP_CODE_404, io_lib:format("Message with ID=~i not found", [Id])); _:_ -> - rest_response_helper:error_response(Req, ?HTTP_CODE_404, "Something went wrong!") + rest_response_helper:error_response_api(Req, ?HTTP_CODE_404, "Something went wrong!") end; {error, wrong_data} -> rest_response_helper:error_400_response(Req) diff --git a/apps/roster/src/roster.erl b/apps/roster/src/roster.erl index cbf03334f..8398fd6b8 100644 --- a/apps/roster/src/roster.erl +++ b/apps/roster/src/roster.erl @@ -11,6 +11,7 @@ -include_lib("emqttd/include/emqttd.hrl"). -include_lib("mnesia/src/mnesia.hrl"). -compile({parse_transform, bert_validator}). +-dialyzer({nowarn_function, validate/1}). -define(BPE_SYS_CLIENT, <<"sys_bpe">>). @@ -46,6 +47,7 @@ register_acl_mod() -> atoms() -> [android, ios, contact, signup, signin, welcome]. init([]) -> {ok, {{one_for_one, 5, 10}, []}}. start(_, _) -> atoms(), catch load([]), + syn:init(), application:stop(n2o), application:start(n2o), X = try begin A = supervisor:start_link({local, roster}, roster, []), @@ -558,7 +560,7 @@ add_message(#'Message'{} = Msg, Reader) -> -spec unread_msg(#muc{} |#p2p{} |#writer{} |#error{}, integer() | #reader{}, integer() |binary()|#'Member'{}) -> - {binary(), #'Message'{} | update, [integer()]}. + {integer() | binary(), #'Message'{} | update, [integer()]}. unread_msg({error, _}, _, _) -> {0, [], []}; unread_msg(_, {error, _}, _) -> {0, [], []}; unread_msg(#writer{cache = #'Message'{id = MaxReadId, type = [sys|_]} = LastMsg} = Writer, @@ -1144,7 +1146,7 @@ room(#'Roster'{id = Id, phone = Phone}, #'Room'{id = Name, last_msg = LMId, type %% = unread_msg(Rec, Reader, UID), %%TODO fix if writer is empty {ok, #'Room'{readers = Readers}} = kvs:get('Room', Name), - LastPhoneId = case LastMsg of #'Message'{from = LPhoneId} -> LPhoneId; _ -> 0 end, + #'Message'{from = LastPhoneId} = LastMsg, Membrs = lists:flatten( case muc_member(LastPhoneId, Name, presence) of #'Member'{phone_id = Local} = M -> [M]; @@ -1256,7 +1258,7 @@ sub_muc(Subscr, #'Roster'{id = RosterId, phone = Phone, userlist = Cntcts, rooml is_shared_rooms(Rooms, PId)} of {subscribe, #'Contact'{status = friend}, true} -> false; {subscribe, _, IsShared} -> IsShared; - {unsubscribe, true, _} -> true; + {unsubscribe, #'Contact'{}, _} -> true; {unsubscribe, false, false} -> true; _ -> false end]; sub_muc(Subscr, PhoneId, Members, ClientIds) -> @@ -1388,7 +1390,7 @@ norm_reader(Reader) -> Reader. is_visible_msg(#'Message'{seenby = Seen} = Msg, UID) when Seen == []; Seen == [-1]; Seen == [0] -> msg_filter(Msg, UID); -is_visible_msg(#'Message'{feed_id = #muc{name = Room} = Msg}, PhoneId) when is_binary(PhoneId)-> +is_visible_msg(#'Message'{feed_id = #muc{name = Room}} = Msg, PhoneId) when is_binary(PhoneId)-> case muc_member(PhoneId, Room) of [] -> 0; #'Member'{id = MembId} -> msg_filter(Msg, MembId) end; is_visible_msg(Msg, UID) -> msg_filter(Msg, UID). @@ -1423,12 +1425,10 @@ msg_update(Msg, UID) -> msg_filter(Msg, UID). concat(A, B) when is_integer(A), is_integer(B) -> A + B; concat(A, B) when is_list(A), is_list(B) -> A ++ B; -concat({A, MA, SA, []}, {_, _, _, _} = B) -> - concat({A, MA, SA, #'Message'{id = 0}}, B); -concat({_, _, _, _} = A, {B, MB, SB, []} = B) -> - concat(A, {B, MB, SB, #'Message'{id = 0}}); +concat({A, MA, SA, []}, {_, _, _, _} = B) -> concat({A, MA, SA, #'Message'{id = 0}}, B); +concat({_, _, _, _} = A, {B, MB, SB, []}) -> concat(A, {B, MB, SB, #'Message'{id = 0}}); concat({A, MA, StA, #'Message'{id = IdA} = MsgA}, - {B, MB, StB, #'Message'{id = IdB} = MsgB}) -> + {B, MB, StB, #'Message'{id = IdB} = MsgB}) -> {A + B, MA ++ MB, case StA of [] -> StA;_ -> StB end, case IdA > IdB of true -> MsgA;_ -> MsgB end}. @@ -1536,7 +1536,7 @@ get_data(Key, Data) -> false -> []; F -> F end. set_data(Key, Val, Data) -> case get_data(Key, Data) of - false -> Data; + [] -> Data; #'Feature'{} = F -> set_data(F#'Feature'{value = Val}, Data) end. @@ -1633,8 +1633,8 @@ restore_bkp(File, Node, SkipTbs) -> {aborted, {no_exists, Tab}} -> restore_bkp(File, Node, [Tab | SkipTbs]); {aborted, Reason} -> info(?MODULE, "aborted backup restore from ~s by reason ~p", [File, Reason]), {error, Reason}; - {atomic, Tabs} -> {ok, Tabs}; - ok -> ok end. + {atomic, Tabs} -> {ok, Tabs} + end. next_key(Table, Count) -> next_key(Table, mnesia:dirty_first(Table), Count). @@ -1702,8 +1702,7 @@ mover(#reader{pos = Pos, cache = {_, Id}, dir = D} = R, T) -> true -> R; false -> case kvs_stream:drop(R#reader{args = 2}) of #reader{pos = Pos} = NR -> NR; - #reader{} = NR -> mover(NR, T); - E -> E + #reader{} = NR -> mover(NR, T) end end. @@ -1895,7 +1894,7 @@ merge_data(Index, Data, OldData) -> sync_indexes() -> lists:map(fun sync_indexes/1, tables()). sync_indexes(#table{name = Table, keys = Keys}) -> - mnesia:wait_for_tables(Table, 10000), + mnesia:wait_for_tables([Table], 10000), #cstruct{attributes = Attrs} = mnesia:table_info(Table, cstruct), Indexes = mnesia:table_info(Table, index), IndexedKeys = [lists:nth(I-1, Attrs)|| I <- Indexes], diff --git a/apps/roster/src/roster_data.erl b/apps/roster/src/roster_data.erl index a03632729..b60e52e39 100644 --- a/apps/roster/src/roster_data.erl +++ b/apps/roster/src/roster_data.erl @@ -131,7 +131,7 @@ friend_test_rand(N) when is_integer(N) -> friend_test_rand(RosterIds) -> try Rosters = [case R of #'Roster'{} -> R; _-> element(2, kvs:get('Roster', R)) end||R<-RosterIds], - Counter = length(Rosters), +%% Counter = length(Rosters), %% Data = [{APhoneId, AClientId, AToken}, {BPhoneId, BClientId, BToken}] = start_rosters(Rosters), [APhoneId, BPhoneId] = [roster:phone_id(P, RosterId)||#'Roster'{phone = P, id = RosterId}<-Rosters], roster_client:test_info(roster_friend, #'Friend'{phone_id = APhoneId, friend_id = BPhoneId, status = request}, roster:phone(APhoneId)), diff --git a/apps/roster/src/roster_db.erl b/apps/roster/src/roster_db.erl index b26326f9b..dad174a99 100644 --- a/apps/roster/src/roster_db.erl +++ b/apps/roster/src/roster_db.erl @@ -9,201 +9,6 @@ -include_lib("roster/include/static/main_var.hrl"). -include_lib("roster/include/static/rest_text.hrl"). -fix_msg_container() -> - RosterRes = lists:flatten([case R#'Roster'{favorite = [Msg#'Message'{container = chain} ||#'ExtendedStar'{star = Msg}<-Stars]} of - R -> []; R2 -> kvs:put(R2) - end || #'Roster'{favorite = Stars} = R <-kvs:all('Roster')]), - MsgRes = lists:flatten([case Msg#'Message'{container = chain} of - Msg -> []; Msg2 -> kvs:put(Msg2) - end ||Msg<-kvs:all('Message')]), - WRes = lists:flatten([case W#writer{first = case FMsg of #'Message'{} -> FMsg#'Message'{container = chain};[]-> [] end, - cache = case CMsg of #'Message'{} -> CMsg#'Message'{container = chain}; []-> [] end} of - W -> []; W2 -> kvs:put(W2) - end ||#writer{id = Feed, first = FMsg, cache = CMsg} = W <-kvs:all(writer), element(1, Feed) == p2p orelse element(1, Feed) == muc]), - JobRes = lists:flatten([case J#'Job'{data = [Msg#'Message'{container = chain} || Msg <-Data]} of - J -> []; J2 -> kvs:put(J2) - end || #'Job'{data = Data} = J <-kvs:all('Job')]), - {RosterRes, MsgRes, WRes, JobRes}. - -fix_duration() -> - [kvs:put(M#'Message'{files = lists:keystore(Id, #'Desc'.id, Descs, - D#'Desc'{data = lists:keystore(<<"DURATION">>, #'Feature'.key, Data, F#'Feature'{value = integer_to_binary(V)})})}) - ||#'Message'{files = Descs}=M<-kvs:all('Message'), #'Desc'{id = Id, mime = <<"audio">>, data = Data} = D<-Descs, - #'Feature'{key = <<"DURATION">>, value = V}=F<-Data, is_integer(V)], - [kvs:put(W#writer{cache = M#'Message'{files = lists:keystore(Id, #'Desc'.id, Descs, - D#'Desc'{data = lists:keystore(<<"DURATION">>, #'Feature'.key, Data, F#'Feature'{value = integer_to_binary(V)})})}}) - ||#writer{cache = #'Message'{files = Descs}=M} = W<-kvs:all(writer), #'Desc'{id = Id, mime = <<"audio">>, data = Data} = D<-Descs, - #'Feature'{key = <<"DURATION">>, value = V}=F<-Data, is_integer(V)]. - -fix_duration2() -> - [M#'Message'{files = lists:keystore(Id, #'Desc'.id, Descs, - D#'Desc'{data = lists:keystore(FId, #'Feature'.id, Data, F#'Feature'{key = <<"DURATION">>})})} - ||#'Message'{files = Descs}=M<-kvs:all('Message'), #'Desc'{id = Id, mime = <<"audio">>, data = Data} = D<-Descs, - #'Feature'{key = <<"SIZE">>, id = FId}=F<-Data], - [kvs:put(W#writer{cache = M#'Message'{files = lists:keystore(Id, #'Desc'.id, Descs, - D#'Desc'{data = lists:keystore(FId, #'Feature'.id, Data, F#'Feature'{key = <<"DURATION">>})})}}) - ||#writer{cache = #'Message'{files = Descs}=M} = W<-kvs:all(writer), #'Desc'{id = Id, mime = <<"audio">>, data = Data} = D<-Descs, - #'Feature'{key = <<"SIZE">>, id = FId}=F<-Data]. - -fix_empty_desc_ids() -> - lists:flatten([case M#'Message'{files = lists:flatten([D||#'Desc'{id = <<_/integer, _/binary>>} = D<-Descs])} of - M -> []; M2 -> kvs:put(M2), error - end || #'Message'{files = Descs} = M <- kvs:all('Message')]). - -find_invalid_rooms(Id) when is_integer(Id) -> find_invalid_rooms(Id, []). -find_invalid_rooms(#'Roster'{roomlist = Rooms} = Roster, N) -> - lists:flatten([case catch roster:room(Roster, R2) of - {'EXIT', _} -> false = R2; - Room -> Room - end || R2 = #'Room'{} <- - case N of [] -> Rooms;_ -> roster:last_rooms(Rooms, 100) end]); -find_invalid_rooms(Id, N) -> case kvs:get('Roster', Id) of {ok, R} -> roster:roomlist(R, N); _ -> [] end. - -check_desc_migration() -> - Types = [<<"audio">>, <<"image">>, <<"file">>, <<"video">>, <<"thumb">>, <<"text">>, <<"contact">>, - <<"place">>, <<"translate">>, <<"posttranslate">>, <<"transcribe">>, <<"location">>], - {Descs2, _} = lists:foldl( - fun (#'Message'{files = Descs}, {Acc, [_|_]=T} = A) -> - case [D || #'Desc'{mime = Mime} = D <-Descs, lists:member(Mime, T)] of - [_|_]=Ds -> {Ds++Acc, T--[M||#'Desc'{mime = M}<-Ds]}; - _ -> A end; - (_, Acc) -> Acc end, {[], Types}, kvs:all('Message')), - Descs2. - -delete_posttranslate_msg() -> - [kvs:put(Msg#'Message'{files = lists:keydelete(Id, #'Desc'.id, Descs)}) - ||#'Message'{files = Descs} = Msg<-kvs:all('Message'), - #'Desc'{mime = <<"posttranslate">>, id = Id} = D<- Descs]. - -del_rooms_with_one_msg() -> - [[case kvs:get('Roster', roster:roster_id(PhoneId)) of - {error, not_found}-> %%kvs:remove('Message', Id), - case Msg of - #'Message'{next = [], prev = []} -> roster:purge_room(To); - _ -> [] end; _ -> [] end - || PhoneId <- case Feed of #muc{} -> [From]; _ -> [From, To] end] - || Msg = #'Message'{id = Id, feed_id = Feed, from = From, to = To}<-kvs:all('Message')]. - -clean_msg_without_user() -> - L = lists:flatten([ - [try case kvs:get('Roster', roster:roster_id(PhoneId)) of - {error, not_found}-> %%kvs:remove('Message', Id), - case Msg of - #'Message'{next = []} -> Msg; - _ -> [] - end; - _ -> [] - end - catch Err:Rea -> [] - end || PhoneId <- - case Feed of - #muc{} -> [From]; - _ -> [From, To] end] - || Msg = #'Message'{id = Id, feed_id = Feed, from = From, to = To}<-kvs:all('Message')]), - lists:ukeysort(#'Message'.created, sets:to_list(sets:from_list(L))). - -get_room_message(Muc) -> - [Msg || #'Message'{feed_id = Muc2} = Msg <- kvs:all('Message'), Muc == Muc2]. - -get_p2p_message(P2P) -> - [Msg || Msg = #'Message'{feed_id = P2P2} <- kvs:all('Message'), P2P == P2P2]. - -get_entity(Feed, Fun) -> - #writer{cache=Last,first=First}= kvs_stream:load_writer(Feed), - roster:entries(Fun, element(2,Last), element(1,Last), undefined). - -%fun(A, Acc) -> case element(2, A) > Limit of true -> Acc; false -> [A | Acc] end end) - -verify_top_writer() -> - lists:flatten([case kvs:get('Message', Id) of - {ok, #'Message'{prev = Next}} -> []; {error, _} -> []; _-> W - end ||#writer{id = #muc{}, cache = #'Message'{id = Id, prev = Next}} = W<-kvs:all(writer)]). - -fix_empty_services() -> - [kvs:put(P#'Profile'{services = [S2||#'Service'{id = Id2}= S2<-Ss, Id2 /= []]}) || - #'Profile'{services = Ss} = P <-kvs:all('Profile'), #'Service'{id = Id}<- Ss, Id == []]. - -test_db_accounts() -> - lists:flatten([case catch roster:roster(Id) of - {error, {user, {Local, PhoneId}} = Res} -> Res; - {error, {room, {PhoneId, Room}, Res} = R} -> R; - R -> [] - end || #'Roster'{id = Id} <- kvs:all('Roster')]). - -purge_invalid_roooms() -> purge_invalid_roooms(10, []). -purge_invalid_roooms(0, Acc) -> Acc; -purge_invalid_roooms(C, Acc) when C > 0 -> - case [begin roster:purge_room(Room), Room end || {room, {_, Room}, _} <- test_db_accounts()] of - [] -> Acc; Rooms -> purge_invalid_roooms(C - 1, Acc ++ Rooms) end. - -fix_db_v8() -> - [Res||Res<-[fix_empty_services(), - delete_posttranslate_msg(), - del_rooms_with_one_msg(), - fix_empty_desc_ids(), - fix_msg_container(), - purge_invalid_roooms()]]. - -data_integrity() -> -%%%% lists:flatten([ [ MSG || #'Message'{id= Id, prev=[]}=MSG <- get_p2p_message(P2P), Id/=TopId, Id/=StartId] -%%%% || #writer{id = #p2p{}=P2P, cache = #'Message'{id=TopId}, first = #'Message'{id=StartId}}<- kvs:all(writer)]), -%% [{Msg,D} || Msg = #'Message'{files = Descs} <- kvs:all('Message'), D=#'Desc'{mime = <<"text">>} <- Descs], - [kvs:put(Msg#'Message'{to =Name}) || Msg = #'Message'{feed_id = #muc{name=Name}, to = Room} <- kvs:all('Message'), Room/=Name] -%% lists:flatten([ get_entity(Feed,fun(A, Acc) -> -%% case element(4, A)==[] of true when ( element(2, A)/=TopId andalso element(2, A)/=StartId) -> [A | Acc]; _ -> Acc end end) -%% || #writer{id = #muc{}=Feed, cache = #'Message'{id=TopId}, first = #'Message'{id=StartId}}<- kvs:all(writer)]) -. - -fix_rosters_names() -> - [case UL of - [#'Contact'{} | _] = L -> - {NewUL, NewR} = lists:foldl(fun(#'Contact'{phone_id = PhoneId, names = CName} = Cont, {Acc, #'Roster'{id = Id} = Rost}) -> - case kvs:get('Roster', RId = roster:roster_id(PhoneId)) of - {ok, #'Roster'{names = Name, userlist = [#'Contact'{} | _]} = R} -> - case {Name, RId} of - {<>, _} -> - {[Cont#'Contact'{names = Name} | Acc], R}; - {_, Id} -> NN = case CName of <> -> CName; _ -> - list_to_binary(random_string(lists:seq(1, 10))) end, - {[Cont#'Contact'{names = NN} | Acc], R#'Roster'{names = NN}}; - _ when is_binary(CName) -> - ok = kvs:put(R#'Roster'{names = CName}), - {[Cont | Acc], Rost}; - _ -> NN = list_to_binary(random_string(lists:seq(1, 10))), - ok = kvs:put(R#'Roster'{names = NN}), - {[Cont#'Contact'{names = NN} | Acc], Rost} - end; - E -> %roster:purge_user(Phone), - roster:info(?MODULE, "Shit:~p", [E]), - {Acc, Rost} end; - (_, Res) -> Res - end, {[], Roster}, L), - case {NewUL, NewR} of - {[#'Contact'{} | _], #'Roster'{}} -> ok = kvs:put(NewR#'Roster'{userlist = NewUL}); - _ -> roster:purge_user(Phone) end; - _ -> roster:purge_user(Phone) - end - || Roster = #'Roster'{phone = Phone, userlist = UL} <- kvs:all('Roster')]. - - -fixed_empty_member_name() -> - [kvs:put(Member#'Member'{names =list_to_binary(random_string(lists:seq(1, 10)))}) - || Member = #'Member'{names = Name} <- kvs:all('Member'), Name == []]. - -random_string(Base)->lists:foldl(fun(_, R) -> [element(rand:uniform(size(list_to_tuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"))), - list_to_tuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")) | R] end, "", Base). - -%% Statistic functions - -unique_p2p() -> -%% get unique p2p feeds count from Messages - PrivateChatSet = sets:to_list(sets:from_list([ FeedId || #'Message'{feed_id = #p2p{} = FeedId} <- kvs:all('Message')])), - {length(PrivateChatSet), PrivateChatSet}. - -room_count(Type) -> - length([Msg || Msg = #'Room'{type = Type2} <- kvs:all('Room'), Type2 == Type]). - - user_stats() -> %% Get statustic for all users in db %% user_statistic(lists:flatten([ RosterId || #'Roster'{id = RosterId} <- kvs:all('Roster')])). @@ -224,12 +29,6 @@ user_stats(RosterId) -> } end. -get_room_stats(RosterId) -> - [begin - #writer{count = MsgCount} = kvs_stream:load_writer(#muc{name = Id}), - #'Room'{name = Name, members = length(roster:members(#muc{name = Id})), last_msg = MsgCount} - end || #'Room'{id = Id, name = Name} <- roster:roomlist(RosterId)]. - user_room_stats(RosterId, Type) -> %% child of get_room_stats, filter by type, pretty response %% response format: {RoomCount, [{name, RoomName}, {mmbrs, RoomMembersCount}, {msgs, RoomMsgCount}] @@ -251,20 +50,22 @@ user_p2p_stats(RosterId) -> ] || #'Contact'{phone_id = ContactPhoneId} <- roster:userlist(RosterId)], {length(ContactInfo), ContactInfo}. -fold(Fun, Acc, Table) -> fold(Fun, Acc, Table, mnesia:dirty_first(Table)). -fold(Fun, Acc, Table, FirstId) -> fold(Fun, Acc, Table, FirstId, -1). -fold(_Fun, Acc, _Table, _Id, 0) -> Acc; -fold(Fun, Acc, Table, '$end_of_table', Count) -> - case string:str(Tables = kvs:rlist(kvs:rname(Table)), [Table]) of - I when length(Tables) > I -> - Table2 = lists:nth(I+1, Tables), - fold(Fun, Acc, Table2, mnesia:dirty_first(Table2), Count); - _ -> Acc - end; -fold(Fun, Acc, Table, Id, Count) when Count < 0; Count > 0 -> - case kvs:get(kvs:rname(Table), Id) of - {ok, El} -> fold(Fun, Fun(El, Acc), Table, mnesia:dirty_next(Table, Id), Count-1); - {error, _} -> Acc +fold(Fun, Acc, Table) -> fold(Fun, Acc, Table, mnesia:dirty_first(Table)). +fold(Fun, Acc, Table, FirstId) -> fold(Fun, Acc, Table, FirstId, -1). +fold(_Fun, Acc, _Table, '$end_of_table', _Count) -> Acc; +fold(Fun, Acc, Table, Id, Count) -> + case mnesia:dirty_next(Table, Id) of + NextId when '$end_of_table' /= NextId andalso Count /= 0 -> + {ok, El} = kvs:get(kvs:rname(Table), Id), + fold(Fun, Fun(El, Acc), Table, NextId, Count-1); + _ when Count == 0 -> Acc; + '$end_of_table' -> %% If table is splitted + case string:str(Tables = kvs:rlist(kvs:rname(Table)), [Table]) of + I when length(Tables) > I -> + Table2 = lists:nth(I+1, Tables), + fold(Fun, Acc, Table2, mnesia:dirty_first(Table2), Count); + _ -> Acc + end end. %% statistic functions @@ -312,54 +113,6 @@ msg_stats(#'Message'{files = [#'Desc'{mime = <<_/integer, _/binary>> = Mime}|Des msg_stats(#'Message'{files = [_|Descs]} = Msg, Acc) -> msg_stats(Msg#'Message'{files = Descs}, Acc). -search_data(Keyword, {CurrentId, Result}, Table, NextFun, FilterFun) -> - case NextFun(Table, CurrentId) of - stop -> Result; - NextId -> - FoundRes = FilterFun(Table, NextId, Keyword), - search_data(Keyword, {NextId, Result++FoundRes}, Table, NextFun, FilterFun) - end. - -search_room(Keyword) -> - T0 = erlang:timestamp(), - NextFun = - fun(Table, Current) -> - case mnesia:dirty_next(Table, Current) of - '$end_of_table' -> stop; NextId -> NextId end - end, - - FilterFun = - fun(Table, NextId, Keyword) -> - {ok, #'Room'{name = Name} = Next} = kvs:get(Table, NextId), - [KeyWLow, LowName] = [string:lowercase(Word) || Word <- [Keyword, Name]], - case binary:match(LowName, [KeyWLow]) of - nomatch -> []; _ -> [Next] end - end, - - Res = search_data(Keyword, {mnesia:dirty_first('Room'), []}, 'Room', NextFun, FilterFun), - T1 = erlang:timestamp(), - roster:info(?MODULE, "TIME for room search in ms:~p", [timer:now_diff(T1, T0) / 1000]), - Res. - -get_features() -> get_features([<<"image">>, <<"video">>, <<"thumb">>]). -get_features(Mimes) -> - lists:ukeysort(#'Feature'.key, lists:flatten( - [Data || #'Message' {files = Descs} <-kvs:all('Message'), - #'Desc' {mime = Mime, data = Data} <-Descs, lists:member(Mime, Mimes)])). - -bin_to_atom_type_msg() -> - [kvs:put(Msg#'Message'{type = [binary_to_atom(T, utf8)||T<-Types]})|| - Msg=#'Message'{type = [H|_] = Types} <- kvs:all('Message'), is_binary(H)]. - -search_voice_reply() -> - lists:flatten([case kvs:get('Message', Id) of - {error, _} -> []; - {ok, #'Message'{files = Descs} = Msg} -> - case [Msg || #'Desc'{mime = <<"audio">>} <- Descs] of - [] -> []; _ -> Msg - end - end || #'Message'{type = [reply], link = Id} <- kvs:all('Message')]). - opt_put(OldRec, OldRec) -> []; opt_put(NewRec, _OldRec) -> kvs:put(NewRec). @@ -404,9 +157,6 @@ upd_tabs('Room') -> [kvs:put(upd_tab(Room))|| Room=#'Room'{links=L} <-kvs:all('Room'), L/=[]]; upd_tabs(_)-> skip. - -%% - get_ips(Begin) -> sets:to_list(sets:from_list([A||A = #'Auth'{settings = Settings}<-kvs:all('Auth'), #'Feature'{key = <<"IP">>, value = IP} <-Settings, @@ -420,79 +170,6 @@ validate_table(Table) -> lists:flatten([case roster_validator:validate(Rec) of {error, Acc} -> throw({error, Acc}); ok -> [] end || Rec<-kvs:all(Table)]). -%%validate2() -> -%% lists:flatten([validate_table2(Table) || #table{name = Table}<-roster:tables(), Rec<-kvs:all(Table), -%% not lists:member(Table, [chain, writer, reader])]). - -validate_table2(Table) -> - lists:flatten([case roster_validator:validate(Rec) of ok -> [];Err -> Err end - || Rec<-kvs:all(Table)]). - -upd_services_in_contacts() -> %% status add to added - lists:flatten([case R#'Roster'{userlist = [C#'Contact'{services = - [Serv#'Service'{status = case St of add-> added; _-> St end} ||#'Service'{status = St} = Serv<-Ss]} - ||C=#'Contact'{services = Ss}<-Contacts]} of - R -> []; - R2 -> kvs:put(R2) - end ||#'Roster'{userlist = Contacts}=R<-kvs:all('Roster')]). - -fix_msg(#'Message'{type = Type} = Msg) when is_atom(Type) -> - fix_msg(Msg#'Message'{type = [Type]}); -fix_msg(#'Message'{status = St} = Msg) when St==internal;St==client -> - fix_msg(Msg#'Message'{status = []}); -fix_msg(#'Message'{link = <>} = Msg) -> - fix_msg(Msg#'Message'{link = binary_to_integer(Link)}); -fix_msg(#'Message'{files = Descs} = Msg) -> - Msg#'Message'{files = [D#'Desc'{mime = case M of [] -> <<"text">>; _ -> M end} - || #'Desc'{mime = M} = D <-Descs]}; -fix_msg(Msg) -> Msg. -fix_msgs() -> upd_msgs(fix_msg). - -fix_jobs() -> - [opt_put(J#'Job'{settings = case S of #'Feature'{} -> [S]; _-> S end}, J) - || J = #'Job'{settings = S}<-kvs:all('Job')], ok. - -find_msg_by_text(Text) when is_binary(Text) -> - [M||M=#'Message'{files = Descs}<-kvs:all('Message'), #'Desc'{mime = <<"text">>, payload = <>} <- Descs]; -find_msg_by_text(_) -> []. - -broken_chains_feed(Tab) -> - lists:flatten([ begin Feed=element(#iterator.feed_id,M), Id=element(#iterator.id,M), - case kvs_stream:load_writer(Feed) of - #writer{cache = CE, first = FE} when (element(2,CE)==Id orelse element(2,FE)==Id) -> []; - #writer{cache = CE, first = FE} ->Feed; - %fix_chain(W), - _ -> kvs:remove(element(1,M),Id), Feed end end - || M <- kvs:all(Tab),(element(#iterator.prev,M)/= [] andalso element(#iterator.id,M) > element(#iterator.prev,M)) - orelse (element(#iterator.next,M)/= [] andalso element(#iterator.id,M) < element(#iterator.next,M)) - orelse element(#iterator.next,M)== [] orelse element(#iterator.prev,M)==[] ]) -% del_invalid_messages() -. - -%%fix_chain(#writer{count =N, cache = EC, first = EF}=W) when element(2,EC)>element(2,EF), N>1 -> -%% case kvs:get(element(1,EC),element(2,EC)) of -%% {ok,E}-> set_prev(EF,E,N); -%% _ -> W -%% end; -%% -%%fix_chain(#writer{count =N, cache = EC, first = EF}=W) -> []. - - -set_prev(E,Start,N)-> - Fun = fun(A, Acc) -> [A | Acc] end, - % roster:info(?MODULE, "Start:~p", [Start]), - case kvs:fold(Fun, [Start], element(1,E), element(2,Start), N, #iterator.next, #kvs{mod = store_mnesia}) of - [H] -> H; - [H1,H2|_] -> - SId=element(2,H1), Stop=element(2,E), - case element(#iterator.next,H2) of - Stop ->NH1=erlang:setelement(#iterator.prev,H1,element(2,H2)), kvs:put(NH1); - SId ->NH1=erlang:setelement(#iterator.prev,H1,element(2,H2)), kvs:put(NH1), set_prev(E,NH1,N); - _ -> H1 - end; - Er -> Er - end. - valid_chains({Tab,feed},Id,Acc) -> [Entity]=mnesia:dirty_read(Tab,Id), % roster:info(?MODULE, "Start:~p", [Acc]), @@ -513,42 +190,6 @@ valid_chains({Tab,Feed},Id,Acc) -> _ -> Acc end. - - -repair_chain(_,[],_) -> []; -repair_chain(Tab,[Id],N) -> [One]=mnesia:dirty_read(Tab,Id), - case kvs_stream:load_writer(element(#iterator.feed_id,One)) of - #writer{count=C}=W when C==1 -> One1=setelement(#iterator.next,One, []), - One2=setelement(#iterator.prev,One1, []), - kvs:put(W#writer{cache=One2, first=One2}),[One2]; - #writer{count=C}=W -> One1=setelement(#iterator.prev,One,[]), - kvs:put(W#writer{count=N, cache=One1}),[One1]; - _ -> kvs:remove(element(1,One),element(2,One)), [] - end; -repair_chain(Tab,[H|T]=NewL,N) -> - %NewL=[H|T]=lists:usort(List), - % roster:info(?MODULE, "Start:~p", [NewL]), - Fun=fun(A,{AOut, []})-> {AOut++repair_chain(Tab,[A],N),[]}; - (A,{AOut, [Ap|TIn]})-> - [E]=mnesia:dirty_read(Tab,A), - {E1,NEl}=case AOut of - [] -> - NA=setelement(#iterator.next,E, []), - kvs_stream:save((kvs_stream:load_writer(element(#iterator.feed_id,E)))#writer{first=NA}), - {NA, []}; - _ -> %[Elast]=mnesia:dirty_read(Tab,), - Next=lists:last(AOut), - {setelement(#iterator.next,E,Next), Next} - end, - %[Ep]=mnesia:dirty_read(Tab,Ap), - case (element(#iterator.prev,E)==Ap andalso element(#iterator.next,E)==NEl) of - true -> skip; - _ -> kvs:put(setelement(#iterator.prev,E1,Ap)) - end, - {AOut++[A],TIn} - end, - lists:foldl(Fun, {[],T}, NewL),ok. - dirty_foldl(Fun, Acc, E) -> dirty_foldl(Fun, Acc, element(1, E), E). dirty_foldl(Fun, Acc, Tab, E) -> Key = mnesia:dirty_first(Tab), @@ -559,69 +200,10 @@ dirty_foldl(Fun, Acc, Tab, E, Key) -> NxtKey = mnesia:dirty_next(Tab, Key), dirty_foldl(Fun, NxtAcc, Tab, E, NxtKey). - -%% @doc Repair chains --spec fix_chains(atom()) -> list(). - -fix_chains(Tab) -> - [ begin #writer{count=C}=kvs_stream:load_writer(Feed), - N=length(Acc), C1=case N-C<0 of true -> N; _ -> C end , - {_,L2}=lists:split(N-C1,lists:usort(Acc)), repair_chain(Tab,L2,C1) end - || {Feed,Acc}<-dirty_foldl(valid_chains, [], {Tab,feed}), Acc/=[]]. - get_chain(Tab,Feed) -> [ case kvs:get(Tab,Id) of {ok, E}-> E; _-> [] end || Id<-lists:usort(dirty_foldl(valid_chains, [], {Tab,Feed}))]. -%%fix_chains(Tab) -> -%% [ repair_chain(Tab,dirty_foldl(valid_chain, [], Tab, Feed)) || #writer{id=Feed}<-kvs:all('writer') ]. - - -%% Mnesia cluster backup -%% -backup()-> ExcTabs= [mqtt_session,mqtt_admin], - backup(mnesia:system_info(tables)-ExcTabs). - -backup(Tabs) -> - Date = roster:local_time_as_gmt(calendar:local_time()), - Node = node(), -% {ok, ServerAddress} = vox_api:get_server_ip(), - File = io_lib:format("./~s_bkp_~s", [Node, Date]), - backup(false, Tabs, Node, File, []). - -backup(Schema, Tables, Node, File, Opts) when is_list(Tables) -> - Tabs = Tables -- if Schema -> []; true -> [schema] end, - Opts2 = lists:keystore(max, 1, Opts, {max, Tabs}), - case mnesia:activate_checkpoint(Opts2) of - {ok, Name, _Nodes} -> - case mnesia:backup_checkpoint(Name, File) of - ok -> - mnesia:deactivate_checkpoint(Name); - {error, Reason} = Err -> - roster:info(?MODULE, "~p", [Reason]), - mnesia:deactivate_checkpoint(Name), - Err - end; - {error, {"Cannot prepare checkpoint (replica not available)", [Table, _]}} -> - backup(Schema, Tables -- [Table], Node, File, Opts); - {error, Reason} = Err -> - roster:info(?MODULE, "~p", [Reason]), - Err - end. - -restore(File) -> restore(File, node(), []). -restore(File, Node, SkipTbs) -> - case mnesia:restore(File, [{skip_tables, SkipTbs}]) of - {aborted, {no_exists, Tab}} -> restore(File, Node, [Tab | SkipTbs]); - {aborted, Reason} -> roster:info(?MODULE, "aborted backup restore from ~s by reason ~p", [File, Reason]), - {error, Reason}; - {atomic, Tabs} -> {ok, Tabs}; - ok -> ok end. - -remigrate_default_contact_settings() -> - kvs:delete(schema_migrations, 20181008144317), - roster:migrate(). - %% tables storage save_db(Path) -> Data = lists:append([kvs:all(B) || B <- [Name || {table,Name} <- kvs:dir()-- @@ -639,7 +221,6 @@ load_db(Path) -> write_trie(Tab,Trie) ->mnesia:dirty_write(Tab, Trie). %% Subscriptions control - unsubs(<<"emqttd_", _/binary>>, _) -> []; unsubs(<<"sys_", _/binary>>, _) -> []; unsubs(<<"reg_", _/binary>>=C, T) -> roster:final_disconnect(C), @@ -647,7 +228,6 @@ unsubs(<<"reg_", _/binary>>=C, T) -> roster:final_disconnect(C), unsubs(_, <<"events/+/", _/binary>>) -> []; unsubs(ClientId, T) -> n2o_vnode:unsubscribe(ClientId,T), {ClientId, T}. -%% unsubscribe({all,Topic})-> unsubscribe(Topic, [n2o_vnode ,unsubscribe]); %% for Topic template with using filter Fun for clients @@ -722,4 +302,33 @@ to_rec('LinkRoster', #{<<"id">> := Uuid, <<"phone_id">> := PhoneId}) -> #'LinkRoster'{id = micro:uuid_to_bin(Uuid), phone_id = PhoneId}. import_json(Table, File) -> - lists:map(fun kvs:put/1, to_rec(Table, File)). \ No newline at end of file + lists:map(fun kvs:put/1, to_rec(Table, File)). +backup()-> ExcTabs= [mqtt_session,mqtt_admin], + backup(mnesia:system_info(tables)-ExcTabs). + +backup(Tabs) -> + Date = roster:local_time_as_gmt(calendar:local_time()), + Node = node(), +% {ok, ServerAddress} = vox_api:get_server_ip(), + File = io_lib:format("./~s_bkp_~s", [Node, Date]), + backup(false, Tabs, Node, File, []). + +backup(Schema, Tables, Node, File, Opts) when is_list(Tables) -> + Tabs = Tables -- if Schema -> []; true -> [schema] end, + Opts2 = lists:keystore(max, 1, Opts, {max, Tabs}), + case mnesia:activate_checkpoint(Opts2) of + {ok, Name, _Nodes} -> + case mnesia:backup_checkpoint(Name, File) of + ok -> + mnesia:deactivate_checkpoint(Name); + {error, Reason} = Err -> + roster:info(?MODULE, "~p", [Reason]), + mnesia:deactivate_checkpoint(Name), + Err + end; + {error, {"Cannot prepare checkpoint (replica not available)", [Table, _]}} -> + backup(Schema, Tables -- [Table], Node, File, Opts); + {error, Reason} = Err -> + roster:info(?MODULE, "~p", [Reason]), + Err +end. \ No newline at end of file diff --git a/apps/roster/src/roster_validator.erl b/apps/roster/src/roster_validator.erl index 0ec02f4e4..910d4c206 100644 --- a/apps/roster/src/roster_validator.erl +++ b/apps/roster/src/roster_validator.erl @@ -33,7 +33,7 @@ validate(D = #'reader'{id = Id, pos = Pos, cache = Cache, args = Args, feed = Fe case {RecField, F} of {id,_} -> Acc2; {pos,_} when Pos==[] orelse is_integer(Pos) -> Acc2; - {cache,_} when Cache==[] orelse is_integer(Cache) -> Acc2; + {cache,_} when Cache==[] orelse is_integer(Cache) orelse is_tuple(Cache) -> Acc2; {args,_} -> Acc2; {feed,_} -> Acc2; {dir,_} when Dir==0 orelse Dir==1 -> Acc2; @@ -116,7 +116,7 @@ validate(D = #'task'{name = Name, module = Module, prompt = Prompt, roles = Role {module,_} when Module==[] orelse is_atom(Module) -> Acc2; {prompt,_} when is_list(Prompt) -> lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; + {roles,_} when Roles==[] orelse is_binary(Roles) -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'task'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -127,7 +127,7 @@ validate(D = #'userTask'{name = Name, module = Module, prompt = Prompt, roles = {module,_} when Module==[] orelse is_atom(Module) -> Acc2; {prompt,_} when is_list(Prompt) -> lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; + {roles,_} when Roles==[] orelse is_binary(Roles) -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'userTask'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -138,7 +138,7 @@ validate(D = #'serviceTask'{name = Name, module = Module, prompt = Prompt, roles {module,_} when Module==[] orelse is_atom(Module) -> Acc2; {prompt,_} when is_list(Prompt) -> lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; + {roles,_} when Roles==[] orelse is_binary(Roles) -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'serviceTask'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -149,19 +149,19 @@ validate(D = #'receiveTask'{name = Name, module = Module, prompt = Prompt, roles {module,_} when Module==[] orelse is_atom(Module) -> Acc2; {prompt,_} when is_list(Prompt) -> lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; + {roles,_} when Roles==[] orelse is_binary(Roles) -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'receiveTask'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; validate(D = #'messageEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; + {name,_} when Name==[] orelse is_atom(Name) orelse is_list(Name) orelse is_binary(Name) -> Acc2; {module,_} when Module==[] orelse is_atom(Module) -> Acc2; {prompt,_} when is_list(Prompt) -> lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when is_binary(Payload) -> Acc2; - {timeout,_} when is_tuple(Timeout) -> Acc2; + {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; + {timeout,_} when Timeout==[] orelse is_tuple(Timeout) -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'messageEvent'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -172,11 +172,11 @@ validate(D = #'boundaryEvent'{name = Name, module = Module, prompt = Prompt, pay {module,_} when Module==[] orelse is_atom(Module) -> Acc2; {prompt,_} when is_list(Prompt) -> lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when is_binary(Payload) -> Acc2; + {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; {timeout,_} when is_tuple(Timeout) -> Acc2; - {timeDate,_} when is_binary(TimeDate) -> Acc2; - {timeDuration,_} when is_binary(TimeDuration) -> Acc2; - {timeCycle,_} when is_binary(TimeCycle) -> Acc2; + {timeDate,_} when TimeDate==[] orelse is_binary(TimeDate) -> Acc2; + {timeDuration,_} when TimeDuration==[] orelse is_binary(TimeDuration) -> Acc2; + {timeCycle,_} when TimeCycle==[] orelse is_binary(TimeCycle) -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'boundaryEvent'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -224,100 +224,67 @@ validate(D = #'sequenceFlow'{source = Source, target = Target}, Acc, {CustomVali _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'sequenceFlow'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'hist'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, name = Name, task = Task, docs = Docs, time = Time}, Acc, {CustomValidateModule, ValidateFun} = CM) -> +validate(D = #'hist'{container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, name = Name, task = Task, docs = Docs, time = Time}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; + {container,_} when Container==[] orelse is_atom(Container) -> Acc2; + {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; {next,_} when Next==[] orelse is_integer(Next) -> Acc2; {feeds,_} when is_list(Feeds) -> []; {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {task,_} when is_atom(Task) -> Acc2; + {task,_} when Task==[] orelse is_atom(Task) orelse is_tuple(Task) -> Acc2; {docs,_} when is_list(Docs) -> lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); {time,_} -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'hist'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'process'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, name = Name, roles = Roles, tasks = Tasks, events = Events, hist = Hist, flows = Flows, rules = Rules, docs = Docs, options = Options, task = Task, timer = Timer, notifications = Notifications, result = Result, started = Started, beginEvent = BeginEvent, endEvent = EndEvent}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {roles,_} when is_list(Roles) -> []; - {tasks,_} when is_list(Tasks) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'task') orelse is_record(Tmp,'serviceTask') orelse is_record(Tmp,'userTask') orelse is_record(Tmp,'receiveTask') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{tasks, D}|Acc3] end, Acc2, Tasks); - {events,_} when is_list(Events) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'messageEvent') orelse is_record(Tmp,'boundaryEvent') orelse is_record(Tmp,'timeoutEvent') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{events, D}|Acc3] end, Acc2, Events); - - {flows,_} when is_list(Flows) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'sequenceFlow') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{flows, D}|Acc3] end, Acc2, Flows); - - {docs,_} when is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - {options,_} -> Acc2; - {task,_} when Task==[] orelse is_atom(Task) -> Acc2; - {timer,_} when Timer==[] orelse is_binary(Timer) -> Acc2; - {notifications,_} when Notifications==[] orelse true -> Acc2; - {result,_} when Result==[] orelse is_binary(Result) -> Acc2; - {started,_} when Started==[] orelse is_tuple(Started) -> Acc2; - {beginEvent,_} when BeginEvent==[] orelse is_atom(BeginEvent) -> Acc2; - {endEvent,_} when EndEvent==[] orelse is_atom(EndEvent) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'process'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'complete'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> +validate(D = #'Comp'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of {id,_} when Id==[] orelse is_integer(Id) -> Acc2; _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'complete'), tl(tuple_to_list(D)))), + end end, Acc, lists:zip(record_info(fields, 'Comp'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'proc'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> +validate(D = #'Proc'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of {id,_} when Id==[] orelse is_integer(Id) -> Acc2; _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'proc'), tl(tuple_to_list(D)))), + end end, Acc, lists:zip(record_info(fields, 'Proc'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'load'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> +validate(D = #'Load'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of {id,_} when Id==[] orelse is_integer(Id) -> Acc2; _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'load'), tl(tuple_to_list(D)))), + end end, Acc, lists:zip(record_info(fields, 'Load'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'histo'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> +validate(D = #'Hist'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of {id,_} when Id==[] orelse is_integer(Id) -> Acc2; _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'histo'), tl(tuple_to_list(D)))), + end end, Acc, lists:zip(record_info(fields, 'Hist'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'create'{proc = Proc, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> +validate(D = #'Make'{proc = Proc, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of {proc,_} when Proc==[] orelse is_record(Proc,'process') orelse is_binary(Proc) -> Acc2; {docs,_} when Docs==[] orelse is_list(Docs) -> lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'create'), tl(tuple_to_list(D)))), + end end, Acc, lists:zip(record_info(fields, 'Make'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'amend'{id = Id, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> +validate(D = #'Amen'{id = Id, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of {id,_} when Id==[] orelse is_integer(Id) -> Acc2; {docs,_} when Docs==[] orelse is_list(Docs) -> lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'amend'), tl(tuple_to_list(D)))), + end end, Acc, lists:zip(record_info(fields, 'Amen'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; validate(D = #'chain'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> @@ -383,8 +350,8 @@ validate(D = #'Feature'{id = Id, key = Key, value = Value, group = Group}, Acc, case {RecField, F} of {id,_} when Id==[] orelse is_binary(Id) -> Acc2; {key,_} when is_binary(Key) -> Acc2; - {value,_} when is_binary(Value) -> Acc2; - {group,_} when is_binary(Group) -> Acc2; + {value,_} when Value==[] orelse is_binary(Value) -> Acc2; + {group,_} when Group==[] orelse is_binary(Group) -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'Feature'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -415,7 +382,7 @@ validate(D = #'Member'{id = Id, container = Container, feed_id = Feed_id, prev = {names,_} when Names==[] orelse is_binary(Names) -> Acc2; {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; {alias,_} when Alias==[] orelse is_binary(Alias) -> Acc2; - {reader,_} when Reader==[] orelse is_integer(Reader) -> Acc2; + {reader,_} when Reader==[] orelse is_integer(Reader) orelse is_record(Reader,'reader') -> Acc2; {update,_} when Update==[] orelse is_integer(Update) -> Acc2; {settings,_} when Settings==[] orelse is_list(Settings) -> lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); @@ -460,7 +427,7 @@ validate(D = #'Message'{id = Id, container = Container, feed_id = Feed_id, prev case {RecField, F} of {id,_} when Id==[] orelse is_integer(Id) -> Acc2; {container,_} when Container=='chain' orelse Container=='cur' orelse Container==[] -> Acc2; - {feed_id,_} when is_record(Feed_id,'muc') orelse is_record(Feed_id,'p2p') -> Acc2; + {feed_id,_} when Feed_id==[] orelse is_record(Feed_id,'muc') orelse is_record(Feed_id,'p2p') -> Acc2; {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; {next,_} when Next==[] orelse is_integer(Next) -> Acc2; {msg_id,_} when Msg_id==[] orelse is_binary(Msg_id) -> Acc2; @@ -575,7 +542,7 @@ validate(D = #'Contact'{phone_id = Phone_id, avatar = Avatar, names = Names, sur {services,_} when is_list(Services) -> lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); {presence,_} when Presence==[] orelse Presence=='online' orelse Presence=='offline' orelse is_binary(Presence) -> Acc2; - {status,_} when Status==[] orelse Status=='request' orelse Status=='authorization' orelse Status=='ignore' orelse Status=='internal' orelse Status=='friend' orelse Status=='last_msg' orelse Status=='ban' orelse Status=='banned' orelse Status=='deleted' -> Acc2; + {status,_} when Status==[] orelse Status=='request' orelse Status=='authorization' orelse Status=='ignore' orelse Status=='internal' orelse Status=='friend' orelse Status=='last_msg' orelse Status=='ban' orelse Status=='banned' orelse Status=='deleted' orelse Status=='not_existence' -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'Contact'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -595,7 +562,7 @@ validate(D = #'Auth'{client_id = Client_id, dev_key = Dev_key, user_id = User_id {user_id,_} when User_id==[] orelse is_binary(User_id) -> Acc2; {phone,_} when Phone==[] orelse is_binary(Phone) orelse is_tuple(Phone) -> Acc2; {token,_} when Token==[] orelse is_binary(Token) -> Acc2; - {type,_} when Type==[] orelse is_atom(Type) -> Acc2; + {type,_} when Type==[] orelse Type=='update' orelse Type=='clear' orelse Type=='delete' orelse Type=='deleted' orelse Type=='logout' orelse Type=='verify' orelse Type=='verified' orelse Type=='expired' orelse Type=='reg' orelse Type=='resend' orelse Type=='voice' orelse Type=='push' orelse Type=='get' orelse is_tuple(Type) -> Acc2; {sms_code,_} when Sms_code==[] orelse is_binary(Sms_code) -> Acc2; {attempts,_} when Attempts==[] orelse is_integer(Attempts) -> Acc2; {services,_} when is_list(Services) -> @@ -628,7 +595,7 @@ validate(D = #'Roster'{id = Id, names = Names, surnames = Surnames, email = Emai {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {status,_} when Status==[] orelse Status=='get' orelse Status=='create' orelse Status=='del' orelse Status=='remove' orelse Status=='nick' orelse Status=='add' orelse Status=='update' orelse Status=='list' orelse Status=='patch' orelse Status=='last_msg' -> Acc2; + {status,_} when Status==[] orelse Status=='get' orelse Status=='create' orelse Status=='del' orelse Status=='remove' orelse Status=='nick' orelse Status=='search' orelse Status=='contact' orelse Status=='add' orelse Status=='update' orelse Status=='list' orelse Status=='patch' orelse Status=='last_msg' -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'Roster'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -721,7 +688,7 @@ validate(D = #'error'{code = Code}, Acc, {CustomValidateModule, ValidateFun} = C validate(D = #'ok'{code = Code}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of - {code,_} when Code==[] orelse is_binary(Code) -> Acc2; + {code,_} when Code==[] orelse Code=='sms_sent' orelse Code=='call_in_progress' orelse Code=='push' orelse Code=='cleared' orelse Code=='logout' orelse is_binary(Code) -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'ok'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -745,7 +712,7 @@ validate(D = #'io'{code = Code, data = Data}, Acc, {CustomValidateModule, Valida ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of {code,_} when Code==[] orelse is_record(Code,'ok') orelse is_record(Code,'error') orelse is_record(Code,'ok2') orelse is_record(Code,'error2') -> Acc2; - {data,_} when Data==[] orelse is_binary(Data) orelse is_record(Data,'Roster') orelse is_tuple(Data) -> Acc2; + {data,_} when Data==[] orelse is_binary(Data) orelse is_binary(Data) orelse is_record(Data,'Roster') orelse is_tuple(Data) -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'io'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; @@ -801,39 +768,17 @@ validate(D = #'handler'{name = Name, module = Module, class = Class, group = Gro _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'handler'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'pi'{name = Name, sup = Sup, module = Module, state = State}, Acc, {CustomValidateModule, ValidateFun} = CM) -> +validate(D = #'pi'{name = Name, table = Table, sup = Sup, module = Module, state = State}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of - {name,_} when is_atom(Name) -> Acc2; + {name,_} -> Acc2; + {table,_} when is_atom(Table) -> Acc2; {sup,_} when is_atom(Sup) -> Acc2; {module,_} when is_atom(Module) -> Acc2; {state,_} -> Acc2; _ -> [{RecField, D}|Acc2] end end, Acc, lists:zip(record_info(fields, 'pi'), tl(tuple_to_list(D)))), ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'cx'{handlers = Handlers, actions = Actions, req = Req, module = Module, lang = Lang, path = Path, session = Session, formatter = Formatter, params = Params, node = Node, client_pid = Client_pid, state = State, from = From, vsn = Vsn}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {handlers,_} when is_list(Handlers) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'handler') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{handlers, D}|Acc3] end, Acc2, Handlers); - {actions,_} when is_list(Actions) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{actions, D}|Acc3] end, Acc2, Actions); - {req,_} when Req==[] orelse true -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {lang,_} when Lang==[] orelse is_atom(Lang) -> Acc2; - {path,_} when Path==[] orelse is_binary(Path) -> Acc2; - {session,_} when Session==[] orelse is_binary(Session) -> Acc2; - {formatter,_} when Formatter=='bert' orelse Formatter=='json' -> Acc2; - {params,_} when Params==[] orelse is_list(Params) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{params, D}|Acc3] end, Acc2, Params); - {node,_} when Node==[] orelse is_atom(Node) -> Acc2; - {client_pid,_} when Client_pid==[] orelse true -> Acc2; - {state,_} when State==[] orelse true -> Acc2; - {from,_} when From==[] orelse is_binary(From) -> Acc2; - {vsn,_} when Vsn==[] orelse is_binary(Vsn) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'cx'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; validate(D = #'user'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, email = Email}, Acc, {CustomValidateModule, ValidateFun} = CM) -> ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> case {RecField, F} of diff --git a/apps/service/rebar.config b/apps/service/rebar.config index 3af62d09d..acd1ea7e9 100644 --- a/apps/service/rebar.config +++ b/apps/service/rebar.config @@ -1 +1 @@ -{deps,[{bert, ".*", {git, "git://github.com/synrc/bert",[]}}]}. \ No newline at end of file +{deps,[]}. \ No newline at end of file diff --git a/priv/protobuf/service_auth/Auth.proto b/priv/protobuf/service_auth/Auth.proto deleted file mode 100644 index f5c0b18ec..000000000 --- a/priv/protobuf/service_auth/Auth.proto +++ /dev/null @@ -1,30 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Auth.grpc"; -option java_outer_classname = "AuthCls"; -import public "authOs.proto"; -import public "Feature.proto"; -import public "authType.proto"; -import public "Service.proto"; - -message Auth { - string client_id = 1; - string dev_key = 2; - string user_id = 3; - string token = 4; - string data = 5; - authType type = 6; - int64 attempts = 7; - repeated Feature settings = 8; - repeated Service services = 9; - string push = 10; - authOs os = 11; - int64 created = 12; - int64 last_online = 13; -} diff --git a/priv/protobuf/service_auth/Desc.proto b/priv/protobuf/service_auth/Desc.proto deleted file mode 100644 index a1bdff122..000000000 --- a/priv/protobuf/service_auth/Desc.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Desc.grpc"; -option java_outer_classname = "DescCls"; -import public "Feature.proto"; - -message Desc { - string id = 1; - string mime = 2; - string payload = 3; - string parentid = 4; - repeated Feature data = 5; -} diff --git a/priv/protobuf/service_auth/Service.proto b/priv/protobuf/service_auth/Service.proto deleted file mode 100644 index 5255c1138..000000000 --- a/priv/protobuf/service_auth/Service.proto +++ /dev/null @@ -1,22 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Service.grpc"; -option java_outer_classname = "ServiceCls"; -import public "Feature.proto"; -import public "serverType.proto"; -import public "serverStatus.proto"; - -message Service { - string id = 1; - string data = 2; - serverType type = 3; - repeated Feature setting = 4; - int64 expiration = 5; - serverStatus service_status = 6; -} diff --git a/priv/protobuf/service_auth/Tag.proto b/priv/protobuf/service_auth/Tag.proto deleted file mode 100644 index fb29d81cb..000000000 --- a/priv/protobuf/service_auth/Tag.proto +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Tag.grpc"; -option java_outer_classname = "TagCls"; -import public "tagType.proto"; - -message Tag { - int64 roster_id = 1; - string name = 2; - string color = 3; - tagType tag_status = 4; -} diff --git a/priv/protobuf/service_auth/authOs.proto b/priv/protobuf/service_auth/authOs.proto deleted file mode 100644 index 4308091b1..000000000 --- a/priv/protobuf/service_auth/authOs.proto +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "authOs.grpc"; -option java_outer_classname = "authOsCls"; - -enum authOs { - ios = 0; - android = 1; - web = 2; -} - diff --git a/priv/protobuf/service_auth/presence.proto b/priv/protobuf/service_auth/presence.proto deleted file mode 100644 index 00f79c3f1..000000000 --- a/priv/protobuf/service_auth/presence.proto +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "presence.grpc"; -option java_outer_classname = "presenceCls"; - -enum presence { - online = 0; - offline = 1; -} - diff --git a/priv/protobuf/service_auth/serverType.proto b/priv/protobuf/service_auth/serverType.proto deleted file mode 100644 index 56279a322..000000000 --- a/priv/protobuf/service_auth/serverType.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "serverType.grpc"; -option java_outer_classname = "serverTypeCls"; - -enum serverType { - email = 0; - wallet = 1; - google_type = 2; - fb = 3; - phone = 4; -} - diff --git a/priv/protobuf/service_friend/Desc.proto b/priv/protobuf/service_friend/Desc.proto deleted file mode 100644 index cfc8b92b4..000000000 --- a/priv/protobuf/service_friend/Desc.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_friend; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Desc.grpc"; -option java_outer_classname = "DescCls"; -import public "Feature.proto"; - -message Desc { - string id = 1; - string mime = 2; - string payload = 3; - string parentid = 4; - repeated Feature data = 5; -} diff --git a/priv/protobuf/service_friend/Feature.proto b/priv/protobuf/service_friend/Feature.proto deleted file mode 100644 index 21240771b..000000000 --- a/priv/protobuf/service_friend/Feature.proto +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_friend; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Feature.grpc"; -option java_outer_classname = "FeatureCls"; - -message Feature { - string id = 1; - string key = 2; - string value = 3; - string group = 4; -} diff --git a/priv/protobuf/service_message/Feature.proto b/priv/protobuf/service_message/Feature.proto deleted file mode 100644 index c525cc914..000000000 --- a/priv/protobuf/service_message/Feature.proto +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_message; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Feature.grpc"; -option java_outer_classname = "FeatureCls"; - -message Feature { - string id = 1; - string key = 2; - string value = 3; - string group = 4; -} diff --git a/priv/protobuf/service_message/Service.proto b/priv/protobuf/service_message/Service.proto deleted file mode 100644 index fd98188cc..000000000 --- a/priv/protobuf/service_message/Service.proto +++ /dev/null @@ -1,22 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_message; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Service.grpc"; -option java_outer_classname = "ServiceCls"; -import public "Feature.proto"; -import public "serverType.proto"; -import public "serverStatus.proto"; - -message Service { - string id = 1; - string data = 2; - serverType type = 3; - repeated Feature setting = 4; - int64 expiration = 5; - serverStatus service_status = 6; -} diff --git a/priv/protobuf/service_message/Tag.proto b/priv/protobuf/service_message/Tag.proto deleted file mode 100644 index 9a1632c0d..000000000 --- a/priv/protobuf/service_message/Tag.proto +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_message; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Tag.grpc"; -option java_outer_classname = "TagCls"; -import public "tagType.proto"; - -message Tag { - int64 roster_id = 1; - string name = 2; - string color = 3; - tagType tag_status = 4; -} diff --git a/priv/protobuf/service_message/p2p.proto b/priv/protobuf/service_message/p2p.proto deleted file mode 100644 index 3290d9526..000000000 --- a/priv/protobuf/service_message/p2p.proto +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_message; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "p2p.grpc"; -option java_outer_classname = "p2pCls"; - -message p2p { - string from = 1; - string to = 2; -} diff --git a/priv/protobuf/service_profile/Desc.proto b/priv/protobuf/service_profile/Desc.proto deleted file mode 100644 index 9a5a2dd16..000000000 --- a/priv/protobuf/service_profile/Desc.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_profile; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Desc.grpc"; -option java_outer_classname = "DescCls"; -import public "Feature.proto"; - -message Desc { - string id = 1; - string mime = 2; - string payload = 3; - string parentid = 4; - repeated Feature data = 5; -} diff --git a/priv/protobuf/service_profile/Tag.proto b/priv/protobuf/service_profile/Tag.proto deleted file mode 100644 index db4d5d5b4..000000000 --- a/priv/protobuf/service_profile/Tag.proto +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_profile; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Tag.grpc"; -option java_outer_classname = "TagCls"; -import public "tagType.proto"; - -message Tag { - int64 roster_id = 1; - string name = 2; - string color = 3; - tagType tag_status = 4; -} diff --git a/priv/protobuf/service_roster/Desc.proto b/priv/protobuf/service_roster/Desc.proto deleted file mode 100644 index 99c421db4..000000000 --- a/priv/protobuf/service_roster/Desc.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_roster; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Desc.grpc"; -option java_outer_classname = "DescCls"; -import public "Feature.proto"; - -message Desc { - string id = 1; - string mime = 2; - string payload = 3; - string parentid = 4; - repeated Feature data = 5; -} diff --git a/priv/protobuf/service_roster/Service.proto b/priv/protobuf/service_roster/Service.proto deleted file mode 100644 index 180788cd3..000000000 --- a/priv/protobuf/service_roster/Service.proto +++ /dev/null @@ -1,22 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_roster; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Service.grpc"; -option java_outer_classname = "ServiceCls"; -import public "Feature.proto"; -import public "serverType.proto"; -import public "serverStatus.proto"; - -message Service { - string id = 1; - string data = 2; - serverType type = 3; - repeated Feature setting = 4; - int64 expiration = 5; - serverStatus service_status = 6; -} diff --git a/priv/protobuf/service_roster/serverType.proto b/priv/protobuf/service_roster/serverType.proto deleted file mode 100644 index 7ca622a89..000000000 --- a/priv/protobuf/service_roster/serverType.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_roster; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "serverType.grpc"; -option java_outer_classname = "serverTypeCls"; - -enum serverType { - email = 0; - wallet = 1; - google_type = 2; - fb = 3; - phone = 4; -} - diff --git a/priv/protobuf/service_roster/tagType.proto b/priv/protobuf/service_roster/tagType.proto deleted file mode 100644 index 73981ba16..000000000 --- a/priv/protobuf/service_roster/tagType.proto +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_roster; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "tagType.grpc"; -option java_outer_classname = "tagTypeCls"; - -enum tagType { - tag_create = 0; - tag_remove = 1; - tag_edit = 2; -} - diff --git a/rebar.config b/rebar.config index 81d88f9ce..5c7f5bd66 100644 --- a/rebar.config +++ b/rebar.config @@ -2,35 +2,33 @@ {lib_dirs,["apps","deps"]}. {deps_dir,"deps"}. {deps, [ - {bert, ".*", {git, "git://github.com/synrc/bert",{tag,"2.4"}}}, - {active, ".*", {git, "git://github.com/synrc/active",{tag,"master"}}}, + {active, ".*", {git, "git://github.com/synrc/active",{branch,"master"}}}, {esockd, ".*", {git, "https://github.com/voxoz/esockd",{ref, "a80634b961c315ffe5f020d73236473b53ae5dc9"}}}, - {bpe, ".*", {git, "git://github.com/synrc/bpe", {tag,"4.4"}}}, - {emqttd, ".*", {git, "git://github.com/synrc/emqttd",{tag,"master"}}}, - {n2o, ".*", {git, "git://github.com/synrc/n2o", {tag,"6.4"}}}, - {emqttc, ".*", {git, "git://github.com/voxoz/emqttc",{tag,"master"}}}, + {bpe, ".*", {git, "git://github.com/synrc/bpe", {tag,"4.5"}}}, + {emqttd, ".*", {git, "git://github.com/synrc/emqttd",{branch,"master"}}}, + {emqttc, ".*", {git, "git://github.com/voxoz/emqttc",{branch,"master"}}}, {rest, ".*", {git, "git://github.com/synrc/rest",{tag,"5.10"}}}, - {gen_smtp, ".*", {git, "git://github.com/voxoz/gen_smtp",{tag,"master"}}}, - {emq_dashboard, ".*", {git, "https://github.com/synrc/emq_dashboard",{tag,"master"}}}, + {gen_smtp, ".*", {git, "git://github.com/voxoz/gen_smtp",{branch,"master"}}}, + {emq_dashboard, ".*", {git, "https://github.com/synrc/emq_dashboard",{branch,"master"}}}, {'opencensus-erlang', ".*", {git, "https://github.com/voxoz/opencensus-erlang",{tag, "v0.4.0"}}}, - {libphonenumber_erlang, ".*", {git, "https://github.com/marinakr/libphonenumber_erlang.git",{tag,"master"}}}, - {gproc, ".*", {git, "https://github.com/uwiger/gproc","0.6.1"}}, - {erlydtl, ".*", {git, "git://github.com/voxoz/erlydtl",{tag,"master"}}}, - {mini_s3, ".*", {git, "https://github.com/chef/mini_s3.git",{tag,"master"}}}, + {libphonenumber_erlang, ".*", {git, "https://github.com/marinakr/libphonenumber_erlang.git",{branch,"master"}}}, + {gproc, ".*", {git, "https://github.com/uwiger/gproc", {tag,"0.6.1"}}}, + {erlydtl, ".*", {git, "git://github.com/voxoz/erlydtl",{branch,"master"}}}, + {mini_s3, ".*", {git, "https://github.com/chef/mini_s3.git",{branch,"master"}}}, {jwt, ".*", {git, "https://github.com/artemeff/jwt.git",{tag, "0.1.8"}}}, - {jsx, ".*", {git, "https://github.com/talentdeficit/jsx.git","v2.9.0"}}, - {base64url, ".*", {git, "https://github.com/dvv/base64url.git","v1.0"}}, - {migresia, ".*", {git, "https://github.com/yoonka/migresia.git",{tag,"master"}}}, + {jsx, ".*", {git, "https://github.com/talentdeficit/jsx.git", {tag,"v2.9.0"}}}, + {base64url, ".*", {git, "https://github.com/dvv/base64url.git", {tag,"v1.0"}}}, + {migresia, ".*", {git, "https://github.com/yoonka/migresia.git",{branch,"master"}}}, {counters, ".*", {git, "https://github.com/deadtrickster/counters.erl.git", {tag, "v0.2.0"}}}, - {ctx, ".*", {git, "https://github.com/tsloughter/ctx.git", []}}, - {wts, ".*", {git, "https://github.com/tsloughter/wts.git", []}}, + {ctx, ".*", {git, "https://github.com/tsloughter/ctx.git", {branch,"master"}}}, + {wts, ".*", {git, "https://github.com/tsloughter/wts.git", {branch,"master"}}}, {rfc3339, ".*", {git, "https://github.com/talentdeficit/rfc3339",{tag,"0.2.2"}}}, - {locus, ".*", {git, "https://github.com/g-andrade/locus.git",{tag,"master"}}}, - {prometheus, ".*", {git, "https://github.com/deadtrickster/prometheus.erl",{tag,"master"}}}, - {cowboy, ".*", {git, "git://github.com/voxoz/cowboy", {tag,"master"}}}, - {'jose-erlang', ".*", {git, "https://github.com/manifest/jose-erlang.git", {tag,"master"}}}, - {json_rec, ".*", {git, "https://github.com/justinkirby/json_rec.git", {tag,"master"}}}, - {'erlang-uuid', ".*", {git, "https://github.com/avtobiff/erlang-uuid.git",{tag,"master"}}}, + {locus, ".*", {git, "https://github.com/g-andrade/locus.git",{branch,"master"}}}, + {prometheus, ".*", {git, "https://github.com/deadtrickster/prometheus.erl",{branch,"master"}}}, + {cowboy, ".*", {git, "git://github.com/voxoz/cowboy", {branch,"master"}}}, + % ===> Dependency failure: source for jose-erlang does not contain a recognizable project and can not be built + % {'jose-erlang', ".*", {git, "https://github.com/manifest/jose-erlang.git", {branch,"master"}}}, + {'erlang-uuid', ".*", {git, "https://github.com/avtobiff/erlang-uuid.git",{branch,"master"}}}, {'qdate', ".*", {git, "https://github.com/enterprizing/qdate.git",{ref,"fba988fc54214bb37a3ce11d5c5a3cc68752c3ce"}}} ]}. {erl_opts, [{parse_transform,lager_transform},{parse_transform, oc_transform},debug_info]}. @@ -48,3 +46,6 @@ {include_erts, true}]} ]} ]}. +{dialyzer, [ + {warnings, [underspecs, no_return]} +]}. \ No newline at end of file diff --git a/rebar.config.script b/rebar.config.script new file mode 100644 index 000000000..e1e5c7da4 --- /dev/null +++ b/rebar.config.script @@ -0,0 +1,10 @@ +OSENV = os:getenv("REBAR_DEPS"). +SetAppEnv = fun(App,Config)-> [ application:set_env(App,Key,Value) || {Key,Value} <- proplists:get_value(App,Config)] end. +{ok,[SysConf]}=file:consult('sys.config'). +SetAppEnv(bert,SysConf). +io:format("Disallowed: ~p~n",[application:get_env(bert,disallowed,[])]). +case OSENV of + false -> CONFIG; % env var not defined + [] -> CONFIG; % env var set to empty string + Dir ->lists:keystore(deps_dir, 1, CONFIG, {deps_dir, Dir}) +end. diff --git a/rebar.lock b/rebar.lock index f641a2fbb..6187a263e 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,17 +1,22 @@ {"1.1.0", -[{<<"base64url">>, +[{<<"active">>, + {git,"git://github.com/synrc/active", + {ref,"db99cfed10ccb8241d89793ec1086348a731df67"}}, + 0}, + {<<"base64url">>, {git,"https://github.com/dvv/base64url.git", {ref,"f2c64ed8b9bebc536fad37ad97243452b674b837"}}, 0}, {<<"bert">>, {git,"git://github.com/synrc/bert", - {ref,"6cde41b32448e85ecd48225221d6f978943a1bad"}}, - 0}, + {ref,"3e3697d6ab97c1ecb9d5cbd80fa9742fb8a5f24e"}}, + 1}, {<<"bpe">>, {git,"git://github.com/synrc/bpe", - {ref,"356c9e621c38e927a8611ecac592bcdc8d689026"}}, + {ref,"e22a47c3d1837f3da9c592aafac1b65f464521ea"}}, 0}, {<<"certifi">>,{pkg,<<"certifi">>,<<"2.4.2">>},1}, + {<<"cf">>,{pkg,<<"cf">>,<<"0.3.1">>},2}, {<<"counters">>, {git,"https://github.com/deadtrickster/counters.erl.git", {ref,"c3f4aa3acdf71c3db0a4b3fc1343aa45de2c5df0"}}, @@ -30,7 +35,7 @@ 0}, {<<"emq_dashboard">>, {git,"https://github.com/synrc/emq_dashboard", - {ref,"f711e8d2b0a992f5540123f3504eebabc324a684"}}, + {ref,"5bee03a8325db8b7d1c89cae86e2f23b8dac7cf7"}}, 0}, {<<"emqttc">>, {git,"git://github.com/voxoz/emqttc", @@ -48,6 +53,7 @@ {git,"https://github.com/avtobiff/erlang-uuid.git", {ref,"cb02a2039a9b29dd2eef0446039c9c6e164df9ef"}}, 0}, + {<<"erlware_commons">>,{pkg,<<"erlware_commons">>,<<"1.3.1">>},1}, {<<"erlydtl">>, {git,"git://github.com/voxoz/erlydtl", {ref,"bdebe6f87d8f989018facbbf8dc6320936ffe98f"}}, @@ -58,7 +64,11 @@ 0}, {<<"forms">>, {git,"git://github.com/synrc/forms", - {ref,"845feb45a46dfc2e0e9a156da9c01c218d8fd6cc"}}, + {ref,"20104d880334a473a5557ea62596ce83e233e218"}}, + 1}, + {<<"fs">>, + {git,"git://github.com/synrc/fs", + {ref,"0023444ac9d64a86cd8ae06d929fd0e203ab6d3e"}}, 1}, {<<"gen_logger">>, {git,"git://github.com/voxoz/gen_logger", @@ -90,7 +100,7 @@ 0}, {<<"kvs">>, {git,"git://github.com/synrc/kvs", - {ref,"c0f9bd4766c2751e8f7b1752f8eb949d17f01b87"}}, + {ref,"4df1d52e941c286dd27d3ec5ebebfed88aede1c3"}}, 1}, {<<"lager">>, {git,"git://github.com/voxoz/lager", @@ -98,12 +108,16 @@ 1}, {<<"libphonenumber_erlang">>, {git,"https://github.com/marinakr/libphonenumber_erlang.git", - {ref,"3a6be75ef4f6fdd40fa8afee2a7fc5cf2ddb8601"}}, + {ref,"9e101e61f45d4d7f44d9fe30431d400e79e3856e"}}, 0}, {<<"locus">>, {git,"https://github.com/g-andrade/locus.git", - {ref,"0ea9079ce5686573e0e70e2b1311343dd25feef8"}}, + {ref,"638063fb9b2d81cfd0b219eee76ae43197ab4433"}}, 0}, + {<<"mad">>, + {git,"git://github.com/synrc/mad", + {ref,"a7ff936dc8b584422d1f5f87af20d4fc49a2e571"}}, + 1}, {<<"migresia">>, {git,"https://github.com/yoonka/migresia.git", {ref,"40e11825e01502d045e87bf8b5d7dc5a9d6e3f73"}}, @@ -118,11 +132,11 @@ 1}, {<<"n2o">>, {git,"git://github.com/synrc/n2o", - {ref,"f59f997d1432515403f505b382ce6717454abaa3"}}, - 0}, + {ref,"8bf41a8b812f0836b547ad0be30c215e06f318bb"}}, + 1}, {<<"nitro">>, {git,"git://github.com/synrc/nitro", - {ref,"1aeb421c332f94b135563f8e855b139c1b067f59"}}, + {ref,"458eecd78c0dfae258fa9b18509bee5fdcd750ff"}}, 1}, {<<"opencensus-erlang">>, {git,"https://github.com/voxoz/opencensus-erlang", @@ -131,8 +145,13 @@ {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},2}, {<<"prometheus">>, {git,"https://github.com/deadtrickster/prometheus.erl", - {ref,"46ea4b487baf4f6cc44495eae07582808e0369d4"}}, + {ref,"4cae6df7d3d0f5feb5508ffc0ea4b2eedf5136fc"}}, 0}, + {<<"qdate">>, + {git,"https://github.com/enterprizing/qdate.git", + {ref,"fba988fc54214bb37a3ce11d5c5a3cc68752c3ce"}}, + 0}, + {<<"qdate_localtime">>,{pkg,<<"qdate_localtime">>,<<"1.1.0">>},1}, {<<"ranch">>, {git,"git://github.com/voxoz/ranch", {ref,"1a75038c82ede22efec46a7dca192b8ce26309e0"}}, @@ -145,6 +164,10 @@ {git,"https://github.com/talentdeficit/rfc3339", {ref,"90effc078c5e673d025b2c1269a153ad4748d3df"}}, 0}, + {<<"sh">>, + {git,"git://github.com/synrc/sh", + {ref,"64b65f6bc8c3a8fbf24351f23357035d79d3815c"}}, + 2}, {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.4">>},1}, {<<"stacktrace_compat">>,{pkg,<<"stacktrace_compat">>,<<"1.0.2">>},1}, {<<"syn">>, @@ -158,7 +181,10 @@ [ {pkg_hash,[ {<<"certifi">>, <<"75424FF0F3BAACCFD34B1214184B6EF616D89E420B258BB0A5EA7D7BC628F7F0">>}, + {<<"cf">>, <<"5CB902239476E141EA70A740340233782D363A31EEA8AD37049561542E6CD641">>}, + {<<"erlware_commons">>, <<"0CE192AD69BC6FD0880246D852D0ECE17631E234878011D1586E053641ED4C04">>}, {<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>}, + {<<"qdate_localtime">>, <<"5F6C3ACF10ECC5A7E2EFA3DCD2C863102B962188DBD9E086EC01D29FE029DA29">>}, {<<"ssl_verify_fun">>, <<"F0EAFFF810D2041E93F915EF59899C923F4568F4585904D010387ED74988E77B">>}, {<<"stacktrace_compat">>, <<"8AD31C32C9A0EADB1EB298F04DC8B0C8D79BCC6233A638B02791FFCA4F331275">>}]} ]. diff --git a/sys.config b/sys.config index 3f0b2bab6..b56074507 100644 --- a/sys.config +++ b/sys.config @@ -3,8 +3,7 @@ {bert,[{js,"apps/roster/priv/macbert/"}, {erl,"apps/roster/src"}, {google,"apps/service/priv/"}, - {disallowed,['feed', 'Whitelist', 'FakeNumbers','Schedule','Index','process']}, - {allowed_hrl, ["roster"]}, + {disallowed,['feed', 'Whitelist', 'FakeNumbers','Schedule','Index','process','cx']}, %% TODO remove the 'cx' record / bring imprevement for bert_validator {custom_validate, {roster, validate}}, {swift,"apps/roster/priv/macbert/"}]}, {roster,[ -- GitLab From 7bcd02ffa8227e741cc2e4a779e094c81a16b8f2 Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Tue, 18 Jun 2019 14:35:37 +0300 Subject: [PATCH 02/20] was removed automatically generated file --- .gitignore | 1 + apps/roster/src/roster_validator.erl | 872 --------------------------- 2 files changed, 1 insertion(+), 872 deletions(-) delete mode 100644 apps/roster/src/roster_validator.erl diff --git a/.gitignore b/.gitignore index dc6aa32ab..845c88f42 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ apps/roster/priv/macbert/Spec/* apps/roster/priv/macbert/Source/* apps/service/priv/* +apps/roster/src/roster_validator.erl \ No newline at end of file diff --git a/apps/roster/src/roster_validator.erl b/apps/roster/src/roster_validator.erl deleted file mode 100644 index 910d4c206..000000000 --- a/apps/roster/src/roster_validator.erl +++ /dev/null @@ -1,872 +0,0 @@ --module(roster_validator). --include_lib("bpe/include/bpe.hrl"). --include_lib("emqttd/include/emqttd.hrl"). --include_lib("kvs/include/feed.hrl"). --include_lib("kvs/include/group.hrl"). --include_lib("kvs/include/kvs.hrl"). --include_lib("kvs/include/metainfo.hrl"). --include_lib("kvs/include/user.hrl"). --include_lib("n2o/include/n2o.hrl"). --include_lib("roster/include/roster.hrl"). --include_lib("roster/include/static_auth.hrl"). --compile(export_all). - -custom_validate(_Obj) -> []. -validate(Obj) -> validate(Obj, [], application:get_env(bert, custom_validate, {?MODULE, custom_validate})). -validate(Obj, Acc, _) when is_atom(Obj) -> Acc; -validate(Obj, Acc, _) when is_integer(Obj) -> Acc; -validate(Obj, Acc, _) when is_binary(Obj) -> Acc; - -validate(D = #'writer'{id = Id, count = Count, cache = Cache, args = Args, first = First}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - {cache,_} when Cache==[] orelse is_tuple(Cache) -> Acc2; - {args,_} -> Acc2; - {first,_} when First==[] orelse is_tuple(First) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'writer'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'reader'{id = Id, pos = Pos, cache = Cache, args = Args, feed = Feed, dir = Dir}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} -> Acc2; - {pos,_} when Pos==[] orelse is_integer(Pos) -> Acc2; - {cache,_} when Cache==[] orelse is_integer(Cache) orelse is_tuple(Cache) -> Acc2; - {args,_} -> Acc2; - {feed,_} -> Acc2; - {dir,_} when Dir==0 orelse Dir==1 -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'reader'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'cur'{id = Id, top = Top, bot = Bot, dir = Dir, reader = Reader, writer = Writer, args = Args}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {bot,_} when Bot==[] orelse is_integer(Bot) -> Acc2; - {dir,_} when Dir==0 orelse Dir==1 -> Acc2; - {reader,_} when Reader==[] orelse is_tuple(Reader) -> Acc2; - {writer,_} when Writer==[] orelse is_tuple(Writer) -> Acc2; - {args,_} when is_list(Args) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) orelse is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{args, D}|Acc3] end, Acc2, Args); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'cur'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'iter'{id = Id, container = Container, feed = Feed, next = Next, prev = Prev}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed,_} -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'iter'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'container'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'container'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'iterator'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'iterator'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'log'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'log'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'operation'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'operation'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'task'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when Roles==[] orelse is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'task'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'userTask'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when Roles==[] orelse is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'userTask'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'serviceTask'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when Roles==[] orelse is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'serviceTask'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'receiveTask'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when Roles==[] orelse is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'receiveTask'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'messageEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) orelse is_list(Name) orelse is_binary(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - {timeout,_} when Timeout==[] orelse is_tuple(Timeout) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'messageEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'boundaryEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout, timeDate = TimeDate, timeDuration = TimeDuration, timeCycle = TimeCycle}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - {timeout,_} when is_tuple(Timeout) -> Acc2; - {timeDate,_} when TimeDate==[] orelse is_binary(TimeDate) -> Acc2; - {timeDuration,_} when TimeDuration==[] orelse is_binary(TimeDuration) -> Acc2; - {timeCycle,_} when TimeCycle==[] orelse is_binary(TimeCycle) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'boundaryEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'timeoutEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout, timeDate = TimeDate, timeDuration = TimeDuration, timeCycle = TimeCycle}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - {timeout,_} when Timeout==[] orelse is_tuple(Timeout) -> Acc2; - {timeDate,_} when TimeDate==[] orelse is_binary(TimeDate) -> Acc2; - {timeDuration,_} when TimeDuration==[] orelse is_binary(TimeDuration) -> Acc2; - {timeCycle,_} when TimeCycle==[] orelse is_binary(TimeCycle) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'timeoutEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'beginEvent'{name = Name, module = Module, prompt = Prompt}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'beginEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'endEvent'{name = Name, module = Module, prompt = Prompt}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'endEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'sequenceFlow'{source = Source, target = Target}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {source,_} when Source==[] orelse is_atom(Source) -> Acc2; - {target,_} when Target==[] orelse is_atom(Target) orelse is_list(Target) -> - lists:foldl(fun(Tmp, Acc3) when is_atom(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{target, D}|Acc3] end, Acc2, Target); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'sequenceFlow'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'hist'{container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, name = Name, task = Task, docs = Docs, time = Time}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {container,_} when Container==[] orelse is_atom(Container) -> Acc2; - - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {task,_} when Task==[] orelse is_atom(Task) orelse is_tuple(Task) -> Acc2; - {docs,_} when is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - {time,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'hist'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Comp'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Comp'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Proc'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Proc'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Load'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Load'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Hist'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Hist'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Make'{proc = Proc, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {proc,_} when Proc==[] orelse is_record(Proc,'process') orelse is_binary(Proc) -> Acc2; - {docs,_} when Docs==[] orelse is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Make'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Amen'{id = Id, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {docs,_} when Docs==[] orelse is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Amen'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'chain'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'chain'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'push'{model = Model, type = Type, title = Title, alert = Alert, badge = Badge, sound = Sound}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {model,_} when Model==[] orelse true -> Acc2; - {type,_} when Type==[] orelse is_binary(Type) -> Acc2; - {title,_} when Title==[] orelse is_binary(Title) -> Acc2; - {alert,_} when Alert==[] orelse is_binary(Alert) -> Acc2; - {badge,_} when Badge==[] orelse is_integer(Badge) -> Acc2; - {sound,_} when Sound==[] orelse is_binary(Sound) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'push'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Search'{id = Id, ref = Ref, field = Field, type = Type, value = Value, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when is_integer(Id) -> Acc2; - {ref,_} when is_binary(Ref) -> Acc2; - {field,_} when is_binary(Field) -> Acc2; - {type,_} when Type=='==' orelse Type=='!=' orelse Type=='like' -> Acc2; - {value,_} when is_list(Value) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{value, D}|Acc3] end, Acc2, Value); - {status,_} when Status=='profile' orelse Status=='roster' orelse Status=='contact' orelse Status=='member' orelse Status=='room' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Search'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'p2p'{from = From, to = To}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {from,_} when is_binary(From) -> Acc2; - {to,_} when is_binary(To) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'p2p'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'muc'{name = Name}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when is_binary(Name) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'muc'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqi'{feed_id = Feed_id, query = Query, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {feed_id, #'muc'{}} -> Acc2; - {query,_} when Query==[] orelse is_binary(Query) -> Acc2; - {status,_} when Status==[] orelse Status=='admin' orelse Status=='member' orelse Status=='removed' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqi'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Feature'{id = Id, key = Key, value = Value, group = Group}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {key,_} when is_binary(Key) -> Acc2; - {value,_} when Value==[] orelse is_binary(Value) -> Acc2; - {group,_} when Group==[] orelse is_binary(Group) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Feature'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Service'{id = Id, type = Type, data = Data, login = Login, password = Password, expiration = Expiration, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {type,_} when Type=='email' orelse Type=='vox' orelse Type=='aws' orelse Type=='wallet' -> Acc2; - {data,_} -> Acc2; - {login,_} when Login==[] orelse is_binary(Login) -> Acc2; - {password,_} when Password==[] orelse is_binary(Password) -> Acc2; - {expiration,_} when Expiration==[] orelse is_integer(Expiration) -> Acc2; - {status,_} when Status==[] orelse Status=='verified' orelse Status=='added' orelse Status=='add' orelse Status=='remove' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Service'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Member'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, phone_id = Phone_id, avatar = Avatar, names = Names, surnames = Surnames, alias = Alias, reader = Reader, update = Update, settings = Settings, services = Services, presence = Presence, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when Container=='chain' orelse Container=='cur' orelse Container==[] -> Acc2; - {feed_id,_} when is_record(Feed_id,'muc') orelse is_record(Feed_id,'p2p') orelse Feed_id==[] -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {phone_id,_} when Phone_id==[] orelse is_binary(Phone_id) -> Acc2; - {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; - {names,_} when Names==[] orelse is_binary(Names) -> Acc2; - {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; - {alias,_} when Alias==[] orelse is_binary(Alias) -> Acc2; - {reader,_} when Reader==[] orelse is_integer(Reader) orelse is_record(Reader,'reader') -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {services,_} when Services==[] orelse is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {presence,_} when Presence==[] orelse Presence=='online' orelse Presence=='offline' -> Acc2; - {status,_} when Status==[] orelse Status=='admin' orelse Status=='member' orelse Status=='removed' orelse Status=='patch' orelse Status=='owner' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Member'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Desc'{id = Id, mime = Mime, payload = Payload, parentid = Parentid, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {mime,_} when Mime==[] orelse is_binary(Mime) -> Acc2; - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - {parentid,_} when Parentid==[] orelse is_binary(Parentid) -> Acc2; - {data,_} when is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Desc'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'StickerPack'{id = Id, name = Name, keywords = Keywords, description = Description, author = Author, stickers = Stickers, created = Created, updated = Updated, downloaded = Downloaded}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {keywords,_} when is_list(Keywords) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{keywords, D}|Acc3] end, Acc2, Keywords); - {description,_} when Description==[] orelse is_binary(Description) -> Acc2; - {author,_} when Author==[] orelse is_binary(Author) -> Acc2; - {stickers,_} when is_list(Stickers) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Desc') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{stickers, D}|Acc3] end, Acc2, Stickers); - {created,_} when is_integer(Created) -> Acc2; - {updated,_} when is_integer(Updated) -> Acc2; - {downloaded,_} when is_integer(Downloaded) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'StickerPack'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Message'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, msg_id = Msg_id, from = From, to = To, created = Created, files = Files, type = Type, link = Link, seenby = Seenby, repliedby = Repliedby, mentioned = Mentioned, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when Container=='chain' orelse Container=='cur' orelse Container==[] -> Acc2; - {feed_id,_} when Feed_id==[] orelse is_record(Feed_id,'muc') orelse is_record(Feed_id,'p2p') -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {msg_id,_} when Msg_id==[] orelse is_binary(Msg_id) -> Acc2; - {from,_} when From==[] orelse is_binary(From) -> Acc2; - {to,_} when To==[] orelse is_binary(To) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {files,_} when is_list(Files) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Desc') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{files, D}|Acc3] end, Acc2, Files); - {type,_} when is_list(Type) -> - lists:foldl(fun(Tmp, Acc3) when Tmp=='sys' orelse Tmp=='reply' orelse Tmp=='forward' orelse Tmp=='read' orelse Tmp=='edited' orelse Tmp=='cursor' -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{type, D}|Acc3] end, Acc2, Type); - {link,_} when Link==[] orelse is_integer(Link) orelse is_record(Link,'Message') -> Acc2; - {seenby,_} when Seenby==[] orelse is_list(Seenby) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) orelse is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{seenby, D}|Acc3] end, Acc2, Seenby); - {repliedby,_} when Repliedby==[] orelse is_list(Repliedby) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{repliedby, D}|Acc3] end, Acc2, Repliedby); - {mentioned,_} when Mentioned==[] orelse is_list(Mentioned) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{mentioned, D}|Acc3] end, Acc2, Mentioned); - {status,_} when Status==[] orelse Status=='async' orelse Status=='delete' orelse Status=='clear' orelse Status=='update' orelse Status=='edit' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Message'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Link'{id = Id, name = Name, room_id = Room_id, created = Created, type = Type, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {room_id,_} when Room_id==[] orelse is_binary(Room_id) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {type,_} when Type==[] orelse Type=='group' orelse Type=='channel' -> Acc2; - {status,_} when Status==[] orelse Status=='gen' orelse Status=='check' orelse Status=='add' orelse Status=='get' orelse Status=='join' orelse Status=='update' orelse Status=='delete' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Link'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Room'{id = Id, name = Name, links = Links, description = Description, settings = Settings, members = Members, admins = Admins, data = Data, type = Type, tos = Tos, tos_update = Tos_update, unread = Unread, mentions = Mentions, readers = Readers, last_msg = Last_msg, update = Update, created = Created, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {links,_} when Links==[] orelse is_list(Links) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Link') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{links, D}|Acc3] end, Acc2, Links); - {description,_} when Description==[] orelse is_binary(Description) -> Acc2; - {settings,_} when is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {members,_} when is_list(Members) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Member') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{members, D}|Acc3] end, Acc2, Members); - {admins,_} when is_list(Admins) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Member') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{admins, D}|Acc3] end, Acc2, Admins); - {data,_} when is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Desc') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {type,_} when Type==[] orelse Type=='group' orelse Type=='channel' orelse Type=='call' -> Acc2; - {tos,_} when Tos==[] orelse is_binary(Tos) -> Acc2; - {tos_update,_} when Tos_update==[] orelse is_integer(Tos_update) -> Acc2; - {unread,_} when Unread==[] orelse is_integer(Unread) -> Acc2; - {mentions,_} when is_list(Mentions) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{mentions, D}|Acc3] end, Acc2, Mentions); - {readers,_} when is_list(Readers) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{readers, D}|Acc3] end, Acc2, Readers); - {last_msg,_} when Last_msg==[] orelse is_integer(Last_msg) orelse is_record(Last_msg,'Message') -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {status,_} when Status==[] orelse Status=='create' orelse Status=='leave' orelse Status=='add' orelse Status=='remove' orelse Status=='removed' orelse Status=='join' orelse Status=='joined' orelse Status=='info' orelse Status=='patch' orelse Status=='get' orelse Status=='delete' orelse Status=='last_msg' orelse Status=='mute' orelse Status=='unmute' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Room'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Tag'{roster_id = Roster_id, name = Name, color = Color, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {roster_id,_} when Roster_id==[] orelse is_binary(Roster_id) -> Acc2; - {name,_} when is_binary(Name) -> Acc2; - {color,_} when is_binary(Color) -> Acc2; - {status,_} when Status==[] orelse Status=='create' orelse Status=='remove' orelse Status=='edit' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Tag'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Star'{id = Id, client_id = Client_id, roster_id = Roster_id, message = Message, tags = Tags, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {client_id,_} when Client_id==[] orelse is_binary(Client_id) -> Acc2; - {roster_id,_} when Roster_id==[] orelse is_integer(Roster_id) -> Acc2; - {message,_} when Message==[] orelse is_record(Message,'Message') -> Acc2; - {tags,_} when is_list(Tags) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Tag') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{tags, D}|Acc3] end, Acc2, Tags); - {status,_} when Status==[] orelse Status=='add' orelse Status=='remove' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Star'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Typing'{phone_id = Phone_id, comments = Comments}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone_id,_} when is_binary(Phone_id) -> Acc2; - {comments,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Typing'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Contact'{phone_id = Phone_id, avatar = Avatar, names = Names, surnames = Surnames, nick = Nick, reader = Reader, unread = Unread, last_msg = Last_msg, update = Update, created = Created, settings = Settings, services = Services, presence = Presence, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone_id,_} when Phone_id==[] orelse is_binary(Phone_id) -> Acc2; - {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; - {names,_} when Names==[] orelse is_binary(Names) -> Acc2; - {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; - {nick,_} when Nick==[] orelse is_binary(Nick) -> Acc2; - {reader,_} when Reader==[] orelse is_integer(Reader) orelse is_list(Reader) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{reader, D}|Acc3] end, Acc2, Reader); - {unread,_} when Unread==[] orelse is_integer(Unread) -> Acc2; - {last_msg,_} when Last_msg==[] orelse is_record(Last_msg,'Message') -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {settings,_} when is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {services,_} when is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {presence,_} when Presence==[] orelse Presence=='online' orelse Presence=='offline' orelse is_binary(Presence) -> Acc2; - {status,_} when Status==[] orelse Status=='request' orelse Status=='authorization' orelse Status=='ignore' orelse Status=='internal' orelse Status=='friend' orelse Status=='last_msg' orelse Status=='ban' orelse Status=='banned' orelse Status=='deleted' orelse Status=='not_existence' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Contact'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'ExtendedStar'{star = Star, from = From}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {star,_} when is_record(Star,'Star') orelse Star==[] -> Acc2; - {from,_} when is_record(From,'Contact') orelse is_record(From,'Room') orelse From==[] -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'ExtendedStar'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Auth'{client_id = Client_id, dev_key = Dev_key, user_id = User_id, phone = Phone, token = Token, type = Type, sms_code = Sms_code, attempts = Attempts, services = Services, settings = Settings, push = Push, os = Os, created = Created, last_online = Last_online}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {client_id,_} when Client_id==[] orelse is_binary(Client_id) -> Acc2; - {dev_key,_} when Dev_key==[] orelse is_binary(Dev_key) -> Acc2; - {user_id,_} when User_id==[] orelse is_binary(User_id) -> Acc2; - {phone,_} when Phone==[] orelse is_binary(Phone) orelse is_tuple(Phone) -> Acc2; - {token,_} when Token==[] orelse is_binary(Token) -> Acc2; - {type,_} when Type==[] orelse Type=='update' orelse Type=='clear' orelse Type=='delete' orelse Type=='deleted' orelse Type=='logout' orelse Type=='verify' orelse Type=='verified' orelse Type=='expired' orelse Type=='reg' orelse Type=='resend' orelse Type=='voice' orelse Type=='push' orelse Type=='get' orelse is_tuple(Type) -> Acc2; - {sms_code,_} when Sms_code==[] orelse is_binary(Sms_code) -> Acc2; - {attempts,_} when Attempts==[] orelse is_integer(Attempts) -> Acc2; - {services,_} when is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {push,_} when Push==[] orelse is_binary(Push) -> Acc2; - {os,_} when Os==[] orelse Os=='ios' orelse Os=='android' orelse Os=='web' -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {last_online,_} when Last_online==[] orelse is_integer(Last_online) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Auth'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Roster'{id = Id, names = Names, surnames = Surnames, email = Email, nick = Nick, userlist = Userlist, roomlist = Roomlist, favorite = Favorite, tags = Tags, phone = Phone, avatar = Avatar, update = Update, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) orelse is_integer(Id) -> Acc2; - {names,_} when Names==[] orelse is_binary(Names) -> Acc2; - {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; - {email,_} when Email==[] orelse is_binary(Email) -> Acc2; - {nick,_} when Nick==[] orelse is_binary(Nick) -> Acc2; - {userlist,_} when is_list(Userlist) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Contact') orelse is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{userlist, D}|Acc3] end, Acc2, Userlist); - {roomlist,_} when is_list(Roomlist) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Room') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{roomlist, D}|Acc3] end, Acc2, Roomlist); - {favorite,_} when is_list(Favorite) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Star') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{favorite, D}|Acc3] end, Acc2, Favorite); - {tags,_} when is_list(Tags) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Tag') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{tags, D}|Acc3] end, Acc2, Tags); - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {status,_} when Status==[] orelse Status=='get' orelse Status=='create' orelse Status=='del' orelse Status=='remove' orelse Status=='nick' orelse Status=='search' orelse Status=='contact' orelse Status=='add' orelse Status=='update' orelse Status=='list' orelse Status=='patch' orelse Status=='last_msg' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Roster'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Profile'{phone = Phone, services = Services, rosters = Rosters, settings = Settings, update = Update, balance = Balance, presence = Presence, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {services,_} when Services==[] orelse is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {rosters,_} when Rosters==[] orelse is_list(Rosters) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Roster') orelse is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{rosters, D}|Acc3] end, Acc2, Rosters); - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {update,_} when is_integer(Update) -> Acc2; - {balance,_} when is_integer(Balance) -> Acc2; - {presence,_} when Presence==[] orelse Presence=='offline' orelse Presence=='online' orelse is_binary(Presence) -> Acc2; - {status,_} when Status==[] orelse Status=='remove' orelse Status=='get' orelse Status=='patch' orelse Status=='update' orelse Status=='delete' orelse Status=='create' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Profile'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Presence'{uid = Uid, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {uid,_} when is_binary(Uid) -> Acc2; - {status,_} when Status==[] orelse Status=='offline' orelse Status=='online' orelse is_binary(Status) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Presence'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Friend'{phone_id = Phone_id, friend_id = Friend_id, settings = Settings, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone_id,_} when is_binary(Phone_id) -> Acc2; - {friend_id,_} when is_binary(Friend_id) -> Acc2; - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {status,_} when Status=='ban' orelse Status=='unban' orelse Status=='request' orelse Status=='confirm' orelse Status=='update' orelse Status=='ignore' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Friend'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'act'{name = Name, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {data,_} when is_binary(Data) orelse is_integer(Data) orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'act'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Job'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, context = Context, proc = Proc, time = Time, data = Data, events = Events, settings = Settings, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when Container=='chain' orelse Container==[] -> Acc2; - {feed_id, #'act'{}} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {context,_} when Context==[] orelse is_integer(Context) orelse is_binary(Context) -> Acc2; - {proc,_} when Proc==[] orelse is_integer(Proc) orelse is_record(Proc,'process') -> Acc2; - {time,_} when Time==[] orelse is_integer(Time) -> Acc2; - {data,_} when Data==[] orelse is_binary(Data) orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when true orelse is_record(Tmp,'Message') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {events,_} when Events==[] orelse is_list(Events) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'messageEvent') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{events, D}|Acc3] end, Acc2, Events); - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {status,_} when Status==[] orelse Status=='init' orelse Status=='update' orelse Status=='delete' orelse Status=='pending' orelse Status=='stop' orelse Status=='complete' orelse Status=='restart' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Job'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'History'{roster_id = Roster_id, feed = Feed, size = Size, entity_id = Entity_id, data = Data, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {roster_id,_} when is_binary(Roster_id) -> Acc2; - {feed,_} when is_record(Feed,'p2p') orelse is_record(Feed,'muc') orelse is_record(Feed,'act') orelse is_record(Feed,'StickerPack') orelse Feed==[] -> Acc2; - {size,_} when Size==[] orelse is_integer(Size) -> Acc2; - {entity_id,_} when Entity_id==[] orelse is_integer(Entity_id) -> Acc2; - {data,_} when Data==[] orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Message') orelse is_record(Tmp,'Job') orelse is_record(Tmp,'StickerPack') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {status,_} when Status=='updated' orelse Status=='get' orelse Status=='update' orelse Status=='last_loaded' orelse Status=='last_msg' orelse Status=='get_reply' orelse Status=='double_get' orelse Status=='delete' orelse Status=='image' orelse Status=='video' orelse Status=='file' orelse Status=='link' orelse Status=='audio' orelse Status=='contact' orelse Status=='location' orelse Status=='text' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'History'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'error'{code = Code}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_atom(Code) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'error'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'ok'{code = Code}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse Code=='sms_sent' orelse Code=='call_in_progress' orelse Code=='push' orelse Code=='cleared' orelse Code=='logout' orelse is_binary(Code) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'ok'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'error2'{code = Code, src = Src}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_atom(Code) -> Acc2; - {src,_} when Src==[] orelse is_binary(Src) orelse is_integer(Src) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'error2'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'ok2'{code = Code, src = Src}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_atom(Code) -> Acc2; - {src,_} when Src==[] orelse is_tuple(Src) orelse is_binary(Src) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'ok2'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'io'{code = Code, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_record(Code,'ok') orelse is_record(Code,'error') orelse is_record(Code,'ok2') orelse is_record(Code,'error2') -> Acc2; - {data,_} when Data==[] orelse is_binary(Data) orelse is_binary(Data) orelse is_record(Data,'Roster') orelse is_tuple(Data) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'io'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Ack'{table = Table, id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {table,_} when is_atom(Table) -> Acc2; - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Ack'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'errors'{code = Code, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_list(Code) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{code, D}|Acc3] end, Acc2, Code); - {data,_} when Data==[] orelse true -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'errors'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'PushService'{recipients = Recipients, id = Id, ttl = Ttl, module = Module, priority = Priority, payload = Payload}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {recipients,_} when is_list(Recipients) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{recipients, D}|Acc3] end, Acc2, Recipients); - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {ttl,_} when Ttl==[] orelse is_integer(Ttl) -> Acc2; - {module,_} when Module==[] orelse is_binary(Module) -> Acc2; - {priority,_} when Priority==[] orelse is_binary(Priority) -> Acc2; - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'PushService'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'PublishService'{message = Message, topic = Topic, qos = Qos}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {message,_} when Message==[] orelse is_binary(Message) -> Acc2; - {topic,_} when Topic==[] orelse is_binary(Topic) -> Acc2; - {qos,_} when Qos==[] orelse is_integer(Qos) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'PublishService'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'handler'{name = Name, module = Module, class = Class, group = Group, config = Config, state = State, seq = Seq}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when is_atom(Name) -> Acc2; - {module,_} when is_atom(Module) -> Acc2; - {class,_} -> Acc2; - {group,_} when is_atom(Group) -> Acc2; - {config,_} -> Acc2; - {state,_} -> Acc2; - {seq,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'handler'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'pi'{name = Name, table = Table, sup = Sup, module = Module, state = State}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} -> Acc2; - {table,_} when is_atom(Table) -> Acc2; - {sup,_} when is_atom(Sup) -> Acc2; - {module,_} when is_atom(Module) -> Acc2; - {state,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'pi'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'user'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, email = Email}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {email,_} when Email==[] orelse is_binary(Email) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'user'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'group'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'group'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_topic'{topic = Topic, flags = Flags}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {topic,_} when is_binary(Topic) -> Acc2; - {flags,_} when is_list(Flags) -> - lists:foldl(fun(Tmp, Acc3) when Tmp=='retained' orelse Tmp=='static' -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{flags, D}|Acc3] end, Acc2, Flags); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_topic'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_client'{client_id = Client_id, client_pid = Client_pid, username = Username, peername = Peername, clean_sess = Clean_sess, proto_ver = Proto_ver, will_topic = Will_topic, ws_initial_headers = Ws_initial_headers}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {client_id,_} when is_binary(Client_id) orelse Client_id=='undefined' -> Acc2; - - {username,_} when is_binary(Username) orelse Username=='undefined' -> Acc2; - {peername,_} when is_tuple(Peername) -> Acc2; - - {proto_ver,_} when Proto_ver==3 orelse Proto_ver==4 -> Acc2; - {will_topic,_} when Will_topic=='undefined' orelse is_binary(Will_topic) -> Acc2; - {ws_initial_headers,_} when is_list(Ws_initial_headers) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{ws_initial_headers, D}|Acc3] end, Acc2, Ws_initial_headers); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_client'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_session'{client_id = Client_id, sess_pid = Sess_pid, clean_sess = Clean_sess}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {client_id,_} when is_binary(Client_id) -> Acc2; - - - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_session'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_message'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when is_binary(Id) orelse Id=='undefined' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_message'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_delivery'{sender = Sender, message = Message}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - - {message, #'mqtt_message'{}} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_delivery'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_route'{topic = Topic, node = Node}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {topic,_} when is_binary(Topic) -> Acc2; - - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_route'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_alarm'{id = Id, severity = Severity, title = Title, summary = Summary}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when is_binary(Id) -> Acc2; - {severity,_} when Severity=='warning' orelse Severity=='error' orelse Severity=='critical' -> Acc2; - {title,_} when is_list(Title) orelse is_binary(Title) -> Acc2; - {summary,_} when is_list(Summary) orelse is_binary(Summary) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_alarm'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end. \ No newline at end of file -- GitLab From 0f60f8b35e19e8afa0b944fe14cc17857748ac62 Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Tue, 18 Jun 2019 18:15:55 +0300 Subject: [PATCH 03/20] update log functions --- apps/roster/src/protocol/roster_bpe.erl | 8 ++++---- apps/roster/src/protocol/roster_history.erl | 2 +- apps/roster/src/protocol/roster_message.erl | 2 +- apps/roster/src/protocol/roster_presence.erl | 2 +- apps/roster/src/roster.erl | 4 ++-- apps/roster/src/roster_data.erl | 4 ++-- apps/roster/src/test/roster_test.erl | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/roster/src/protocol/roster_bpe.erl b/apps/roster/src/protocol/roster_bpe.erl index 6917bcd1d..2829807b4 100644 --- a/apps/roster/src/protocol/roster_bpe.erl +++ b/apps/roster/src/protocol/roster_bpe.erl @@ -31,7 +31,7 @@ info(#'History'{roster_id = Roster, feed = Feed, size = N, entity_id = MId, stat {ok, #reader{cache = []} = Rdr} when MId == 0 -> #writer{count = Count, cache = #'Job'{id = Id}} = Writer, case Count of - 0 -> n2o:error(?MODULE, "There are not messages: ~p:~n", [Writer]), {[], 0}, <<>>; + 0 -> roster:error(?MODULE, "There are not messages: ~p:~n", [Writer]), {[], 0}, <<>>; _ -> #reader{cache = {_, RId}} = kvs_stream:save(kvs_stream:top((Rdr#reader{dir = 0}))), %{ok,#'Job'{prev = ID }}=kvs:get('Job',RId), Js = roster:exclude({'Job', RId}, #'Job'.status, -?JOBS_LIMIT, 0, []), @@ -270,7 +270,7 @@ proc({update, #'Job'{id = Id0, time = Time, feed_id = {act, <<"publish">>, Phone _ -> try amend(Proc, NewSh = #'Schedule'{id = T, proc = Proc, data = NewD}, Par), roster:send_ses(C, roster:phone(PhoneId), case OldTime of 0 -> NewJ; _ -> NewJ#'Job'{status = update} end), {reply, [], H#handler{state = {C, Proc}}} - catch Err:Rea -> n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]), + catch Err:Rea -> roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]), restart_bpe(P, C), timer:sleep(300), bpe:complete(Proc), @@ -321,7 +321,7 @@ proc({next, #process{id = Id} = P, Current}, #handler{state = {C, Proc}, seq = S _ -> [Stop] end end, - try bpe:amend(Id, Docs) catch Err:Rea -> n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]) end, + try bpe:amend(Id, Docs) catch Err:Rea -> roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, kvs:delete('Schedule', Current), {reply, [], H}; @@ -339,7 +339,7 @@ proc({timeout, #'Schedule'{id = Current} = Sh, T}, #handler{state = {C, Proc}} = %{ok, TRef} = timer:apply_after(T, bpe, complete, [Proc]), {ok, TRef} = timer:apply_after(T, roster_bpe, publish, [Proc]), try bpe:amend(Proc, Sh#'Schedule'{state = TRef}, noflow) catch Err:Rea -> - n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]) end, kvs:put(Sh#'Schedule'{state = TRef}), + rosetr:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, kvs:put(Sh#'Schedule'{state = TRef}), %job_process:update_opt(bpe:load(Proc),{timer,TRef}), {reply, [], H}; diff --git a/apps/roster/src/protocol/roster_history.erl b/apps/roster/src/protocol/roster_history.erl index ad74633d4..39d974840 100644 --- a/apps/roster/src/protocol/roster_history.erl +++ b/apps/roster/src/protocol/roster_history.erl @@ -268,7 +268,7 @@ proc({send_push, ToPhoneId, Feed, Action}, #handler{} = H) -> try Room = #'Room'{} = roster:room(roster:roster_id(ToPhoneId), RoomId), case Action of ?HISTORY_UPDATE_ACTION -> Room#'Room'{last_msg = []}; _ -> Room end catch Err:Rea -> - roster:error(?MODULE, ":~p~n", [n2o:stack_trace(Err, Rea)]) + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end; #p2p{} -> Contact = roster:user(roster:roster_id(ToPhoneId), roster:friend(ToPhoneId, Feed)), diff --git a/apps/roster/src/protocol/roster_message.erl b/apps/roster/src/protocol/roster_message.erl index 5a1364a08..213701a0d 100644 --- a/apps/roster/src/protocol/roster_message.erl +++ b/apps/roster/src/protocol/roster_message.erl @@ -363,7 +363,7 @@ proc({#'Message'{status = update} = Msg, ClientId}, #handler{state = C} = H) -> try {reply, {bert, IO}, _, _} = info(Msg, {[], handled}, #cx{params = ClientId, client_pid = C, state = ack}), roster:send_action(C, ClientId, IO) catch Err:Rea -> - roster:error(?MODULE, ":~p~n", [n2o:stack_trace(Err, Rea)]) + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, {reply, [], H}; proc({mqttc, C, connected}, State = #handler{state = C, seq = S}) -> {ok, State#handler{seq = S + 1}}; diff --git a/apps/roster/src/protocol/roster_presence.erl b/apps/roster/src/protocol/roster_presence.erl index b184d0bb1..6a58e3da6 100644 --- a/apps/roster/src/protocol/roster_presence.erl +++ b/apps/roster/src/protocol/roster_presence.erl @@ -28,7 +28,7 @@ on_connect(Phone, ClientId, C, Ver) -> roster:send_cache(ClientId, C) end catch Err:Rea -> - roster:info(?MODULE, "Catch:~p", [n2o:stack_trace(Err, Rea)]) + roster:info(?MODULE, "Catch:~p~n", [{Err, Rea}]) end. on_disconnect(#'Auth'{type = logout, phone = Phone, client_id = ClientId, user_id = PhoneId}, C) -> diff --git a/apps/roster/src/roster.erl b/apps/roster/src/roster.erl index 8398fd6b8..744222a8d 100644 --- a/apps/roster/src/roster.erl +++ b/apps/roster/src/roster.erl @@ -1101,7 +1101,7 @@ user(#'Roster'{id = Id, phone = Phone}, {Presence, Update} = is_online2(PhoneId), Msgs = case catch p2p_readmsgs(Local, PhoneId) of {'EXIT', {Err, _}} -> - n2o:error(?MODULE,"Catch:~p~n",[n2o:stack_trace(error, Err)]), + roster:error(?MODULE,"Catch:~p~n",[{error, Err}]), throw({error, {user, Local, PhoneId}}); Ms -> Ms end, C#'Contact'{presence = Presence, update = Update, services = get_services(phone(PhoneId)), @@ -1676,7 +1676,7 @@ fold(Fun, Acc, Table, Start, Finish, Driver, Direction, Count, GetFun) when Star {_, _} when Dir -> Acc2; _ -> fold(Fun, Acc2, Table, Prev, Finish, Driver, Direction, Count2) end; _ -> Acc end catch Err:Rea -> - n2o:error(?MODULE, "Catch fold2:~p~n", [n2o:stack_trace(Err, Rea)]), Acc end. + roster:error(?MODULE, "Catch fold2:~p~n", [{Err, Rea}]), Acc end. %%count(#reader{pos = P}, #writer{count = T}) -> T - P. diff --git a/apps/roster/src/roster_data.erl b/apps/roster/src/roster_data.erl index b60e52e39..6022c9c35 100644 --- a/apps/roster/src/roster_data.erl +++ b/apps/roster/src/roster_data.erl @@ -143,7 +143,7 @@ friend_test_rand(RosterIds) -> %% roster_client:set_filer([AClientId, BClientId], filter), %% lists:map(fun roster_client:stop_client/1, ClientIds), ok catch Err:Rea -> - n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]), ok + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]), ok end. get_roster_ids() -> @@ -190,7 +190,7 @@ create_room(RosterIds, Room, PageMembCount, Type) -> [roster_client:test_info(roster_room, #'Room'{status = add, id = Room, members = Mmbrs}, AdmPhone)|| Mmbrs <-Mmbrs2, Mmbrs /= []] %% roster_client:stop_client(AClientId) catch Err:Rea -> - n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]) + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, Room. create_channel() -> diff --git a/apps/roster/src/test/roster_test.erl b/apps/roster/src/test/roster_test.erl index 96b21ee49..93d7afe0c 100644 --- a/apps/roster/src/test/roster_test.erl +++ b/apps/roster/src/test/roster_test.erl @@ -1561,7 +1561,7 @@ test_migrate() -> Res -> roster:info(?MODULE, "~p = migresia:check(roster)", [Res]), {error, test_migration} end catch Err:Rea -> - n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]), + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]), throw({error, migrate}) after catch kvs:delete('schema_migrations', 30171023145947), file:delete(TestFile2) end. -- GitLab From 474577a2a10a29bb4bc0c3127e37727aac35285e Mon Sep 17 00:00:00 2001 From: qomputer Date: Wed, 19 Jun 2019 13:24:22 +0300 Subject: [PATCH 04/20] Fix using bpe:amend --- apps/roster/src/protocol/roster_bpe.erl | 10 +++++----- rebar.config | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/roster/src/protocol/roster_bpe.erl b/apps/roster/src/protocol/roster_bpe.erl index 2829807b4..f7a4acc71 100644 --- a/apps/roster/src/protocol/roster_bpe.erl +++ b/apps/roster/src/protocol/roster_bpe.erl @@ -313,12 +313,12 @@ proc({next, #process{id = Id} = P, Current}, #handler{state = {C, Proc}, seq = S FirstS = try mnesia:dirty_first('Schedule') of '$end_of_table' -> Current; Key -> Key catch _ -> Current end, Stop = #'Schedule'{id = roster:now_msec(), data = <<"stop">>}, Docs = case job:next('Schedule', Current) of - [] -> [Stop]; + [] -> Stop; % kvs:put(Stop); - Doc when FirstS =:= Current -> [Doc]; + Doc when FirstS =:= Current -> Doc; _ -> case kvs:get('Schedule', FirstS) of - {ok, #'Schedule'{} = Doc} -> [Doc]; - _ -> [Stop] + {ok, #'Schedule'{} = Doc} -> Doc; + _ -> Stop end end, try bpe:amend(Id, Docs) catch Err:Rea -> roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, @@ -398,4 +398,4 @@ set_schedule(_, Time, #'Job'{id = Id, proc = Proc, time = T0} = J) -> action(#'History'{status=update}=Term,R,S)-> - roster_history:info(Term, R, S). \ No newline at end of file + roster_history:info(Term, R, S). diff --git a/rebar.config b/rebar.config index 5c7f5bd66..91a057b76 100644 --- a/rebar.config +++ b/rebar.config @@ -4,7 +4,8 @@ {deps, [ {active, ".*", {git, "git://github.com/synrc/active",{branch,"master"}}}, {esockd, ".*", {git, "https://github.com/voxoz/esockd",{ref, "a80634b961c315ffe5f020d73236473b53ae5dc9"}}}, - {bpe, ".*", {git, "git://github.com/synrc/bpe", {tag,"4.5"}}}, + {kvs, ".*", {git, "git://github.com/qomputer/kvs", {tag,"master"}}}, + {bpe, ".*", {git, "git://github.com/qomputer/bpe", {tag,"4.5"}}}, {emqttd, ".*", {git, "git://github.com/synrc/emqttd",{branch,"master"}}}, {emqttc, ".*", {git, "git://github.com/voxoz/emqttc",{branch,"master"}}}, {rest, ".*", {git, "git://github.com/synrc/rest",{tag,"5.10"}}}, -- GitLab From 4290f85705093f0d7fd1a92130a52cfe66e318e4 Mon Sep 17 00:00:00 2001 From: qomputer Date: Wed, 19 Jun 2019 13:43:38 +0300 Subject: [PATCH 05/20] Switch to kvs-branch for bpe --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 91a057b76..28b08d614 100644 --- a/rebar.config +++ b/rebar.config @@ -5,7 +5,7 @@ {active, ".*", {git, "git://github.com/synrc/active",{branch,"master"}}}, {esockd, ".*", {git, "https://github.com/voxoz/esockd",{ref, "a80634b961c315ffe5f020d73236473b53ae5dc9"}}}, {kvs, ".*", {git, "git://github.com/qomputer/kvs", {tag,"master"}}}, - {bpe, ".*", {git, "git://github.com/qomputer/bpe", {tag,"4.5"}}}, + {bpe, ".*", {git, "git://github.com/qomputer/bpe", {branch,"kvs"}}}, {emqttd, ".*", {git, "git://github.com/synrc/emqttd",{branch,"master"}}}, {emqttc, ".*", {git, "git://github.com/voxoz/emqttc",{branch,"master"}}}, {rest, ".*", {git, "git://github.com/synrc/rest",{tag,"5.10"}}}, -- GitLab From 165af3eb61255523b22fb5fa790313346558baf6 Mon Sep 17 00:00:00 2001 From: Namdak Tonpa Date: Wed, 19 Jun 2019 16:53:35 +0300 Subject: [PATCH 06/20] switch to official sources --- rebar.config | 2 +- rebar.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rebar.config b/rebar.config index 28b08d614..b3576f61d 100644 --- a/rebar.config +++ b/rebar.config @@ -5,7 +5,7 @@ {active, ".*", {git, "git://github.com/synrc/active",{branch,"master"}}}, {esockd, ".*", {git, "https://github.com/voxoz/esockd",{ref, "a80634b961c315ffe5f020d73236473b53ae5dc9"}}}, {kvs, ".*", {git, "git://github.com/qomputer/kvs", {tag,"master"}}}, - {bpe, ".*", {git, "git://github.com/qomputer/bpe", {branch,"kvs"}}}, + {bpe, ".*", {git, "git://github.com/synrc/bpe", {branch,"v4.5"}}}, {emqttd, ".*", {git, "git://github.com/synrc/emqttd",{branch,"master"}}}, {emqttc, ".*", {git, "git://github.com/voxoz/emqttc",{branch,"master"}}}, {rest, ".*", {git, "git://github.com/synrc/rest",{tag,"5.10"}}}, diff --git a/rebar.lock b/rebar.lock index 6187a263e..3387cb405 100644 --- a/rebar.lock +++ b/rebar.lock @@ -13,7 +13,7 @@ 1}, {<<"bpe">>, {git,"git://github.com/synrc/bpe", - {ref,"e22a47c3d1837f3da9c592aafac1b65f464521ea"}}, + {ref,"bcfa8a384ca975d7f8932827108a748d3c83d34c"}}, 0}, {<<"certifi">>,{pkg,<<"certifi">>,<<"2.4.2">>},1}, {<<"cf">>,{pkg,<<"cf">>,<<"0.3.1">>},2}, @@ -99,9 +99,9 @@ {ref,"6fd754fec1cd2e4577a5d7121233371900aa44e7"}}, 0}, {<<"kvs">>, - {git,"git://github.com/synrc/kvs", + {git,"git://github.com/qomputer/kvs", {ref,"4df1d52e941c286dd27d3ec5ebebfed88aede1c3"}}, - 1}, + 0}, {<<"lager">>, {git,"git://github.com/voxoz/lager", {ref,"1ecf4c17e9e39dd7a1943140477f632d17518f0c"}}, @@ -132,7 +132,7 @@ 1}, {<<"n2o">>, {git,"git://github.com/synrc/n2o", - {ref,"8bf41a8b812f0836b547ad0be30c215e06f318bb"}}, + {ref,"cb6ae134793724a6eaf37a3f498ca5e130dfc51e"}}, 1}, {<<"nitro">>, {git,"git://github.com/synrc/nitro", -- GitLab From ed2f285bfad7e168b32307f026e41888bd3292b8 Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Thu, 20 Jun 2019 12:32:18 +0300 Subject: [PATCH 07/20] [NY-7291] fixed err_hndl; patt_match; fun_arity; miss_type_spec WIP --- .gitignore | 5 +- apps/roster/include/roster.hrl | 2 +- apps/roster/priv/macbert/Model/Roster.swift | 16 - apps/roster/priv/macbert/json-bert.js | 2001 ------------------- apps/roster/src/protocol/micro_auth.erl | 8 +- apps/roster/src/protocol/roster_auth.erl | 3 +- apps/roster/src/protocol/roster_friend.erl | 6 +- apps/roster/src/protocol/roster_ftp.erl | 24 +- apps/roster/src/protocol/roster_history.erl | 4 +- apps/roster/src/protocol/roster_link.erl | 27 +- apps/roster/src/protocol/roster_message.erl | 2 +- rebar.lock | 190 -- 12 files changed, 46 insertions(+), 2242 deletions(-) delete mode 100644 apps/roster/priv/macbert/Model/Roster.swift delete mode 100644 apps/roster/priv/macbert/json-bert.js delete mode 100644 rebar.lock diff --git a/.gitignore b/.gitignore index 845c88f42..67cc952f7 100644 --- a/.gitignore +++ b/.gitignore @@ -19,10 +19,13 @@ _build .applist 0.3 +rebar.lock + priv/protobuf/* apps/roster/priv/macbert/Model/* apps/roster/priv/macbert/Spec/* apps/roster/priv/macbert/Source/* apps/service/priv/* -apps/roster/src/roster_validator.erl \ No newline at end of file +apps/roster/src/roster_validator.erl +apps/roster/priv/macbert/json-bert.js \ No newline at end of file diff --git a/apps/roster/include/roster.hrl b/apps/roster/include/roster.hrl index d3fcbeea3..4ece712dc 100644 --- a/apps/roster/include/roster.hrl +++ b/apps/roster/include/roster.hrl @@ -234,7 +234,7 @@ -record('Profile', {phone = [] :: [] | binary(), services = [] :: [] | list(#'Service'{}), - rosters = [] :: [] | list(#'Roster'{} | binary()), + rosters = [] :: [] | list(#'Roster'{} | binary() | integer()), settings = [] :: [] | list(#'Feature'{}), update = 0 :: integer(), balance = 0 :: integer(), diff --git a/apps/roster/priv/macbert/Model/Roster.swift b/apps/roster/priv/macbert/Model/Roster.swift deleted file mode 100644 index d9ff48490..000000000 --- a/apps/roster/priv/macbert/Model/Roster.swift +++ /dev/null @@ -1,16 +0,0 @@ - -class Roster { - var id: AnyObject? - var names: String? - var surnames: String? - var email: String? - var nick: String? - var userlist: [AnyObject]? - var roomlist: [Room]? - var favorite: [Star]? - var tags: [Tag]? - var phone: String? - var avatar: String? - var update: Int64? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/json-bert.js b/apps/roster/priv/macbert/json-bert.js deleted file mode 100644 index 00feb50fe..000000000 --- a/apps/roster/priv/macbert/json-bert.js +++ /dev/null @@ -1,2001 +0,0 @@ -function clean(r) { for(var k in r) if(!r[k]) delete r[k]; return r; } -function check_len(x) { try { return (eval('len'+utf8_arr(x.v[0].v))() == x.v.length) ? true : false } - catch (e) { return false; } } - -function scalar(data) { - var res = undefined; - switch (typeof data) { - case 'string': res = bin(data); break; case 'number': res = number(data); break; - default: console.log('Strange data: ' + data); } - return res; }; -function nil() { return {t: 106, v: undefined}; }; - -function decode(x) { - if (x == undefined) { - return []; - } if (x % 1 === 0) { - return x; - } else if (x.t == 108) { - var r = []; x.v.forEach(function(y) { r.push(decode(y)) }); return r; - } else if (x.t == 109) { - return utf8_arr(x.v); - } else if (x.t == 104 && check_len(x)) { - return eval('dec'+x.v[0].v)(x); - } else if (x.t == 104) { - var r=[]; x.v.forEach(function(a){r.push(decode(a))}); - return Object.assign({tup:'$'}, r); - } else return x.v; -} - -function encode(x) { - if (Array.isArray(x)) { - var r = []; x.forEach(function(y) { r.push(encode(y)) }); return {t:108,v:r}; - } else if (typeof x == 'object') { - switch (x.tup) { - case '$': delete x['tup']; var r=[]; - Object.keys(x).map(function(p){return x[p];}).forEach(function(a){r.push(encode(a))}); - return {t:104, v:r}; - default: return eval('enc'+x.tup)(x); } - } else return scalar(x); -} - -function encwriter(d) { - var tup = atom('writer'); - var id = 'id' in d && d.id ? encode(d.id) : nil(); - var count = 'count' in d && d.count ? number(d.count) : nil(); - var cache = 'cache' in d && d.cache ? encode(d.cache) : nil(); - var args = 'args' in d && d.args ? encode(d.args) : nil(); - var first = 'first' in d && d.first ? encode(d.first) : nil(); - return tuple(tup,id,count,cache,args,first); } - -function lenwriter() { return 6; } -function decwriter(d) { - var r={}; r.tup = 'writer'; - r.id = d && d.v[1] ? decode(d.v[1]) : undefined; - r.count = d && d.v[2] ? d.v[2].v : undefined; - r.cache = d && d.v[3] ? decode(d.v[3]) : undefined; - r.args = d && d.v[4] ? decode(d.v[4]) : undefined; - r.first = d && d.v[5] ? decode(d.v[5]) : undefined; - return clean(r); } - -function encreader(d) { - var tup = atom('reader'); - var id = 'id' in d && d.id ? encode(d.id) : nil(); - var pos = 'pos' in d && d.pos ? number(d.pos) : nil(); - var cache = 'cache' in d && d.cache ? encode(d.cache) : nil(); - var args = 'args' in d && d.args ? encode(d.args) : nil(); - var feed = 'feed' in d && d.feed ? encode(d.feed) : nil(); - var dir = 'dir' in d && d.dir ? encode(d.dir) : nil(); - return tuple(tup,id,pos,cache,args,feed,dir); } - -function lenreader() { return 7; } -function decreader(d) { - var r={}; r.tup = 'reader'; - r.id = d && d.v[1] ? decode(d.v[1]) : undefined; - r.pos = d && d.v[2] ? d.v[2].v : undefined; - r.cache = d && d.v[3] ? decode(d.v[3]) : undefined; - r.args = d && d.v[4] ? decode(d.v[4]) : undefined; - r.feed = d && d.v[5] ? decode(d.v[5]) : undefined; - r.dir = d && d.v[6] ? decode(d.v[6]) : undefined; - return clean(r); } - -function enccur(d) { - var tup = atom('cur'); - var id = 'id' in d && d.id ? encode(d.id) : nil(); - var top = 'top' in d && d.top ? number(d.top) : nil(); - var bot = 'bot' in d && d.bot ? number(d.bot) : nil(); - var dir = 'dir' in d && d.dir ? encode(d.dir) : nil(); - var reader = 'reader' in d && d.reader ? encode(d.reader) : nil(); - var writer = 'writer' in d && d.writer ? encode(d.writer) : nil(); - var left = 'left' in d && d.left ? encode(d.left) : nil(); - var right = 'right' in d && d.right ? encode(d.right) : nil(); - var args = []; if ('args' in d && d.args) - { d.args.forEach(function(x){ - args.push(encode(x))}); - args={t:108,v:args}; } else { args = nil() }; - var money = 'money' in d && d.money ? encode(d.money) : nil(); - var status = 'status' in d && d.status ? encode(d.status) : nil(); - return tuple(tup,id,top,bot,dir,reader,writer,left,right,args,money,status); } - -function lencur() { return 12; } -function deccur(d) { - var r={}; r.tup = 'cur'; - r.id = d && d.v[1] ? decode(d.v[1]) : undefined; - r.top = d && d.v[2] ? d.v[2].v : undefined; - r.bot = d && d.v[3] ? d.v[3].v : undefined; - r.dir = d && d.v[4] ? decode(d.v[4]) : undefined; - r.reader = d && d.v[5] ? decode(d.v[5]) : undefined; - r.writer = d && d.v[6] ? decode(d.v[6]) : undefined; - r.left = d && d.v[7] ? decode(d.v[7]) : undefined; - r.right = d && d.v[8] ? decode(d.v[8]) : undefined; - r.args = []; - (d && d.v[9] && d.v[9].v) ? - d.v[9].v.forEach(function(x){r.args.push(decode(x))}) : - r.args = undefined; - r.money = d && d.v[10] ? decode(d.v[10]) : undefined; - r.status = d && d.v[11] ? decode(d.v[11]) : undefined; - return clean(r); } - -function enciter(d) { - var tup = atom('iter'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var container = 'container' in d && d.container ? atom(d.container) : nil(); - var feed = 'feed' in d && d.feed ? encode(d.feed) : nil(); - var next = 'next' in d && d.next ? number(d.next) : nil(); - var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); - return tuple(tup,id,container,feed,next,prev); } - -function leniter() { return 6; } -function deciter(d) { - var r={}; r.tup = 'iter'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.container = d && d.v[2] ? d.v[2].v : undefined; - r.feed = d && d.v[3] ? decode(d.v[3]) : undefined; - r.next = d && d.v[4] ? d.v[4].v : undefined; - r.prev = d && d.v[5] ? d.v[5].v : undefined; - return clean(r); } - -function enccontainer(d) { - var tup = atom('container'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var top = 'top' in d && d.top ? number(d.top) : nil(); - var rear = 'rear' in d && d.rear ? number(d.rear) : nil(); - var count = 'count' in d && d.count ? number(d.count) : nil(); - return tuple(tup,id,top,rear,count); } - -function lencontainer() { return 5; } -function deccontainer(d) { - var r={}; r.tup = 'container'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.top = d && d.v[2] ? d.v[2].v : undefined; - r.rear = d && d.v[3] ? d.v[3].v : undefined; - r.count = d && d.v[4] ? d.v[4].v : undefined; - return clean(r); } - -function enciterator(d) { - var tup = atom('iterator'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var container = 'container' in d && d.container ? atom(d.container) : nil(); - var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); - var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); - var next = 'next' in d && d.next ? number(d.next) : nil(); - var feeds = []; if ('feeds' in d && d.feeds) - { d.feeds.forEach(function(x){ - feeds.push(encode(x))}); - feeds={t:108,v:feeds}; } else { feeds = nil() }; - return tuple(tup,id,container,feed_id,prev,next,feeds); } - -function leniterator() { return 7; } -function deciterator(d) { - var r={}; r.tup = 'iterator'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.container = d && d.v[2] ? d.v[2].v : undefined; - r.feed_id = d && d.v[3] ? decode(d.v[3]) : undefined; - r.prev = d && d.v[4] ? d.v[4].v : undefined; - r.next = d && d.v[5] ? d.v[5].v : undefined; - r.feeds = []; - (d && d.v[6] && d.v[6].v) ? - d.v[6].v.forEach(function(x){r.feeds.push(decode(x))}) : - r.feeds = undefined; - return clean(r); } - -function enclog(d) { - var tup = atom('log'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var top = 'top' in d && d.top ? number(d.top) : nil(); - var rear = 'rear' in d && d.rear ? number(d.rear) : nil(); - var count = 'count' in d && d.count ? number(d.count) : nil(); - return tuple(tup,id,top,rear,count); } - -function lenlog() { return 5; } -function declog(d) { - var r={}; r.tup = 'log'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.top = d && d.v[2] ? d.v[2].v : undefined; - r.rear = d && d.v[3] ? d.v[3].v : undefined; - r.count = d && d.v[4] ? d.v[4].v : undefined; - return clean(r); } - -function encoperation(d) { - var tup = atom('operation'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var container = 'container' in d && d.container ? atom(d.container) : nil(); - var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); - var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); - var next = 'next' in d && d.next ? number(d.next) : nil(); - var feeds = []; if ('feeds' in d && d.feeds) - { d.feeds.forEach(function(x){ - feeds.push(encode(x))}); - feeds={t:108,v:feeds}; } else { feeds = nil() }; - var body = 'body' in d && d.body ? encode(d.body) : nil(); - var name = 'name' in d && d.name ? encode(d.name) : nil(); - var status = 'status' in d && d.status ? encode(d.status) : nil(); - return tuple(tup,id,container,feed_id,prev,next,feeds,body,name,status); } - -function lenoperation() { return 10; } -function decoperation(d) { - var r={}; r.tup = 'operation'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.container = d && d.v[2] ? d.v[2].v : undefined; - r.feed_id = d && d.v[3] ? decode(d.v[3]) : undefined; - r.prev = d && d.v[4] ? d.v[4].v : undefined; - r.next = d && d.v[5] ? d.v[5].v : undefined; - r.feeds = []; - (d && d.v[6] && d.v[6].v) ? - d.v[6].v.forEach(function(x){r.feeds.push(decode(x))}) : - r.feeds = undefined; - r.body = d && d.v[7] ? decode(d.v[7]) : undefined; - r.name = d && d.v[8] ? decode(d.v[8]) : undefined; - r.status = d && d.v[9] ? decode(d.v[9]) : undefined; - return clean(r); } - -function enckvs(d) { - var tup = atom('kvs'); - var mod = 'mod' in d && d.mod ? encode(d.mod) : nil(); - return tuple(tup,mod); } - -function lenkvs() { return 2; } -function deckvs(d) { - var r={}; r.tup = 'kvs'; - r.mod = d && d.v[1] ? decode(d.v[1]) : undefined; - return clean(r); } - -function encfeed(d) { - var tup = atom('feed'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var top = 'top' in d && d.top ? number(d.top) : nil(); - var rear = 'rear' in d && d.rear ? number(d.rear) : nil(); - var count = 'count' in d && d.count ? number(d.count) : nil(); - var aclver = 'aclver' in d && d.aclver ? encode(d.aclver) : nil(); - return tuple(tup,id,top,rear,count,aclver); } - -function lenfeed() { return 6; } -function decfeed(d) { - var r={}; r.tup = 'feed'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.top = d && d.v[2] ? d.v[2].v : undefined; - r.rear = d && d.v[3] ? d.v[3].v : undefined; - r.count = d && d.v[4] ? d.v[4].v : undefined; - r.aclver = d && d.v[5] ? decode(d.v[5]) : undefined; - return clean(r); } - -function enctask(d) { - var tup = atom('task'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var prompt = []; if ('prompt' in d && d.prompt) - { d.prompt.forEach(function(x){ - prompt.push(encode(x))}); - prompt={t:108,v:prompt}; } else { prompt = nil() }; - var roles = 'roles' in d && d.roles ? bin(d.roles) : nil(); - return tuple(tup,name,module,prompt,roles); } - -function lentask() { return 5; } -function dectask(d) { - var r={}; r.tup = 'task'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.prompt = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : - r.prompt = undefined; - r.roles = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - return clean(r); } - -function encuserTask(d) { - var tup = atom('userTask'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var prompt = []; if ('prompt' in d && d.prompt) - { d.prompt.forEach(function(x){ - prompt.push(encode(x))}); - prompt={t:108,v:prompt}; } else { prompt = nil() }; - var roles = 'roles' in d && d.roles ? bin(d.roles) : nil(); - return tuple(tup,name,module,prompt,roles); } - -function lenuserTask() { return 5; } -function decuserTask(d) { - var r={}; r.tup = 'userTask'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.prompt = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : - r.prompt = undefined; - r.roles = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - return clean(r); } - -function encserviceTask(d) { - var tup = atom('serviceTask'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var prompt = []; if ('prompt' in d && d.prompt) - { d.prompt.forEach(function(x){ - prompt.push(encode(x))}); - prompt={t:108,v:prompt}; } else { prompt = nil() }; - var roles = 'roles' in d && d.roles ? bin(d.roles) : nil(); - return tuple(tup,name,module,prompt,roles); } - -function lenserviceTask() { return 5; } -function decserviceTask(d) { - var r={}; r.tup = 'serviceTask'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.prompt = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : - r.prompt = undefined; - r.roles = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - return clean(r); } - -function encreceiveTask(d) { - var tup = atom('receiveTask'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var prompt = []; if ('prompt' in d && d.prompt) - { d.prompt.forEach(function(x){ - prompt.push(encode(x))}); - prompt={t:108,v:prompt}; } else { prompt = nil() }; - var roles = 'roles' in d && d.roles ? bin(d.roles) : nil(); - return tuple(tup,name,module,prompt,roles); } - -function lenreceiveTask() { return 5; } -function decreceiveTask(d) { - var r={}; r.tup = 'receiveTask'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.prompt = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : - r.prompt = undefined; - r.roles = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - return clean(r); } - -function encmessageEvent(d) { - var tup = atom('messageEvent'); - var name = 'name' in d && d.name ? encode(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var prompt = []; if ('prompt' in d && d.prompt) - { d.prompt.forEach(function(x){ - prompt.push(encode(x))}); - prompt={t:108,v:prompt}; } else { prompt = nil() }; - var payload = 'payload' in d && d.payload ? bin(d.payload) : nil(); - var timeout = 'timeout' in d && d.timeout ? encode(d.timeout) : nil(); - return tuple(tup,name,module,prompt,payload,timeout); } - -function lenmessageEvent() { return 6; } -function decmessageEvent(d) { - var r={}; r.tup = 'messageEvent'; - r.name = d && d.v[1] ? decode(d.v[1]) : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.prompt = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : - r.prompt = undefined; - r.payload = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.timeout = d && d.v[5] ? decode(d.v[5]) : undefined; - return clean(r); } - -function encboundaryEvent(d) { - var tup = atom('boundaryEvent'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var prompt = []; if ('prompt' in d && d.prompt) - { d.prompt.forEach(function(x){ - prompt.push(encode(x))}); - prompt={t:108,v:prompt}; } else { prompt = nil() }; - var payload = 'payload' in d && d.payload ? bin(d.payload) : nil(); - var timeout = 'timeout' in d && d.timeout ? encode(d.timeout) : nil(); - var timeDate = 'timeDate' in d && d.timeDate ? bin(d.timeDate) : nil(); - var timeDuration = 'timeDuration' in d && d.timeDuration ? bin(d.timeDuration) : nil(); - var timeCycle = 'timeCycle' in d && d.timeCycle ? bin(d.timeCycle) : nil(); - return tuple(tup,name,module,prompt,payload,timeout,timeDate,timeDuration,timeCycle); } - -function lenboundaryEvent() { return 9; } -function decboundaryEvent(d) { - var r={}; r.tup = 'boundaryEvent'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.prompt = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : - r.prompt = undefined; - r.payload = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.timeout = d && d.v[5] ? decode(d.v[5]) : undefined; - r.timeDate = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; - r.timeDuration = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; - r.timeCycle = d && d.v[8] ? utf8_arr(d.v[8].v) : undefined; - return clean(r); } - -function enctimeoutEvent(d) { - var tup = atom('timeoutEvent'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var prompt = []; if ('prompt' in d && d.prompt) - { d.prompt.forEach(function(x){ - prompt.push(encode(x))}); - prompt={t:108,v:prompt}; } else { prompt = nil() }; - var payload = 'payload' in d && d.payload ? bin(d.payload) : nil(); - var timeout = 'timeout' in d && d.timeout ? encode(d.timeout) : nil(); - var timeDate = 'timeDate' in d && d.timeDate ? bin(d.timeDate) : nil(); - var timeDuration = 'timeDuration' in d && d.timeDuration ? bin(d.timeDuration) : nil(); - var timeCycle = 'timeCycle' in d && d.timeCycle ? bin(d.timeCycle) : nil(); - return tuple(tup,name,module,prompt,payload,timeout,timeDate,timeDuration,timeCycle); } - -function lentimeoutEvent() { return 9; } -function dectimeoutEvent(d) { - var r={}; r.tup = 'timeoutEvent'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.prompt = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : - r.prompt = undefined; - r.payload = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.timeout = d && d.v[5] ? decode(d.v[5]) : undefined; - r.timeDate = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; - r.timeDuration = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; - r.timeCycle = d && d.v[8] ? utf8_arr(d.v[8].v) : undefined; - return clean(r); } - -function encbeginEvent(d) { - var tup = atom('beginEvent'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var prompt = []; if ('prompt' in d && d.prompt) - { d.prompt.forEach(function(x){ - prompt.push(encode(x))}); - prompt={t:108,v:prompt}; } else { prompt = nil() }; - return tuple(tup,name,module,prompt); } - -function lenbeginEvent() { return 4; } -function decbeginEvent(d) { - var r={}; r.tup = 'beginEvent'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.prompt = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : - r.prompt = undefined; - return clean(r); } - -function encendEvent(d) { - var tup = atom('endEvent'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var prompt = []; if ('prompt' in d && d.prompt) - { d.prompt.forEach(function(x){ - prompt.push(encode(x))}); - prompt={t:108,v:prompt}; } else { prompt = nil() }; - return tuple(tup,name,module,prompt); } - -function lenendEvent() { return 4; } -function decendEvent(d) { - var r={}; r.tup = 'endEvent'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.prompt = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.prompt.push(decode(x))}) : - r.prompt = undefined; - return clean(r); } - -function encsequenceFlow(d) { - var tup = atom('sequenceFlow'); - var source = 'source' in d && d.source ? atom(d.source) : nil(); - var target = 'target' in d && d.target ? encode(d.target) : nil(); - return tuple(tup,source,target); } - -function lensequenceFlow() { return 3; } -function decsequenceFlow(d) { - var r={}; r.tup = 'sequenceFlow'; - r.source = d && d.v[1] ? d.v[1].v : undefined; - r.target = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function enchist(d) { - var tup = atom('hist'); - var container = 'container' in d && d.container ? atom(d.container) : nil(); - var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); - var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); - var next = 'next' in d && d.next ? number(d.next) : nil(); - var feeds = []; if ('feeds' in d && d.feeds) - { d.feeds.forEach(function(x){ - feeds.push(encode(x))}); - feeds={t:108,v:feeds}; } else { feeds = nil() }; - var name = 'name' in d && d.name ? bin(d.name) : nil(); - var task = 'task' in d && d.task ? encode(d.task) : nil(); - var docs = []; if ('docs' in d && d.docs) - { d.docs.forEach(function(x){ - docs.push(encode(x))}); - docs={t:108,v:docs}; } else { docs = nil() }; - var time = 'time' in d && d.time ? encode(d.time) : nil(); - return tuple(tup,container,feed_id,prev,next,feeds,name,task,docs,time); } - -function lenhist() { return 10; } -function dechist(d) { - var r={}; r.tup = 'hist'; - r.container = d && d.v[1] ? d.v[1].v : undefined; - r.feed_id = d && d.v[2] ? decode(d.v[2]) : undefined; - r.prev = d && d.v[3] ? d.v[3].v : undefined; - r.next = d && d.v[4] ? d.v[4].v : undefined; - r.feeds = []; - (d && d.v[5] && d.v[5].v) ? - d.v[5].v.forEach(function(x){r.feeds.push(decode(x))}) : - r.feeds = undefined; - r.name = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; - r.task = d && d.v[7] ? decode(d.v[7]) : undefined; - r.docs = []; - (d && d.v[8] && d.v[8].v) ? - d.v[8].v.forEach(function(x){r.docs.push(decode(x))}) : - r.docs = undefined; - r.time = d && d.v[9] ? decode(d.v[9]) : undefined; - return clean(r); } - -function encprocess(d) { - var tup = atom('process'); - var container = 'container' in d && d.container ? atom(d.container) : nil(); - var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); - var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); - var next = 'next' in d && d.next ? number(d.next) : nil(); - var name = 'name' in d && d.name ? encode(d.name) : nil(); - var feeds = []; if ('feeds' in d && d.feeds) - { d.feeds.forEach(function(x){ - feeds.push(encode(x))}); - feeds={t:108,v:feeds}; } else { feeds = nil() }; - var roles = []; if ('roles' in d && d.roles) - { d.roles.forEach(function(x){ - roles.push(encode(x))}); - roles={t:108,v:roles}; } else { roles = nil() }; - var tasks = []; if ('tasks' in d && d.tasks) - { d.tasks.forEach(function(x){ - tasks.push(encode(x))}); - tasks={t:108,v:tasks}; } else { tasks = nil() }; - var events = []; if ('events' in d && d.events) - { d.events.forEach(function(x){ - events.push(encode(x))}); - events={t:108,v:events}; } else { events = nil() }; - var hist = 'hist' in d && d.hist ? encode(d.hist) : nil(); - var flows = []; if ('flows' in d && d.flows) - { d.flows.forEach(function(x){ - flows.push(encode(x))}); - flows={t:108,v:flows}; } else { flows = nil() }; - var rules = 'rules' in d && d.rules ? encode(d.rules) : nil(); - var docs = []; if ('docs' in d && d.docs) - { d.docs.forEach(function(x){ - docs.push(encode(x))}); - docs={t:108,v:docs}; } else { docs = nil() }; - var options = 'options' in d && d.options ? encode(d.options) : nil(); - var task = 'task' in d && d.task ? atom(d.task) : nil(); - var timer = 'timer' in d && d.timer ? encode(d.timer) : nil(); - var notifications = 'notifications' in d && d.notifications ? encode(d.notifications) : nil(); - var result = 'result' in d && d.result ? bin(d.result) : nil(); - var started = 'started' in d && d.started ? encode(d.started) : nil(); - var beginEvent = 'beginEvent' in d && d.beginEvent ? atom(d.beginEvent) : nil(); - var endEvent = 'endEvent' in d && d.endEvent ? atom(d.endEvent) : nil(); - return tuple(tup,container,feed_id,prev,next,name,feeds,roles,tasks,events,hist, - flows,rules,docs,options,task,timer,notifications,result,started,beginEvent,endEvent); } - -function lenprocess() { return 22; } -function decprocess(d) { - var r={}; r.tup = 'process'; - r.container = d && d.v[1] ? d.v[1].v : undefined; - r.feed_id = d && d.v[2] ? decode(d.v[2]) : undefined; - r.prev = d && d.v[3] ? d.v[3].v : undefined; - r.next = d && d.v[4] ? d.v[4].v : undefined; - r.name = d && d.v[5] ? decode(d.v[5]) : undefined; - r.feeds = []; - (d && d.v[6] && d.v[6].v) ? - d.v[6].v.forEach(function(x){r.feeds.push(decode(x))}) : - r.feeds = undefined; - r.roles = []; - (d && d.v[7] && d.v[7].v) ? - d.v[7].v.forEach(function(x){r.roles.push(decode(x))}) : - r.roles = undefined; - r.tasks = []; - (d && d.v[8] && d.v[8].v) ? - d.v[8].v.forEach(function(x){r.tasks.push(decode(x))}) : - r.tasks = undefined; - r.events = []; - (d && d.v[9] && d.v[9].v) ? - d.v[9].v.forEach(function(x){r.events.push(decode(x))}) : - r.events = undefined; - r.hist = d && d.v[10] ? decode(d.v[10]) : undefined; - r.flows = []; - (d && d.v[11] && d.v[11].v) ? - d.v[11].v.forEach(function(x){r.flows.push(decode(x))}) : - r.flows = undefined; - r.rules = d && d.v[12] ? decode(d.v[12]) : undefined; - r.docs = []; - (d && d.v[13] && d.v[13].v) ? - d.v[13].v.forEach(function(x){r.docs.push(decode(x))}) : - r.docs = undefined; - r.options = d && d.v[14] ? decode(d.v[14]) : undefined; - r.task = d && d.v[15] ? d.v[15].v : undefined; - r.timer = d && d.v[16] ? decode(d.v[16]) : undefined; - r.notifications = d && d.v[17] ? decode(d.v[17]) : undefined; - r.result = d && d.v[18] ? utf8_arr(d.v[18].v) : undefined; - r.started = d && d.v[19] ? decode(d.v[19]) : undefined; - r.beginEvent = d && d.v[20] ? d.v[20].v : undefined; - r.endEvent = d && d.v[21] ? d.v[21].v : undefined; - return clean(r); } - -function encComp(d) { - var tup = atom('Comp'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - return tuple(tup,id); } - -function lenComp() { return 2; } -function decComp(d) { - var r={}; r.tup = 'Comp'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - return clean(r); } - -function encProc(d) { - var tup = atom('Proc'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - return tuple(tup,id); } - -function lenProc() { return 2; } -function decProc(d) { - var r={}; r.tup = 'Proc'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - return clean(r); } - -function encLoad(d) { - var tup = atom('Load'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - return tuple(tup,id); } - -function lenLoad() { return 2; } -function decLoad(d) { - var r={}; r.tup = 'Load'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - return clean(r); } - -function encHist(d) { - var tup = atom('Hist'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - return tuple(tup,id); } - -function lenHist() { return 2; } -function decHist(d) { - var r={}; r.tup = 'Hist'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - return clean(r); } - -function encMake(d) { - var tup = atom('Make'); - var proc = 'proc' in d && d.proc ? encode(d.proc) : nil(); - var docs = []; if ('docs' in d && d.docs) - { d.docs.forEach(function(x){ - docs.push(encode(x))}); - docs={t:108,v:docs}; } else { docs = nil() }; - return tuple(tup,proc,docs); } - -function lenMake() { return 3; } -function decMake(d) { - var r={}; r.tup = 'Make'; - r.proc = d && d.v[1] ? decode(d.v[1]) : undefined; - r.docs = []; - (d && d.v[2] && d.v[2].v) ? - d.v[2].v.forEach(function(x){r.docs.push(decode(x))}) : - r.docs = undefined; - return clean(r); } - -function encAmen(d) { - var tup = atom('Amen'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var docs = []; if ('docs' in d && d.docs) - { d.docs.forEach(function(x){ - docs.push(encode(x))}); - docs={t:108,v:docs}; } else { docs = nil() }; - return tuple(tup,id,docs); } - -function lenAmen() { return 3; } -function decAmen(d) { - var r={}; r.tup = 'Amen'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.docs = []; - (d && d.v[2] && d.v[2].v) ? - d.v[2].v.forEach(function(x){r.docs.push(decode(x))}) : - r.docs = undefined; - return clean(r); } - -function encchain(d) { - var tup = atom('chain'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var top = 'top' in d && d.top ? number(d.top) : nil(); - var rear = 'rear' in d && d.rear ? number(d.rear) : nil(); - var count = 'count' in d && d.count ? number(d.count) : nil(); - var aclver = 'aclver' in d && d.aclver ? encode(d.aclver) : nil(); - var unread = 'unread' in d && d.unread ? encode(d.unread) : nil(); - return tuple(tup,id,top,rear,count,aclver,unread); } - -function lenchain() { return 7; } -function decchain(d) { - var r={}; r.tup = 'chain'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.top = d && d.v[2] ? d.v[2].v : undefined; - r.rear = d && d.v[3] ? d.v[3].v : undefined; - r.count = d && d.v[4] ? d.v[4].v : undefined; - r.aclver = d && d.v[5] ? decode(d.v[5]) : undefined; - r.unread = d && d.v[6] ? decode(d.v[6]) : undefined; - return clean(r); } - -function encpush(d) { - var tup = atom('push'); - var model = 'model' in d && d.model ? encode(d.model) : nil(); - var type = 'type' in d && d.type ? bin(d.type) : nil(); - var title = 'title' in d && d.title ? bin(d.title) : nil(); - var alert = 'alert' in d && d.alert ? bin(d.alert) : nil(); - var badge = 'badge' in d && d.badge ? number(d.badge) : nil(); - var sound = 'sound' in d && d.sound ? bin(d.sound) : nil(); - return tuple(tup,model,type,title,alert,badge,sound); } - -function lenpush() { return 7; } -function decpush(d) { - var r={}; r.tup = 'push'; - r.model = d && d.v[1] ? decode(d.v[1]) : undefined; - r.type = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.title = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; - r.alert = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.badge = d && d.v[5] ? d.v[5].v : undefined; - r.sound = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; - return clean(r); } - -function encSearch(d) { - var tup = atom('Search'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var ref = 'ref' in d && d.ref ? bin(d.ref) : nil(); - var field = 'field' in d && d.field ? bin(d.field) : nil(); - var type = 'type' in d && d.type ? atom(d.type) : nil(); - var value = []; if ('value' in d && d.value) - { d.value.forEach(function(x){ - value.push(encode(x))}); - value={t:108,v:value}; } else { value = nil() }; - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,id,ref,field,type,value,status); } - -function lenSearch() { return 7; } -function decSearch(d) { - var r={}; r.tup = 'Search'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.ref = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.field = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; - r.type = d && d.v[4] ? decode(d.v[4]) : undefined; - r.value = []; - (d && d.v[5] && d.v[5].v) ? - d.v[5].v.forEach(function(x){r.value.push(decode(x))}) : - r.value = undefined; - r.status = d && d.v[6] ? decode(d.v[6]) : undefined; - return clean(r); } - -function encp2p(d) { - var tup = atom('p2p'); - var from = 'from' in d && d.from ? bin(d.from) : nil(); - var to = 'to' in d && d.to ? bin(d.to) : nil(); - return tuple(tup,from,to); } - -function lenp2p() { return 3; } -function decp2p(d) { - var r={}; r.tup = 'p2p'; - r.from = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.to = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - return clean(r); } - -function encmuc(d) { - var tup = atom('muc'); - var name = 'name' in d && d.name ? bin(d.name) : nil(); - return tuple(tup,name); } - -function lenmuc() { return 2; } -function decmuc(d) { - var r={}; r.tup = 'muc'; - r.name = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - return clean(r); } - -function encmqi(d) { - var tup = atom('mqi'); - var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); - var query = 'query' in d && d.query ? bin(d.query) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,feed_id,query,status); } - -function lenmqi() { return 4; } -function decmqi(d) { - var r={}; r.tup = 'mqi'; - r.feed_id = d && d.v[1] ? decode(d.v[1]) : undefined; - r.query = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.status = d && d.v[3] ? decode(d.v[3]) : undefined; - return clean(r); } - -function encFeature(d) { - var tup = atom('Feature'); - var id = 'id' in d && d.id ? bin(d.id) : nil(); - var key = 'key' in d && d.key ? bin(d.key) : nil(); - var value = 'value' in d && d.value ? bin(d.value) : nil(); - var group = 'group' in d && d.group ? bin(d.group) : nil(); - return tuple(tup,id,key,value,group); } - -function lenFeature() { return 5; } -function decFeature(d) { - var r={}; r.tup = 'Feature'; - r.id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.key = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.value = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; - r.group = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - return clean(r); } - -function encService(d) { - var tup = atom('Service'); - var id = 'id' in d && d.id ? bin(d.id) : nil(); - var type = 'type' in d && d.type ? atom(d.type) : nil(); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - var login = 'login' in d && d.login ? bin(d.login) : nil(); - var password = 'password' in d && d.password ? bin(d.password) : nil(); - var expiration = 'expiration' in d && d.expiration ? number(d.expiration) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,id,type,data,login,password,expiration,status); } - -function lenService() { return 8; } -function decService(d) { - var r={}; r.tup = 'Service'; - r.id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.type = d && d.v[2] ? decode(d.v[2]) : undefined; - r.data = d && d.v[3] ? decode(d.v[3]) : undefined; - r.login = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.password = d && d.v[5] ? utf8_arr(d.v[5].v) : undefined; - r.expiration = d && d.v[6] ? d.v[6].v : undefined; - r.status = d && d.v[7] ? decode(d.v[7]) : undefined; - return clean(r); } - -function encMember(d) { - var tup = atom('Member'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var container = 'container' in d && d.container ? atom(d.container) : nil(); - var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); - var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); - var next = 'next' in d && d.next ? number(d.next) : nil(); - var feeds = []; if ('feeds' in d && d.feeds) - { d.feeds.forEach(function(x){ - feeds.push(encode(x))}); - feeds={t:108,v:feeds}; } else { feeds = nil() }; - var phone_id = 'phone_id' in d && d.phone_id ? bin(d.phone_id) : nil(); - var avatar = 'avatar' in d && d.avatar ? bin(d.avatar) : nil(); - var names = 'names' in d && d.names ? bin(d.names) : nil(); - var surnames = 'surnames' in d && d.surnames ? bin(d.surnames) : nil(); - var alias = 'alias' in d && d.alias ? bin(d.alias) : nil(); - var reader = 'reader' in d && d.reader ? encode(d.reader) : nil(); - var update = 'update' in d && d.update ? number(d.update) : nil(); - var settings = []; if ('settings' in d && d.settings) - { d.settings.forEach(function(x){ - settings.push(encode(x))}); - settings={t:108,v:settings}; } else { settings = nil() }; - var services = []; if ('services' in d && d.services) - { d.services.forEach(function(x){ - services.push(encode(x))}); - services={t:108,v:services}; } else { services = nil() }; - var presence = 'presence' in d && d.presence ? atom(d.presence) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,id,container,feed_id,prev,next,feeds,phone_id,avatar,names,surnames, - alias,reader,update,settings,services,presence,status); } - -function lenMember() { return 18; } -function decMember(d) { - var r={}; r.tup = 'Member'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.container = d && d.v[2] ? decode(d.v[2]) : undefined; - r.feed_id = d && d.v[3] ? decode(d.v[3]) : undefined; - r.prev = d && d.v[4] ? d.v[4].v : undefined; - r.next = d && d.v[5] ? d.v[5].v : undefined; - r.feeds = []; - (d && d.v[6] && d.v[6].v) ? - d.v[6].v.forEach(function(x){r.feeds.push(decode(x))}) : - r.feeds = undefined; - r.phone_id = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; - r.avatar = d && d.v[8] ? utf8_arr(d.v[8].v) : undefined; - r.names = d && d.v[9] ? utf8_arr(d.v[9].v) : undefined; - r.surnames = d && d.v[10] ? utf8_arr(d.v[10].v) : undefined; - r.alias = d && d.v[11] ? utf8_arr(d.v[11].v) : undefined; - r.reader = d && d.v[12] ? decode(d.v[12]) : undefined; - r.update = d && d.v[13] ? d.v[13].v : undefined; - r.settings = []; - (d && d.v[14] && d.v[14].v) ? - d.v[14].v.forEach(function(x){r.settings.push(decode(x))}) : - r.settings = undefined; - r.services = []; - (d && d.v[15] && d.v[15].v) ? - d.v[15].v.forEach(function(x){r.services.push(decode(x))}) : - r.services = undefined; - r.presence = d && d.v[16] ? decode(d.v[16]) : undefined; - r.status = d && d.v[17] ? decode(d.v[17]) : undefined; - return clean(r); } - -function encDesc(d) { - var tup = atom('Desc'); - var id = 'id' in d && d.id ? bin(d.id) : nil(); - var mime = 'mime' in d && d.mime ? bin(d.mime) : nil(); - var payload = 'payload' in d && d.payload ? bin(d.payload) : nil(); - var parentid = 'parentid' in d && d.parentid ? bin(d.parentid) : nil(); - var data = []; if ('data' in d && d.data) - { d.data.forEach(function(x){ - data.push(encode(x))}); - data={t:108,v:data}; } else { data = nil() }; - return tuple(tup,id,mime,payload,parentid,data); } - -function lenDesc() { return 6; } -function decDesc(d) { - var r={}; r.tup = 'Desc'; - r.id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.mime = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.payload = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; - r.parentid = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.data = []; - (d && d.v[5] && d.v[5].v) ? - d.v[5].v.forEach(function(x){r.data.push(decode(x))}) : - r.data = undefined; - return clean(r); } - -function encStickerPack(d) { - var tup = atom('StickerPack'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var name = 'name' in d && d.name ? bin(d.name) : nil(); - var keywords = []; if ('keywords' in d && d.keywords) - { d.keywords.forEach(function(x){ - keywords.push(encode(x))}); - keywords={t:108,v:keywords}; } else { keywords = nil() }; - var description = 'description' in d && d.description ? bin(d.description) : nil(); - var author = 'author' in d && d.author ? bin(d.author) : nil(); - var stickers = []; if ('stickers' in d && d.stickers) - { d.stickers.forEach(function(x){ - stickers.push(encode(x))}); - stickers={t:108,v:stickers}; } else { stickers = nil() }; - var created = 'created' in d && d.created ? number(d.created) : nil(); - var updated = 'updated' in d && d.updated ? number(d.updated) : nil(); - var downloaded = 'downloaded' in d && d.downloaded ? number(d.downloaded) : nil(); - return tuple(tup,id,name,keywords,description,author,stickers,created,updated,downloaded); } - -function lenStickerPack() { return 10; } -function decStickerPack(d) { - var r={}; r.tup = 'StickerPack'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.name = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.keywords = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.keywords.push(decode(x))}) : - r.keywords = undefined; - r.description = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.author = d && d.v[5] ? utf8_arr(d.v[5].v) : undefined; - r.stickers = []; - (d && d.v[6] && d.v[6].v) ? - d.v[6].v.forEach(function(x){r.stickers.push(decode(x))}) : - r.stickers = undefined; - r.created = d && d.v[7] ? d.v[7].v : undefined; - r.updated = d && d.v[8] ? d.v[8].v : undefined; - r.downloaded = d && d.v[9] ? d.v[9].v : undefined; - return clean(r); } - -function encMessage(d) { - var tup = atom('Message'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var container = 'container' in d && d.container ? atom(d.container) : nil(); - var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); - var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); - var next = 'next' in d && d.next ? number(d.next) : nil(); - var msg_id = 'msg_id' in d && d.msg_id ? bin(d.msg_id) : nil(); - var from = 'from' in d && d.from ? bin(d.from) : nil(); - var to = 'to' in d && d.to ? bin(d.to) : nil(); - var created = 'created' in d && d.created ? number(d.created) : nil(); - var files = []; if ('files' in d && d.files) - { d.files.forEach(function(x){ - files.push(encode(x))}); - files={t:108,v:files}; } else { files = nil() }; - var type = []; if ('type' in d && d.type) - { d.type.forEach(function(x){ - type.push(atom(x))}); - type={t:108,v:type}; } else { type = nil() }; - var link = 'link' in d && d.link ? encode(d.link) : nil(); - var seenby = []; if ('seenby' in d && d.seenby) - { d.seenby.forEach(function(x){ - seenby.push(encode(x))}); - seenby={t:108,v:seenby}; } else { seenby = nil() }; - var repliedby = []; if ('repliedby' in d && d.repliedby) - { d.repliedby.forEach(function(x){ - repliedby.push(encode(x))}); - repliedby={t:108,v:repliedby}; } else { repliedby = nil() }; - var mentioned = []; if ('mentioned' in d && d.mentioned) - { d.mentioned.forEach(function(x){ - mentioned.push(encode(x))}); - mentioned={t:108,v:mentioned}; } else { mentioned = nil() }; - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,id,container,feed_id,prev,next,msg_id,from,to,created,files, - type,link,seenby,repliedby,mentioned,status); } - -function lenMessage() { return 17; } -function decMessage(d) { - var r={}; r.tup = 'Message'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.container = d && d.v[2] ? decode(d.v[2]) : undefined; - r.feed_id = d && d.v[3] ? decode(d.v[3]) : undefined; - r.prev = d && d.v[4] ? d.v[4].v : undefined; - r.next = d && d.v[5] ? d.v[5].v : undefined; - r.msg_id = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; - r.from = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; - r.to = d && d.v[8] ? utf8_arr(d.v[8].v) : undefined; - r.created = d && d.v[9] ? d.v[9].v : undefined; - r.files = []; - (d && d.v[10] && d.v[10].v) ? - d.v[10].v.forEach(function(x){r.files.push(decode(x))}) : - r.files = undefined; - r.type = []; - (d && d.v[11] && d.v[11].v) ? - d.v[11].v.forEach(function(x){r.type.push(decode(x))}) : - r.type = undefined; - r.link = d && d.v[12] ? decode(d.v[12]) : undefined; - r.seenby = []; - (d && d.v[13] && d.v[13].v) ? - d.v[13].v.forEach(function(x){r.seenby.push(decode(x))}) : - r.seenby = undefined; - r.repliedby = []; - (d && d.v[14] && d.v[14].v) ? - d.v[14].v.forEach(function(x){r.repliedby.push(decode(x))}) : - r.repliedby = undefined; - r.mentioned = []; - (d && d.v[15] && d.v[15].v) ? - d.v[15].v.forEach(function(x){r.mentioned.push(decode(x))}) : - r.mentioned = undefined; - r.status = d && d.v[16] ? decode(d.v[16]) : undefined; - return clean(r); } - -function encLink(d) { - var tup = atom('Link'); - var id = 'id' in d && d.id ? bin(d.id) : nil(); - var name = 'name' in d && d.name ? bin(d.name) : nil(); - var room_id = 'room_id' in d && d.room_id ? bin(d.room_id) : nil(); - var created = 'created' in d && d.created ? number(d.created) : nil(); - var type = 'type' in d && d.type ? atom(d.type) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,id,name,room_id,created,type,status); } - -function lenLink() { return 7; } -function decLink(d) { - var r={}; r.tup = 'Link'; - r.id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.name = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.room_id = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; - r.created = d && d.v[4] ? d.v[4].v : undefined; - r.type = d && d.v[5] ? decode(d.v[5]) : undefined; - r.status = d && d.v[6] ? decode(d.v[6]) : undefined; - return clean(r); } - -function encRoom(d) { - var tup = atom('Room'); - var id = 'id' in d && d.id ? bin(d.id) : nil(); - var name = 'name' in d && d.name ? bin(d.name) : nil(); - var links = []; if ('links' in d && d.links) - { d.links.forEach(function(x){ - links.push(encode(x))}); - links={t:108,v:links}; } else { links = nil() }; - var description = 'description' in d && d.description ? bin(d.description) : nil(); - var settings = []; if ('settings' in d && d.settings) - { d.settings.forEach(function(x){ - settings.push(encode(x))}); - settings={t:108,v:settings}; } else { settings = nil() }; - var members = []; if ('members' in d && d.members) - { d.members.forEach(function(x){ - members.push(encode(x))}); - members={t:108,v:members}; } else { members = nil() }; - var admins = []; if ('admins' in d && d.admins) - { d.admins.forEach(function(x){ - admins.push(encode(x))}); - admins={t:108,v:admins}; } else { admins = nil() }; - var data = []; if ('data' in d && d.data) - { d.data.forEach(function(x){ - data.push(encode(x))}); - data={t:108,v:data}; } else { data = nil() }; - var type = 'type' in d && d.type ? atom(d.type) : nil(); - var tos = 'tos' in d && d.tos ? bin(d.tos) : nil(); - var tos_update = 'tos_update' in d && d.tos_update ? number(d.tos_update) : nil(); - var unread = 'unread' in d && d.unread ? number(d.unread) : nil(); - var mentions = []; if ('mentions' in d && d.mentions) - { d.mentions.forEach(function(x){ - mentions.push(encode(x))}); - mentions={t:108,v:mentions}; } else { mentions = nil() }; - var readers = []; if ('readers' in d && d.readers) - { d.readers.forEach(function(x){ - readers.push(encode(x))}); - readers={t:108,v:readers}; } else { readers = nil() }; - var last_msg = 'last_msg' in d && d.last_msg ? encode(d.last_msg) : nil(); - var update = 'update' in d && d.update ? number(d.update) : nil(); - var created = 'created' in d && d.created ? number(d.created) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,id,name,links,description,settings,members,admins,data,type,tos, - tos_update,unread,mentions,readers,last_msg,update,created,status); } - -function lenRoom() { return 19; } -function decRoom(d) { - var r={}; r.tup = 'Room'; - r.id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.name = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.links = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.links.push(decode(x))}) : - r.links = undefined; - r.description = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.settings = []; - (d && d.v[5] && d.v[5].v) ? - d.v[5].v.forEach(function(x){r.settings.push(decode(x))}) : - r.settings = undefined; - r.members = []; - (d && d.v[6] && d.v[6].v) ? - d.v[6].v.forEach(function(x){r.members.push(decode(x))}) : - r.members = undefined; - r.admins = []; - (d && d.v[7] && d.v[7].v) ? - d.v[7].v.forEach(function(x){r.admins.push(decode(x))}) : - r.admins = undefined; - r.data = []; - (d && d.v[8] && d.v[8].v) ? - d.v[8].v.forEach(function(x){r.data.push(decode(x))}) : - r.data = undefined; - r.type = d && d.v[9] ? decode(d.v[9]) : undefined; - r.tos = d && d.v[10] ? utf8_arr(d.v[10].v) : undefined; - r.tos_update = d && d.v[11] ? d.v[11].v : undefined; - r.unread = d && d.v[12] ? d.v[12].v : undefined; - r.mentions = []; - (d && d.v[13] && d.v[13].v) ? - d.v[13].v.forEach(function(x){r.mentions.push(decode(x))}) : - r.mentions = undefined; - r.readers = []; - (d && d.v[14] && d.v[14].v) ? - d.v[14].v.forEach(function(x){r.readers.push(decode(x))}) : - r.readers = undefined; - r.last_msg = d && d.v[15] ? decode(d.v[15]) : undefined; - r.update = d && d.v[16] ? d.v[16].v : undefined; - r.created = d && d.v[17] ? d.v[17].v : undefined; - r.status = d && d.v[18] ? decode(d.v[18]) : undefined; - return clean(r); } - -function encTag(d) { - var tup = atom('Tag'); - var roster_id = 'roster_id' in d && d.roster_id ? bin(d.roster_id) : nil(); - var name = 'name' in d && d.name ? bin(d.name) : nil(); - var color = 'color' in d && d.color ? bin(d.color) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,roster_id,name,color,status); } - -function lenTag() { return 5; } -function decTag(d) { - var r={}; r.tup = 'Tag'; - r.roster_id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.name = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.color = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; - r.status = d && d.v[4] ? decode(d.v[4]) : undefined; - return clean(r); } - -function encStar(d) { - var tup = atom('Star'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var client_id = 'client_id' in d && d.client_id ? bin(d.client_id) : nil(); - var roster_id = 'roster_id' in d && d.roster_id ? number(d.roster_id) : nil(); - var message = 'message' in d && d.message ? encode(d.message) : nil(); - var tags = []; if ('tags' in d && d.tags) - { d.tags.forEach(function(x){ - tags.push(encode(x))}); - tags={t:108,v:tags}; } else { tags = nil() }; - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,id,client_id,roster_id,message,tags,status); } - -function lenStar() { return 7; } -function decStar(d) { - var r={}; r.tup = 'Star'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.client_id = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.roster_id = d && d.v[3] ? d.v[3].v : undefined; - r.message = d && d.v[4] ? decode(d.v[4]) : undefined; - r.tags = []; - (d && d.v[5] && d.v[5].v) ? - d.v[5].v.forEach(function(x){r.tags.push(decode(x))}) : - r.tags = undefined; - r.status = d && d.v[6] ? decode(d.v[6]) : undefined; - return clean(r); } - -function encTyping(d) { - var tup = atom('Typing'); - var phone_id = 'phone_id' in d && d.phone_id ? bin(d.phone_id) : nil(); - var comments = 'comments' in d && d.comments ? encode(d.comments) : nil(); - return tuple(tup,phone_id,comments); } - -function lenTyping() { return 3; } -function decTyping(d) { - var r={}; r.tup = 'Typing'; - r.phone_id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.comments = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function encContact(d) { - var tup = atom('Contact'); - var phone_id = 'phone_id' in d && d.phone_id ? bin(d.phone_id) : nil(); - var avatar = 'avatar' in d && d.avatar ? bin(d.avatar) : nil(); - var names = 'names' in d && d.names ? bin(d.names) : nil(); - var surnames = 'surnames' in d && d.surnames ? bin(d.surnames) : nil(); - var nick = 'nick' in d && d.nick ? bin(d.nick) : nil(); - var reader = 'reader' in d && d.reader ? encode(d.reader) : nil(); - var unread = 'unread' in d && d.unread ? number(d.unread) : nil(); - var last_msg = 'last_msg' in d && d.last_msg ? encode(d.last_msg) : nil(); - var update = 'update' in d && d.update ? number(d.update) : nil(); - var created = 'created' in d && d.created ? number(d.created) : nil(); - var settings = []; if ('settings' in d && d.settings) - { d.settings.forEach(function(x){ - settings.push(encode(x))}); - settings={t:108,v:settings}; } else { settings = nil() }; - var services = []; if ('services' in d && d.services) - { d.services.forEach(function(x){ - services.push(encode(x))}); - services={t:108,v:services}; } else { services = nil() }; - var presence = 'presence' in d && d.presence ? atom(d.presence) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,phone_id,avatar,names,surnames,nick,reader,unread,last_msg,update,created, - settings,services,presence,status); } - -function lenContact() { return 15; } -function decContact(d) { - var r={}; r.tup = 'Contact'; - r.phone_id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.avatar = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.names = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; - r.surnames = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.nick = d && d.v[5] ? utf8_arr(d.v[5].v) : undefined; - r.reader = d && d.v[6] ? decode(d.v[6]) : undefined; - r.unread = d && d.v[7] ? d.v[7].v : undefined; - r.last_msg = d && d.v[8] ? decode(d.v[8]) : undefined; - r.update = d && d.v[9] ? d.v[9].v : undefined; - r.created = d && d.v[10] ? d.v[10].v : undefined; - r.settings = []; - (d && d.v[11] && d.v[11].v) ? - d.v[11].v.forEach(function(x){r.settings.push(decode(x))}) : - r.settings = undefined; - r.services = []; - (d && d.v[12] && d.v[12].v) ? - d.v[12].v.forEach(function(x){r.services.push(decode(x))}) : - r.services = undefined; - r.presence = d && d.v[13] ? decode(d.v[13]) : undefined; - r.status = d && d.v[14] ? decode(d.v[14]) : undefined; - return clean(r); } - -function encExtendedStar(d) { - var tup = atom('ExtendedStar'); - var star = 'star' in d && d.star ? encode(d.star) : nil(); - var from = 'from' in d && d.from ? encode(d.from) : nil(); - return tuple(tup,star,from); } - -function lenExtendedStar() { return 3; } -function decExtendedStar(d) { - var r={}; r.tup = 'ExtendedStar'; - r.star = d && d.v[1] ? decode(d.v[1]) : undefined; - r.from = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function encAuth(d) { - var tup = atom('Auth'); - var client_id = 'client_id' in d && d.client_id ? bin(d.client_id) : nil(); - var dev_key = 'dev_key' in d && d.dev_key ? bin(d.dev_key) : nil(); - var user_id = 'user_id' in d && d.user_id ? bin(d.user_id) : nil(); - var phone = 'phone' in d && d.phone ? encode(d.phone) : nil(); - var token = 'token' in d && d.token ? bin(d.token) : nil(); - var type = 'type' in d && d.type ? atom(d.type) : nil(); - var sms_code = 'sms_code' in d && d.sms_code ? bin(d.sms_code) : nil(); - var attempts = 'attempts' in d && d.attempts ? number(d.attempts) : nil(); - var services = []; if ('services' in d && d.services) - { d.services.forEach(function(x){ - services.push(encode(x))}); - services={t:108,v:services}; } else { services = nil() }; - var settings = []; if ('settings' in d && d.settings) - { d.settings.forEach(function(x){ - settings.push(encode(x))}); - settings={t:108,v:settings}; } else { settings = nil() }; - var push = 'push' in d && d.push ? bin(d.push) : nil(); - var os = 'os' in d && d.os ? atom(d.os) : nil(); - var created = 'created' in d && d.created ? number(d.created) : nil(); - var last_online = 'last_online' in d && d.last_online ? number(d.last_online) : nil(); - return tuple(tup,client_id,dev_key,user_id,phone,token,type,sms_code,attempts,services,settings, - push,os,created,last_online); } - -function lenAuth() { return 15; } -function decAuth(d) { - var r={}; r.tup = 'Auth'; - r.client_id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.dev_key = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.user_id = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; - r.phone = d && d.v[4] ? decode(d.v[4]) : undefined; - r.token = d && d.v[5] ? utf8_arr(d.v[5].v) : undefined; - r.type = d && d.v[6] ? decode(d.v[6]) : undefined; - r.sms_code = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; - r.attempts = d && d.v[8] ? d.v[8].v : undefined; - r.services = []; - (d && d.v[9] && d.v[9].v) ? - d.v[9].v.forEach(function(x){r.services.push(decode(x))}) : - r.services = undefined; - r.settings = []; - (d && d.v[10] && d.v[10].v) ? - d.v[10].v.forEach(function(x){r.settings.push(decode(x))}) : - r.settings = undefined; - r.push = d && d.v[11] ? utf8_arr(d.v[11].v) : undefined; - r.os = d && d.v[12] ? decode(d.v[12]) : undefined; - r.created = d && d.v[13] ? d.v[13].v : undefined; - r.last_online = d && d.v[14] ? d.v[14].v : undefined; - return clean(r); } - -function encRoster(d) { - var tup = atom('Roster'); - var id = 'id' in d && d.id ? encode(d.id) : nil(); - var names = 'names' in d && d.names ? bin(d.names) : nil(); - var surnames = 'surnames' in d && d.surnames ? bin(d.surnames) : nil(); - var email = 'email' in d && d.email ? bin(d.email) : nil(); - var nick = 'nick' in d && d.nick ? bin(d.nick) : nil(); - var userlist = []; if ('userlist' in d && d.userlist) - { d.userlist.forEach(function(x){ - userlist.push(encode(x))}); - userlist={t:108,v:userlist}; } else { userlist = nil() }; - var roomlist = []; if ('roomlist' in d && d.roomlist) - { d.roomlist.forEach(function(x){ - roomlist.push(encode(x))}); - roomlist={t:108,v:roomlist}; } else { roomlist = nil() }; - var favorite = []; if ('favorite' in d && d.favorite) - { d.favorite.forEach(function(x){ - favorite.push(encode(x))}); - favorite={t:108,v:favorite}; } else { favorite = nil() }; - var tags = []; if ('tags' in d && d.tags) - { d.tags.forEach(function(x){ - tags.push(encode(x))}); - tags={t:108,v:tags}; } else { tags = nil() }; - var phone = 'phone' in d && d.phone ? bin(d.phone) : nil(); - var avatar = 'avatar' in d && d.avatar ? bin(d.avatar) : nil(); - var update = 'update' in d && d.update ? number(d.update) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,id,names,surnames,email,nick,userlist,roomlist,favorite,tags,phone, - avatar,update,status); } - -function lenRoster() { return 14; } -function decRoster(d) { - var r={}; r.tup = 'Roster'; - r.id = d && d.v[1] ? decode(d.v[1]) : undefined; - r.names = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.surnames = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; - r.email = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.nick = d && d.v[5] ? utf8_arr(d.v[5].v) : undefined; - r.userlist = []; - (d && d.v[6] && d.v[6].v) ? - d.v[6].v.forEach(function(x){r.userlist.push(decode(x))}) : - r.userlist = undefined; - r.roomlist = []; - (d && d.v[7] && d.v[7].v) ? - d.v[7].v.forEach(function(x){r.roomlist.push(decode(x))}) : - r.roomlist = undefined; - r.favorite = []; - (d && d.v[8] && d.v[8].v) ? - d.v[8].v.forEach(function(x){r.favorite.push(decode(x))}) : - r.favorite = undefined; - r.tags = []; - (d && d.v[9] && d.v[9].v) ? - d.v[9].v.forEach(function(x){r.tags.push(decode(x))}) : - r.tags = undefined; - r.phone = d && d.v[10] ? utf8_arr(d.v[10].v) : undefined; - r.avatar = d && d.v[11] ? utf8_arr(d.v[11].v) : undefined; - r.update = d && d.v[12] ? d.v[12].v : undefined; - r.status = d && d.v[13] ? decode(d.v[13]) : undefined; - return clean(r); } - -function encProfile(d) { - var tup = atom('Profile'); - var phone = 'phone' in d && d.phone ? bin(d.phone) : nil(); - var services = []; if ('services' in d && d.services) - { d.services.forEach(function(x){ - services.push(encode(x))}); - services={t:108,v:services}; } else { services = nil() }; - var rosters = []; if ('rosters' in d && d.rosters) - { d.rosters.forEach(function(x){ - rosters.push(encode(x))}); - rosters={t:108,v:rosters}; } else { rosters = nil() }; - var settings = []; if ('settings' in d && d.settings) - { d.settings.forEach(function(x){ - settings.push(encode(x))}); - settings={t:108,v:settings}; } else { settings = nil() }; - var update = 'update' in d && d.update ? number(d.update) : nil(); - var balance = 'balance' in d && d.balance ? number(d.balance) : nil(); - var presence = 'presence' in d && d.presence ? atom(d.presence) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,phone,services,rosters,settings,update,balance,presence,status); } - -function lenProfile() { return 9; } -function decProfile(d) { - var r={}; r.tup = 'Profile'; - r.phone = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.services = []; - (d && d.v[2] && d.v[2].v) ? - d.v[2].v.forEach(function(x){r.services.push(decode(x))}) : - r.services = undefined; - r.rosters = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.rosters.push(decode(x))}) : - r.rosters = undefined; - r.settings = []; - (d && d.v[4] && d.v[4].v) ? - d.v[4].v.forEach(function(x){r.settings.push(decode(x))}) : - r.settings = undefined; - r.update = d && d.v[5] ? d.v[5].v : undefined; - r.balance = d && d.v[6] ? d.v[6].v : undefined; - r.presence = d && d.v[7] ? decode(d.v[7]) : undefined; - r.status = d && d.v[8] ? decode(d.v[8]) : undefined; - return clean(r); } - -function encPresence(d) { - var tup = atom('Presence'); - var uid = 'uid' in d && d.uid ? bin(d.uid) : nil(); - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,uid,status); } - -function lenPresence() { return 3; } -function decPresence(d) { - var r={}; r.tup = 'Presence'; - r.uid = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.status = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function encFriend(d) { - var tup = atom('Friend'); - var phone_id = 'phone_id' in d && d.phone_id ? bin(d.phone_id) : nil(); - var friend_id = 'friend_id' in d && d.friend_id ? bin(d.friend_id) : nil(); - var settings = []; if ('settings' in d && d.settings) - { d.settings.forEach(function(x){ - settings.push(encode(x))}); - settings={t:108,v:settings}; } else { settings = nil() }; - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,phone_id,friend_id,settings,status); } - -function lenFriend() { return 5; } -function decFriend(d) { - var r={}; r.tup = 'Friend'; - r.phone_id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.friend_id = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.settings = []; - (d && d.v[3] && d.v[3].v) ? - d.v[3].v.forEach(function(x){r.settings.push(decode(x))}) : - r.settings = undefined; - r.status = d && d.v[4] ? decode(d.v[4]) : undefined; - return clean(r); } - -function encact(d) { - var tup = atom('act'); - var name = 'name' in d && d.name ? bin(d.name) : nil(); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - return tuple(tup,name,data); } - -function lenact() { return 3; } -function decact(d) { - var r={}; r.tup = 'act'; - r.name = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.data = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function encJob(d) { - var tup = atom('Job'); - var id = 'id' in d && d.id ? number(d.id) : nil(); - var container = 'container' in d && d.container ? atom(d.container) : nil(); - var feed_id = 'feed_id' in d && d.feed_id ? encode(d.feed_id) : nil(); - var prev = 'prev' in d && d.prev ? number(d.prev) : nil(); - var next = 'next' in d && d.next ? number(d.next) : nil(); - var context = 'context' in d && d.context ? encode(d.context) : nil(); - var proc = 'proc' in d && d.proc ? encode(d.proc) : nil(); - var time = 'time' in d && d.time ? number(d.time) : nil(); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - var events = []; if ('events' in d && d.events) - { d.events.forEach(function(x){ - events.push(encode(x))}); - events={t:108,v:events}; } else { events = nil() }; - var settings = []; if ('settings' in d && d.settings) - { d.settings.forEach(function(x){ - settings.push(encode(x))}); - settings={t:108,v:settings}; } else { settings = nil() }; - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,id,container,feed_id,prev,next,context,proc,time,data,events, - settings,status); } - -function lenJob() { return 13; } -function decJob(d) { - var r={}; r.tup = 'Job'; - r.id = d && d.v[1] ? d.v[1].v : undefined; - r.container = d && d.v[2] ? decode(d.v[2]) : undefined; - r.feed_id = d && d.v[3] ? decode(d.v[3]) : undefined; - r.prev = d && d.v[4] ? d.v[4].v : undefined; - r.next = d && d.v[5] ? d.v[5].v : undefined; - r.context = d && d.v[6] ? decode(d.v[6]) : undefined; - r.proc = d && d.v[7] ? decode(d.v[7]) : undefined; - r.time = d && d.v[8] ? d.v[8].v : undefined; - r.data = d && d.v[9] ? decode(d.v[9]) : undefined; - r.events = []; - (d && d.v[10] && d.v[10].v) ? - d.v[10].v.forEach(function(x){r.events.push(decode(x))}) : - r.events = undefined; - r.settings = []; - (d && d.v[11] && d.v[11].v) ? - d.v[11].v.forEach(function(x){r.settings.push(decode(x))}) : - r.settings = undefined; - r.status = d && d.v[12] ? decode(d.v[12]) : undefined; - return clean(r); } - -function encHistory(d) { - var tup = atom('History'); - var roster_id = 'roster_id' in d && d.roster_id ? bin(d.roster_id) : nil(); - var feed = 'feed' in d && d.feed ? encode(d.feed) : nil(); - var size = 'size' in d && d.size ? number(d.size) : nil(); - var entity_id = 'entity_id' in d && d.entity_id ? number(d.entity_id) : nil(); - var data = []; if ('data' in d && d.data) - { d.data.forEach(function(x){ - data.push(encode(x))}); - data={t:108,v:data}; } else { data = nil() }; - var status = 'status' in d && d.status ? atom(d.status) : nil(); - return tuple(tup,roster_id,feed,size,entity_id,data,status); } - -function lenHistory() { return 7; } -function decHistory(d) { - var r={}; r.tup = 'History'; - r.roster_id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.feed = d && d.v[2] ? decode(d.v[2]) : undefined; - r.size = d && d.v[3] ? d.v[3].v : undefined; - r.entity_id = d && d.v[4] ? d.v[4].v : undefined; - r.data = []; - (d && d.v[5] && d.v[5].v) ? - d.v[5].v.forEach(function(x){r.data.push(decode(x))}) : - r.data = undefined; - r.status = d && d.v[6] ? decode(d.v[6]) : undefined; - return clean(r); } - -function encSchedule(d) { - var tup = atom('Schedule'); - var id = 'id' in d && d.id ? encode(d.id) : nil(); - var proc = 'proc' in d && d.proc ? encode(d.proc) : nil(); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - var state = 'state' in d && d.state ? encode(d.state) : nil(); - return tuple(tup,id,proc,data,state); } - -function lenSchedule() { return 5; } -function decSchedule(d) { - var r={}; r.tup = 'Schedule'; - r.id = d && d.v[1] ? decode(d.v[1]) : undefined; - r.proc = d && d.v[2] ? decode(d.v[2]) : undefined; - r.data = d && d.v[3] ? decode(d.v[3]) : undefined; - r.state = d && d.v[4] ? decode(d.v[4]) : undefined; - return clean(r); } - -function encIndex(d) { - var tup = atom('Index'); - var id = 'id' in d && d.id ? encode(d.id) : nil(); - var roster = []; if ('roster' in d && d.roster) - { d.roster.forEach(function(x){ - roster.push(encode(x))}); - roster={t:108,v:roster}; } else { roster = nil() }; - return tuple(tup,id,roster); } - -function lenIndex() { return 3; } -function decIndex(d) { - var r={}; r.tup = 'Index'; - r.id = d && d.v[1] ? decode(d.v[1]) : undefined; - r.roster = []; - (d && d.v[2] && d.v[2].v) ? - d.v[2].v.forEach(function(x){r.roster.push(decode(x))}) : - r.roster = undefined; - return clean(r); } - -function encWhitelist(d) { - var tup = atom('Whitelist'); - var phone = 'phone' in d && d.phone ? encode(d.phone) : nil(); - var created = 'created' in d && d.created ? number(d.created) : nil(); - return tuple(tup,phone,created); } - -function lenWhitelist() { return 3; } -function decWhitelist(d) { - var r={}; r.tup = 'Whitelist'; - r.phone = d && d.v[1] ? decode(d.v[1]) : undefined; - r.created = d && d.v[2] ? d.v[2].v : undefined; - return clean(r); } - -function encerror(d) { - var tup = atom('error'); - var code = 'code' in d && d.code ? atom(d.code) : nil(); - return tuple(tup,code); } - -function lenerror() { return 2; } -function decerror(d) { - var r={}; r.tup = 'error'; - r.code = d && d.v[1] ? d.v[1].v : undefined; - return clean(r); } - -function encok(d) { - var tup = atom('ok'); - var code = 'code' in d && d.code ? atom(d.code) : nil(); - return tuple(tup,code); } - -function lenok() { return 2; } -function decok(d) { - var r={}; r.tup = 'ok'; - r.code = d && d.v[1] ? decode(d.v[1]) : undefined; - return clean(r); } - -function encerror2(d) { - var tup = atom('error2'); - var code = 'code' in d && d.code ? atom(d.code) : nil(); - var src = 'src' in d && d.src ? encode(d.src) : nil(); - return tuple(tup,code,src); } - -function lenerror2() { return 3; } -function decerror2(d) { - var r={}; r.tup = 'error2'; - r.code = d && d.v[1] ? d.v[1].v : undefined; - r.src = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function encok2(d) { - var tup = atom('ok2'); - var code = 'code' in d && d.code ? atom(d.code) : nil(); - var src = 'src' in d && d.src ? encode(d.src) : nil(); - return tuple(tup,code,src); } - -function lenok2() { return 3; } -function decok2(d) { - var r={}; r.tup = 'ok2'; - r.code = d && d.v[1] ? d.v[1].v : undefined; - r.src = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function encio(d) { - var tup = atom('io'); - var code = 'code' in d && d.code ? encode(d.code) : nil(); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - return tuple(tup,code,data); } - -function lenio() { return 3; } -function decio(d) { - var r={}; r.tup = 'io'; - r.code = d && d.v[1] ? decode(d.v[1]) : undefined; - r.data = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function encAck(d) { - var tup = atom('Ack'); - var table = 'table' in d && d.table ? atom(d.table) : nil(); - var id = 'id' in d && d.id ? bin(d.id) : nil(); - return tuple(tup,table,id); } - -function lenAck() { return 3; } -function decAck(d) { - var r={}; r.tup = 'Ack'; - r.table = d && d.v[1] ? d.v[1].v : undefined; - r.id = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - return clean(r); } - -function encerrors(d) { - var tup = atom('errors'); - var code = []; if ('code' in d && d.code) - { d.code.forEach(function(x){ - code.push(encode(x))}); - code={t:108,v:code}; } else { code = nil() }; - var data = 'data' in d && d.data ? encode(d.data) : nil(); - return tuple(tup,code,data); } - -function lenerrors() { return 3; } -function decerrors(d) { - var r={}; r.tup = 'errors'; - r.code = []; - (d && d.v[1] && d.v[1].v) ? - d.v[1].v.forEach(function(x){r.code.push(decode(x))}) : - r.code = undefined; - r.data = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function encPushService(d) { - var tup = atom('PushService'); - var recipients = []; if ('recipients' in d && d.recipients) - { d.recipients.forEach(function(x){ - recipients.push(encode(x))}); - recipients={t:108,v:recipients}; } else { recipients = nil() }; - var id = 'id' in d && d.id ? bin(d.id) : nil(); - var ttl = 'ttl' in d && d.ttl ? number(d.ttl) : nil(); - var module = 'module' in d && d.module ? bin(d.module) : nil(); - var priority = 'priority' in d && d.priority ? bin(d.priority) : nil(); - var payload = 'payload' in d && d.payload ? bin(d.payload) : nil(); - return tuple(tup,recipients,id,ttl,module,priority,payload); } - -function lenPushService() { return 7; } -function decPushService(d) { - var r={}; r.tup = 'PushService'; - r.recipients = []; - (d && d.v[1] && d.v[1].v) ? - d.v[1].v.forEach(function(x){r.recipients.push(decode(x))}) : - r.recipients = undefined; - r.id = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.ttl = d && d.v[3] ? d.v[3].v : undefined; - r.module = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; - r.priority = d && d.v[5] ? utf8_arr(d.v[5].v) : undefined; - r.payload = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; - return clean(r); } - -function encPublishService(d) { - var tup = atom('PublishService'); - var message = 'message' in d && d.message ? bin(d.message) : nil(); - var topic = 'topic' in d && d.topic ? bin(d.topic) : nil(); - var qos = 'qos' in d && d.qos ? number(d.qos) : nil(); - return tuple(tup,message,topic,qos); } - -function lenPublishService() { return 4; } -function decPublishService(d) { - var r={}; r.tup = 'PublishService'; - r.message = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.topic = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.qos = d && d.v[3] ? d.v[3].v : undefined; - return clean(r); } - -function encFakeNumbers(d) { - var tup = atom('FakeNumbers'); - var phone = 'phone' in d && d.phone ? encode(d.phone) : nil(); - var created = 'created' in d && d.created ? encode(d.created) : nil(); - return tuple(tup,phone,created); } - -function lenFakeNumbers() { return 3; } -function decFakeNumbers(d) { - var r={}; r.tup = 'FakeNumbers'; - r.phone = d && d.v[1] ? decode(d.v[1]) : undefined; - r.created = d && d.v[2] ? decode(d.v[2]) : undefined; - return clean(r); } - -function enchandler(d) { - var tup = atom('handler'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var class = 'class' in d && d.class ? encode(d.class) : nil(); - var group = 'group' in d && d.group ? atom(d.group) : nil(); - var config = 'config' in d && d.config ? encode(d.config) : nil(); - var state = 'state' in d && d.state ? encode(d.state) : nil(); - var seq = 'seq' in d && d.seq ? encode(d.seq) : nil(); - return tuple(tup,name,module,class,group,config,state,seq); } - -function lenhandler() { return 8; } -function dechandler(d) { - var r={}; r.tup = 'handler'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.module = d && d.v[2] ? d.v[2].v : undefined; - r.class = d && d.v[3] ? decode(d.v[3]) : undefined; - r.group = d && d.v[4] ? d.v[4].v : undefined; - r.config = d && d.v[5] ? decode(d.v[5]) : undefined; - r.state = d && d.v[6] ? decode(d.v[6]) : undefined; - r.seq = d && d.v[7] ? decode(d.v[7]) : undefined; - return clean(r); } - -function encpi(d) { - var tup = atom('pi'); - var name = 'name' in d && d.name ? encode(d.name) : nil(); - var table = 'table' in d && d.table ? atom(d.table) : nil(); - var sup = 'sup' in d && d.sup ? atom(d.sup) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var state = 'state' in d && d.state ? encode(d.state) : nil(); - return tuple(tup,name,table,sup,module,state); } - -function lenpi() { return 6; } -function decpi(d) { - var r={}; r.tup = 'pi'; - r.name = d && d.v[1] ? decode(d.v[1]) : undefined; - r.table = d && d.v[2] ? d.v[2].v : undefined; - r.sup = d && d.v[3] ? d.v[3].v : undefined; - r.module = d && d.v[4] ? d.v[4].v : undefined; - r.state = d && d.v[5] ? decode(d.v[5]) : undefined; - return clean(r); } - -function enccx(d) { - var tup = atom('cx'); - var handlers = []; if ('handlers' in d && d.handlers) - { d.handlers.forEach(function(x){ - handlers.push(encode(x))}); - handlers={t:108,v:handlers}; } else { handlers = nil() }; - var actions = []; if ('actions' in d && d.actions) - { d.actions.forEach(function(x){ - actions.push(encode(x))}); - actions={t:108,v:actions}; } else { actions = nil() }; - var req = 'req' in d && d.req ? encode(d.req) : nil(); - var module = 'module' in d && d.module ? atom(d.module) : nil(); - var lang = 'lang' in d && d.lang ? atom(d.lang) : nil(); - var path = 'path' in d && d.path ? bin(d.path) : nil(); - var session = 'session' in d && d.session ? bin(d.session) : nil(); - var formatter = 'formatter' in d && d.formatter ? atom(d.formatter) : nil(); - var params = []; if ('params' in d && d.params) - { d.params.forEach(function(x){ - params.push(encode(x))}); - params={t:108,v:params}; } else { params = nil() }; - var node = 'node' in d && d.node ? atom(d.node) : nil(); - var client_pid = 'client_pid' in d && d.client_pid ? encode(d.client_pid) : nil(); - var state = 'state' in d && d.state ? encode(d.state) : nil(); - var from = 'from' in d && d.from ? bin(d.from) : nil(); - var vsn = 'vsn' in d && d.vsn ? bin(d.vsn) : nil(); - return tuple(tup,handlers,actions,req,module,lang,path,session,formatter,params,node, - client_pid,state,from,vsn); } - -function lencx() { return 15; } -function deccx(d) { - var r={}; r.tup = 'cx'; - r.handlers = []; - (d && d.v[1] && d.v[1].v) ? - d.v[1].v.forEach(function(x){r.handlers.push(decode(x))}) : - r.handlers = undefined; - r.actions = []; - (d && d.v[2] && d.v[2].v) ? - d.v[2].v.forEach(function(x){r.actions.push(decode(x))}) : - r.actions = undefined; - r.req = d && d.v[3] ? decode(d.v[3]) : undefined; - r.module = d && d.v[4] ? d.v[4].v : undefined; - r.lang = d && d.v[5] ? d.v[5].v : undefined; - r.path = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; - r.session = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; - r.formatter = d && d.v[8] ? decode(d.v[8]) : undefined; - r.params = []; - (d && d.v[9] && d.v[9].v) ? - d.v[9].v.forEach(function(x){r.params.push(decode(x))}) : - r.params = undefined; - r.node = d && d.v[10] ? d.v[10].v : undefined; - r.client_pid = d && d.v[11] ? decode(d.v[11]) : undefined; - r.state = d && d.v[12] ? decode(d.v[12]) : undefined; - r.from = d && d.v[13] ? utf8_arr(d.v[13].v) : undefined; - r.vsn = d && d.v[14] ? utf8_arr(d.v[14].v) : undefined; - return clean(r); } - -function encbin(d) { - var tup = atom('bin'); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - return tuple(tup,data); } - -function lenbin() { return 2; } -function decbin(d) { - var r={}; r.tup = 'bin'; - r.data = d && d.v[1] ? decode(d.v[1]) : undefined; - return clean(r); } - -function encclient(d) { - var tup = atom('client'); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - return tuple(tup,data); } - -function lenclient() { return 2; } -function decclient(d) { - var r={}; r.tup = 'client'; - r.data = d && d.v[1] ? decode(d.v[1]) : undefined; - return clean(r); } - -function encserver(d) { - var tup = atom('server'); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - return tuple(tup,data); } - -function lenserver() { return 2; } -function decserver(d) { - var r={}; r.tup = 'server'; - r.data = d && d.v[1] ? decode(d.v[1]) : undefined; - return clean(r); } - -function encinit(d) { - var tup = atom('init'); - var token = 'token' in d && d.token ? encode(d.token) : nil(); - return tuple(tup,token); } - -function leninit() { return 2; } -function decinit(d) { - var r={}; r.tup = 'init'; - r.token = d && d.v[1] ? decode(d.v[1]) : undefined; - return clean(r); } - -function encpickle(d) { - var tup = atom('pickle'); - var source = 'source' in d && d.source ? encode(d.source) : nil(); - var pickled = 'pickled' in d && d.pickled ? encode(d.pickled) : nil(); - var args = 'args' in d && d.args ? encode(d.args) : nil(); - return tuple(tup,source,pickled,args); } - -function lenpickle() { return 4; } -function decpickle(d) { - var r={}; r.tup = 'pickle'; - r.source = d && d.v[1] ? decode(d.v[1]) : undefined; - r.pickled = d && d.v[2] ? decode(d.v[2]) : undefined; - r.args = d && d.v[3] ? decode(d.v[3]) : undefined; - return clean(r); } - -function encflush(d) { - var tup = atom('flush'); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - return tuple(tup,data); } - -function lenflush() { return 2; } -function decflush(d) { - var r={}; r.tup = 'flush'; - r.data = d && d.v[1] ? decode(d.v[1]) : undefined; - return clean(r); } - -function encdirect(d) { - var tup = atom('direct'); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - return tuple(tup,data); } - -function lendirect() { return 2; } -function decdirect(d) { - var r={}; r.tup = 'direct'; - r.data = d && d.v[1] ? decode(d.v[1]) : undefined; - return clean(r); } - -function encev(d) { - var tup = atom('ev'); - var module = 'module' in d && d.module ? encode(d.module) : nil(); - var msg = 'msg' in d && d.msg ? encode(d.msg) : nil(); - var trigger = 'trigger' in d && d.trigger ? encode(d.trigger) : nil(); - var name = 'name' in d && d.name ? encode(d.name) : nil(); - return tuple(tup,module,msg,trigger,name); } - -function lenev() { return 5; } -function decev(d) { - var r={}; r.tup = 'ev'; - r.module = d && d.v[1] ? decode(d.v[1]) : undefined; - r.msg = d && d.v[2] ? decode(d.v[2]) : undefined; - r.trigger = d && d.v[3] ? decode(d.v[3]) : undefined; - r.name = d && d.v[4] ? decode(d.v[4]) : undefined; - return clean(r); } - -function encftp(d) { - var tup = atom('ftp'); - var id = 'id' in d && d.id ? encode(d.id) : nil(); - var sid = 'sid' in d && d.sid ? encode(d.sid) : nil(); - var filename = 'filename' in d && d.filename ? encode(d.filename) : nil(); - var meta = 'meta' in d && d.meta ? encode(d.meta) : nil(); - var size = 'size' in d && d.size ? encode(d.size) : nil(); - var offset = 'offset' in d && d.offset ? encode(d.offset) : nil(); - var block = 'block' in d && d.block ? encode(d.block) : nil(); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - var status = 'status' in d && d.status ? encode(d.status) : nil(); - return tuple(tup,id,sid,filename,meta,size,offset,block,data,status); } - -function lenftp() { return 10; } -function decftp(d) { - var r={}; r.tup = 'ftp'; - r.id = d && d.v[1] ? decode(d.v[1]) : undefined; - r.sid = d && d.v[2] ? decode(d.v[2]) : undefined; - r.filename = d && d.v[3] ? decode(d.v[3]) : undefined; - r.meta = d && d.v[4] ? decode(d.v[4]) : undefined; - r.size = d && d.v[5] ? decode(d.v[5]) : undefined; - r.offset = d && d.v[6] ? decode(d.v[6]) : undefined; - r.block = d && d.v[7] ? decode(d.v[7]) : undefined; - r.data = d && d.v[8] ? decode(d.v[8]) : undefined; - r.status = d && d.v[9] ? decode(d.v[9]) : undefined; - return clean(r); } - -function encftpack(d) { - var tup = atom('ftpack'); - var id = 'id' in d && d.id ? encode(d.id) : nil(); - var sid = 'sid' in d && d.sid ? encode(d.sid) : nil(); - var filename = 'filename' in d && d.filename ? encode(d.filename) : nil(); - var meta = 'meta' in d && d.meta ? encode(d.meta) : nil(); - var size = 'size' in d && d.size ? encode(d.size) : nil(); - var offset = 'offset' in d && d.offset ? encode(d.offset) : nil(); - var block = 'block' in d && d.block ? encode(d.block) : nil(); - var data = 'data' in d && d.data ? encode(d.data) : nil(); - var status = 'status' in d && d.status ? encode(d.status) : nil(); - return tuple(tup,id,sid,filename,meta,size,offset,block,data,status); } - -function lenftpack() { return 10; } -function decftpack(d) { - var r={}; r.tup = 'ftpack'; - r.id = d && d.v[1] ? decode(d.v[1]) : undefined; - r.sid = d && d.v[2] ? decode(d.v[2]) : undefined; - r.filename = d && d.v[3] ? decode(d.v[3]) : undefined; - r.meta = d && d.v[4] ? decode(d.v[4]) : undefined; - r.size = d && d.v[5] ? decode(d.v[5]) : undefined; - r.offset = d && d.v[6] ? decode(d.v[6]) : undefined; - r.block = d && d.v[7] ? decode(d.v[7]) : undefined; - r.data = d && d.v[8] ? decode(d.v[8]) : undefined; - r.status = d && d.v[9] ? decode(d.v[9]) : undefined; - return clean(r); } - diff --git a/apps/roster/src/protocol/micro_auth.erl b/apps/roster/src/protocol/micro_auth.erl index 2d6ce2226..3d00ee7c4 100644 --- a/apps/roster/src/protocol/micro_auth.erl +++ b/apps/roster/src/protocol/micro_auth.erl @@ -72,11 +72,11 @@ info(#'Auth'{type = update, client_id = <<"emqttd_", _/binary>> = ClientId, toke {error, _} -> #io{code = #error{code = session_not_found}, data = ClientId} end, {reply, {bert, IO}, Req, State}; -info(#'Auth'{type = clear, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, _Req, #cx{client_pid = C} = State) -> - Reply = {reply, {bert, IO}, _, _} = roster_auth:info(Auth, State#cx{params = ClientId}), +info(#'Auth'{type = clear, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, Req, #cx{client_pid = C} = State) -> + Reply = {reply, {bert, IO}, _, _} = roster_auth:info(Auth, Req, State#cx{params = ClientId}), roster:send_action(C, ClientId, IO), Reply; -info(#'Auth'{type = delete, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, _Req, #cx{client_pid = C} = State) -> - Reply = {reply, {bert, IO}, _, _} = roster_auth:info(Auth, State#cx{params = ClientId}), +info(#'Auth'{type = delete, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, Req, #cx{client_pid = C} = State) -> + Reply = {reply, {bert, IO}, _, _} = roster_auth:info(Auth, Req, State#cx{params = ClientId}), roster:send_action(C, ClientId, IO), Reply; info(#'Auth'{type = logout, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, Req, #cx{params = SysClientId, client_pid = C} = State) -> IO = case kvs:get('Auth', ClientId) of diff --git a/apps/roster/src/protocol/roster_auth.erl b/apps/roster/src/protocol/roster_auth.erl index 1c257e2c4..fdc1d85d7 100644 --- a/apps/roster/src/protocol/roster_auth.erl +++ b/apps/roster/src/protocol/roster_auth.erl @@ -182,8 +182,7 @@ info(#'Auth'{type = verify, phone = Phone, dev_key = DevKey, settings = Settings PhoneId = roster:phone_id(Phone, Roster), NewSettings = [F#'Feature'{id = <>} || #'Feature'{key = Key} = F <-Settings], - kvs:put(P = #'Profile'{phone = Phone, rosters = [Roster], - settings = NewSettings, update = roster:now_msec()}), + kvs:put(P = #'Profile'{phone = Phone, rosters = [Roster], settings = NewSettings, update = roster:now_msec()}), % roster:n2o_pid(?MODULE) ! {vox, P, client(RegClientId)}, {roster, Roster} end, UserId = roster:phone_id(Phone, RosterId), ClientId = client(RegClientId), diff --git a/apps/roster/src/protocol/roster_friend.erl b/apps/roster/src/protocol/roster_friend.erl index eb2764db1..5f206dac5 100644 --- a/apps/roster/src/protocol/roster_friend.erl +++ b/apps/roster/src/protocol/roster_friend.erl @@ -14,7 +14,7 @@ info(#'Friend'{phone_id = Me, friend_id = Friend, status = request}, {Req, handl [{ok, FromR}, {ok, ToR}] = [kvs:get('Roster', Id) || Id <- [FromId, ToId]], D = case {roster:get_contact(FromR, Friend), roster:get_contact(ToR, Me)} of {#'Contact'{status = S1}, #'Contact'{status = S2}} when S1 =/= [];S2 =/= [] -> - #io{code = invalid_data}; + #io{code = #error{code = invalid_data}}; _ -> [Mc] = roster:to_contact([FromR], authorization), [Fc] = roster:to_contact([ToR], request), @@ -56,7 +56,7 @@ info(#'Friend'{friend_id = Friend, status = ignore}, Req, #cx{params = ClientId, case roster:update_contact(Me, Contact2 = Contact#'Contact'{status = ignore}) of {ok, added} -> roster:send_ses(C, roster:phone(Me), roster:presence(Contact2)), <<>>; E -> #io{code = E} end; - _ -> #io{code = invalid_data} + _ -> #io{code = #error{code = invalid_data}} end, {reply, {bert, IO}, Req, State}; @@ -90,7 +90,7 @@ info(#'Friend'{friend_id = Friend, status = confirm}, Req, #cx{params = ClientId roster:send_ses(C, From, roster:presence(Friendc#'Contact'{update = Now, created = Now, unread = 1, reader = lists:reverse(Rs)})), n2o_async:pid(system, ?MODULE) ! {send_push, Mec2, Friend, <<"friend">>}, {io, Local, Remote}; - _ -> #io{code = invalid_data} + _ -> #io{code = #error{code = invalid_data}} end, {reply, {bert, D}, Req, State}; diff --git a/apps/roster/src/protocol/roster_ftp.erl b/apps/roster/src/protocol/roster_ftp.erl index 8a498de09..4f19f9a44 100644 --- a/apps/roster/src/protocol/roster_ftp.erl +++ b/apps/roster/src/protocol/roster_ftp.erl @@ -7,7 +7,11 @@ -define(ROOT, application:get_env(roster, upload, code:priv_dir(roster))). -define(NEXT, 250 * 1024). % 256K chunks for best 25MB/s speed -define(STOP, 0). - +-define(N2O_ENV, application:get_all_env(n2o)). +-define(REPLY_ENCODER, + begin + proplists:get_value(formatter,?N2O_ENV,n2o_bert) + end). % Callbacks filename(#ftp{sid = Sid, filename = FileName}) -> FileName. %filename:join(nitro:to_list(Sid),FileName). @@ -20,10 +24,11 @@ info(#ftp{status = {event, _}} = FTP, Req, State) -> [] -> index; M -> M end, Reply = try Module:event(FTP) - catch E:R -> Error = n2o:stack(E, R), - roster:info(?MODULE, "Catch: ~p:~p~n~p", Error), - Error end, - {reply, n2o:format({io, n2o_nitro:render_actions(n2o:actions()), Reply}), Req, State}; + catch E:R -> + roster:error(?MODULE, "Catch: ~p~n", {E, R}), + [E, R, erlang:get_stacktrace()] + end, + {reply, {bert, reply_encode(Reply)}, Req, State}; %% TODO delete RelPath usage info(#ftp{id = Link, status = <<"init">>, block = Block, offset = Offset} = FTP, Req, State) -> @@ -78,7 +83,7 @@ proc(#ftp{id = Link, sid = Sid, data = Data, status = <<"send">>, block = Block, spawn(fun() -> n2o_async:stop(file, Link) end), {stop, normal, FTP2, Async#handler{state = FTP2}}; _ -> - {reply, {error, S3_Data / binary}, Async} + {reply, {error, S3_Data}, Async} end; proc(#ftp{data = Data, block = Block} = FTP, @@ -91,7 +96,10 @@ proc(#ftp{data = Data, block = Block} = FTP, roster:info(?MODULE, "~n~n Uploaded to S3 file with link ~p ~n~n", [S3_Data]), {reply, FTP2#ftp{data = <<>>}, Async#handler{state = FTP2#ftp{filename = RelPath}}}; _ -> - {reply, {error, S3_Data / binary}, Async} + {reply, {error, S3_Data }, Async} end; -proc(_, Async) -> {reply, #ftpack{}, Async}. \ No newline at end of file +proc(_, Async) -> {reply, #ftpack{}, Async}. + +reply_encode(Reply)-> + (?REPLY_ENCODER):encode(Reply). \ No newline at end of file diff --git a/apps/roster/src/protocol/roster_history.erl b/apps/roster/src/protocol/roster_history.erl index 39d974840..8dabf2e3e 100644 --- a/apps/roster/src/protocol/roster_history.erl +++ b/apps/roster/src/protocol/roster_history.erl @@ -180,8 +180,8 @@ info(#'History'{status = update, feed = Feed, entity_id = MId}, Req, members = [roster:reader_cache(roster:muc_member(PhoneId, Room, presence))]}, roster:reader_cache(UpdRoom#'Room'.readers)}; #p2p{} -> {_, FR, _, U} = roster:get_feed_data(Feed, roster:friend(PhoneId, Feed)), - {U, [roster:reader_cache(RId) || RId <- [FR, UpdReader]]}; - _ -> {<<>>, <<>>} + {U, [roster:reader_cache(RId) || RId <- [FR, UpdReader]]} + % _ -> {<<>>, <<>>} %% TODO: ------------------- To be removed in the future. ------------------- end, Res = roster:update_field(Record, [{unread, Unread}, {reader, Readers }, {readers, Readers }, {status, last_msg}]), roster:send_ses(C, From, Res), diff --git a/apps/roster/src/protocol/roster_link.erl b/apps/roster/src/protocol/roster_link.erl index 632de7d92..95ecc1ba7 100644 --- a/apps/roster/src/protocol/roster_link.erl +++ b/apps/roster/src/protocol/roster_link.erl @@ -57,9 +57,8 @@ info(#'Link'{id = LinkId, room_id = RoomId, type = Type, status = update = LStat Res = case roster:muc_member(ClientId, RoomId) of #'Member'{status = Status} when Status == owner; Status == admin -> case update_link(RequestData) of - {error, invalid_data} = E -> #io{code = E}; - {error, not_found} = E -> #io{code = E}; - NewLink -> NewLink + #'Link'{} = NewLink -> NewLink; + {error, invalid_data} = E -> #io{code = E} end; #'Member'{status = member} -> #io{code = #error{code = permission_denied}}; @@ -89,15 +88,17 @@ info(#'Link'{} = RequestData, Req, #cx{params = ClientId} = State) -> update_link(#'Link'{id=[], room_id = EId, type=Type}) ->gen_link(EId,Type); update_link(#'Link'{id=LinkId, room_id = EId, type=Type} = Link) -> - case get_link(kvs:get('Room',EId)) of - #'Link'{id=LinkId, room_id = EId} = L -> kvs:put(NewL=L#'Link'{type=Type}), - NewL#'Link'{status=update}; - #'Link'{id=Links0, room_id = EId} = L -> ok = kvs:delete('Link', Links0), - kvs:put(NewL=L#'Link'{id=LinkId, created=roster:now_msec(),type=Type}), - NewL#'Link'{status=update}; - {error, not_found} -> {error, invalid_data}; - E -> E - end. + case get_link(kvs:get('Room',EId)) of + #'Link'{id=LinkId, room_id = EId} = L -> + kvs:put(NewL=L#'Link'{type=Type}), + NewL#'Link'{status=update}; + #'Link'{id=Links0, room_id = EId} = L -> + ok = kvs:delete('Link', Links0), + kvs:put(NewL=L#'Link'{id=LinkId, created=roster:now_msec(),type=Type}), + NewL#'Link'{status=update}; + _ -> + {error, invalid_data} + end. %% NOTE - Not used at the moment, to be finished in next release @@ -127,7 +128,7 @@ delete_link(ClientId, #'Link'{id = LinkId, room_id = RoomId}) -> lists:map( fun (#'Member'{status = member}) -> {error, permission_denied}; - (#'Member'{status = Status}) when Status == owner; Status == admin -> + (#'Member'{status = Status}) when Status =:= admin; Status =:= owner -> case kvs:get('Room', RoomId) of {ok, #'Room'{id = RoomId, links = Links} = Room} -> ok = kvs:put(Room#'Room'{links = lists:keydelete(LinkId, #'Link'.id, Links)}), diff --git a/apps/roster/src/protocol/roster_message.erl b/apps/roster/src/protocol/roster_message.erl index 213701a0d..6cbc3972b 100644 --- a/apps/roster/src/protocol/roster_message.erl +++ b/apps/roster/src/protocol/roster_message.erl @@ -278,7 +278,7 @@ info(#'Message'{status = update, id = Id, files = [#'Desc'{mime = <<"transcribe" {reply, {bert, <<>>}, Req, State}; {ok, InvalidMsg} -> roster:info(?MODULE, "invalid audio transcribe for ~p", [InvalidMsg]), - {reply, {bert, #io{code = invalid_data}}, Req, State}; + {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}; {error, _} = E -> roster:error(?MODULE, "message ~p not found for transcribe", [Id]), {reply, {bert, #io{code = E}}, Req, State} end; diff --git a/rebar.lock b/rebar.lock deleted file mode 100644 index 3387cb405..000000000 --- a/rebar.lock +++ /dev/null @@ -1,190 +0,0 @@ -{"1.1.0", -[{<<"active">>, - {git,"git://github.com/synrc/active", - {ref,"db99cfed10ccb8241d89793ec1086348a731df67"}}, - 0}, - {<<"base64url">>, - {git,"https://github.com/dvv/base64url.git", - {ref,"f2c64ed8b9bebc536fad37ad97243452b674b837"}}, - 0}, - {<<"bert">>, - {git,"git://github.com/synrc/bert", - {ref,"3e3697d6ab97c1ecb9d5cbd80fa9742fb8a5f24e"}}, - 1}, - {<<"bpe">>, - {git,"git://github.com/synrc/bpe", - {ref,"bcfa8a384ca975d7f8932827108a748d3c83d34c"}}, - 0}, - {<<"certifi">>,{pkg,<<"certifi">>,<<"2.4.2">>},1}, - {<<"cf">>,{pkg,<<"cf">>,<<"0.3.1">>},2}, - {<<"counters">>, - {git,"https://github.com/deadtrickster/counters.erl.git", - {ref,"c3f4aa3acdf71c3db0a4b3fc1343aa45de2c5df0"}}, - 0}, - {<<"cowboy">>, - {git,"git://github.com/voxoz/cowboy", - {ref,"c1cfbfa5dc6b5f6ecd9591ad5bf642b6a107a7f5"}}, - 0}, - {<<"cowlib">>, - {git,"git://github.com/voxoz/cowlib", - {ref,"5cc0038d0a3ae6a829646ddfff998d8c491969ca"}}, - 1}, - {<<"ctx">>, - {git,"https://github.com/tsloughter/ctx.git", - {ref,"a5a6b0948708e02bc7b9cb6248807c9ff8327940"}}, - 0}, - {<<"emq_dashboard">>, - {git,"https://github.com/synrc/emq_dashboard", - {ref,"5bee03a8325db8b7d1c89cae86e2f23b8dac7cf7"}}, - 0}, - {<<"emqttc">>, - {git,"git://github.com/voxoz/emqttc", - {ref,"141fd2e925be854321d22005313762adb1195f48"}}, - 0}, - {<<"emqttd">>, - {git,"git://github.com/synrc/emqttd", - {ref,"c3d0b7b092fffe7bebe27af27dbbfe1714757d1c"}}, - 0}, - {<<"envy">>, - {git,"https://github.com/markan/envy.git", - {ref,"0148fb4b7ed0e188511578e98b42d6e7dde0ebd1"}}, - 1}, - {<<"erlang-uuid">>, - {git,"https://github.com/avtobiff/erlang-uuid.git", - {ref,"cb02a2039a9b29dd2eef0446039c9c6e164df9ef"}}, - 0}, - {<<"erlware_commons">>,{pkg,<<"erlware_commons">>,<<"1.3.1">>},1}, - {<<"erlydtl">>, - {git,"git://github.com/voxoz/erlydtl", - {ref,"bdebe6f87d8f989018facbbf8dc6320936ffe98f"}}, - 0}, - {<<"esockd">>, - {git,"https://github.com/voxoz/esockd", - {ref,"a80634b961c315ffe5f020d73236473b53ae5dc9"}}, - 0}, - {<<"forms">>, - {git,"git://github.com/synrc/forms", - {ref,"20104d880334a473a5557ea62596ce83e233e218"}}, - 1}, - {<<"fs">>, - {git,"git://github.com/synrc/fs", - {ref,"0023444ac9d64a86cd8ae06d929fd0e203ab6d3e"}}, - 1}, - {<<"gen_logger">>, - {git,"git://github.com/voxoz/gen_logger", - {ref,"5b14530363feb0b049c4f5c7c606f815aec781d2"}}, - 1}, - {<<"gen_smtp">>, - {git,"git://github.com/voxoz/gen_smtp", - {ref,"89eb26f8a81b0dce76aedae5695a923c8ac98695"}}, - 0}, - {<<"goldrush">>, - {git,"git://github.com/voxoz/goldrush.git", - {ref,"9e92405985827fabd2508b92bdc8b28b9e17b668"}}, - 2}, - {<<"gproc">>, - {git,"https://github.com/uwiger/gproc", - {ref,"1d16f5e6d7cf616eec4395f2385e3a680a4ffc9f"}}, - 0}, - {<<"ibrowse">>, - {git,"git://github.com/cmullaparthi/ibrowse.git", - {ref,"c97136cfb61fcc6f39d4e7da47372a64f7fca04e"}}, - 1}, - {<<"jsx">>, - {git,"https://github.com/talentdeficit/jsx.git", - {ref,"fc2a001073f2300ba38427c23e83d5673c020542"}}, - 0}, - {<<"jwt">>, - {git,"https://github.com/artemeff/jwt.git", - {ref,"6fd754fec1cd2e4577a5d7121233371900aa44e7"}}, - 0}, - {<<"kvs">>, - {git,"git://github.com/qomputer/kvs", - {ref,"4df1d52e941c286dd27d3ec5ebebfed88aede1c3"}}, - 0}, - {<<"lager">>, - {git,"git://github.com/voxoz/lager", - {ref,"1ecf4c17e9e39dd7a1943140477f632d17518f0c"}}, - 1}, - {<<"libphonenumber_erlang">>, - {git,"https://github.com/marinakr/libphonenumber_erlang.git", - {ref,"9e101e61f45d4d7f44d9fe30431d400e79e3856e"}}, - 0}, - {<<"locus">>, - {git,"https://github.com/g-andrade/locus.git", - {ref,"638063fb9b2d81cfd0b219eee76ae43197ab4433"}}, - 0}, - {<<"mad">>, - {git,"git://github.com/synrc/mad", - {ref,"a7ff936dc8b584422d1f5f87af20d4fc49a2e571"}}, - 1}, - {<<"migresia">>, - {git,"https://github.com/yoonka/migresia.git", - {ref,"40e11825e01502d045e87bf8b5d7dc5a9d6e3f73"}}, - 0}, - {<<"mini_s3">>, - {git,"https://github.com/chef/mini_s3.git", - {ref,"df0c68ea901343b8e0c647142d88d7f3aae27e7b"}}, - 0}, - {<<"mochiweb">>, - {git,"git://github.com/voxoz/mochiweb", - {ref,"c53540557dba6d79c347209fc9980e97dcf3dd3f"}}, - 1}, - {<<"n2o">>, - {git,"git://github.com/synrc/n2o", - {ref,"cb6ae134793724a6eaf37a3f498ca5e130dfc51e"}}, - 1}, - {<<"nitro">>, - {git,"git://github.com/synrc/nitro", - {ref,"458eecd78c0dfae258fa9b18509bee5fdcd750ff"}}, - 1}, - {<<"opencensus-erlang">>, - {git,"https://github.com/voxoz/opencensus-erlang", - {ref,"8dc9ae86f5c1ef69593fe37b49e649afed6bd201"}}, - 0}, - {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},2}, - {<<"prometheus">>, - {git,"https://github.com/deadtrickster/prometheus.erl", - {ref,"4cae6df7d3d0f5feb5508ffc0ea4b2eedf5136fc"}}, - 0}, - {<<"qdate">>, - {git,"https://github.com/enterprizing/qdate.git", - {ref,"fba988fc54214bb37a3ce11d5c5a3cc68752c3ce"}}, - 0}, - {<<"qdate_localtime">>,{pkg,<<"qdate_localtime">>,<<"1.1.0">>},1}, - {<<"ranch">>, - {git,"git://github.com/voxoz/ranch", - {ref,"1a75038c82ede22efec46a7dca192b8ce26309e0"}}, - 1}, - {<<"rest">>, - {git,"git://github.com/synrc/rest", - {ref,"9a4e21d50a96b06649944c9a88ad595114db6c31"}}, - 0}, - {<<"rfc3339">>, - {git,"https://github.com/talentdeficit/rfc3339", - {ref,"90effc078c5e673d025b2c1269a153ad4748d3df"}}, - 0}, - {<<"sh">>, - {git,"git://github.com/synrc/sh", - {ref,"64b65f6bc8c3a8fbf24351f23357035d79d3815c"}}, - 2}, - {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.4">>},1}, - {<<"stacktrace_compat">>,{pkg,<<"stacktrace_compat">>,<<"1.0.2">>},1}, - {<<"syn">>, - {git,"git://github.com/ostinelli/syn", - {ref,"9964eb8969b6e1e712249d3aed4f3dfafd3aaac3"}}, - 1}, - {<<"wts">>, - {git,"https://github.com/tsloughter/wts.git", - {ref,"5613b6c4354867fd2b02fde5ef15bf80190b8586"}}, - 0}]}. -[ -{pkg_hash,[ - {<<"certifi">>, <<"75424FF0F3BAACCFD34B1214184B6EF616D89E420B258BB0A5EA7D7BC628F7F0">>}, - {<<"cf">>, <<"5CB902239476E141EA70A740340233782D363A31EEA8AD37049561542E6CD641">>}, - {<<"erlware_commons">>, <<"0CE192AD69BC6FD0880246D852D0ECE17631E234878011D1586E053641ED4C04">>}, - {<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>}, - {<<"qdate_localtime">>, <<"5F6C3ACF10ECC5A7E2EFA3DCD2C863102B962188DBD9E086EC01D29FE029DA29">>}, - {<<"ssl_verify_fun">>, <<"F0EAFFF810D2041E93F915EF59899C923F4568F4585904D010387ED74988E77B">>}, - {<<"stacktrace_compat">>, <<"8AD31C32C9A0EADB1EB298F04DC8B0C8D79BCC6233A638B02791FFCA4F331275">>}]} -]. -- GitLab From cb668d859fec301600ea2bdacf9a67fd50974db9 Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Thu, 20 Jun 2019 14:56:04 +0300 Subject: [PATCH 08/20] [NY-7291] fixed roster_room patt_match; roster miss_type_spec WIP --- .gitignore | 2 ++ apps/roster/include/roster.hrl | 2 +- apps/roster/src/protocol/roster_room.erl | 24 +++++++++++++++++------- apps/roster/src/roster.erl | 7 ++++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 67cc952f7..0381484ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +erl_crash.dump + deps/ log/ **/*.java diff --git a/apps/roster/include/roster.hrl b/apps/roster/include/roster.hrl index 4ece712dc..a4c621964 100644 --- a/apps/roster/include/roster.hrl +++ b/apps/roster/include/roster.hrl @@ -239,7 +239,7 @@ update = 0 :: integer(), balance = 0 :: integer(), presence = [] :: [] | offline | online | binary(), - status = [] :: [] | remove | get | patch | update| delete | create }). + status = [] :: [] | remove | get | patch | update| delete | create | init}). -record('Presence', {uid = <<>> :: binary(), status = [] :: [] | offline | online | binary()}). diff --git a/apps/roster/src/protocol/roster_room.erl b/apps/roster/src/protocol/roster_room.erl index f0244c4d6..22e7622ac 100644 --- a/apps/roster/src/protocol/roster_room.erl +++ b/apps/roster/src/protocol/roster_room.erl @@ -136,16 +136,22 @@ info(#'Room'{status = St, id = Room, members = Members, admins = Admins, readers case roster:muc_member(PhoneId, Room, presence) of #'Member'{status = removed} = M when Status == admin; Status == member-> M2 = roster:patch_member(M#'Member'{status = Status}, Member), - {M3, _, UpdRoom} = roster:add_member(TmpRoom, M2, {no_muc_message, HL}), - kvs:put(M3), - {M3, UpdRoom}; + case lists:map(fun handle_add_member/1, + [roster:add_member(TmpRoom, M2, {no_muc_message, HL})]) + of + [{M3, _} = Resource]-> ok = kvs:put(M3), Resource; + _ -> error + end; #'Member'{phone_id = APId} = M -> {ignore, M}; #'Member'{} = M -> kvs:put(M2 = roster:patch_member(M#'Member'{status = Status}, Member)), {ignore, M2}; - _ -> {M2, _, UpdRoom} = roster:add_member(TmpRoom, - Member#'Member'{feed_id = #muc{name = Room}, reader = 0}, {no_muc_message, HL}), - {M2, UpdRoom} + _ -> + [Resource] = + lists:map(fun handle_add_member/1, [roster:add_member(TmpRoom, + Member#'Member'{feed_id = #muc{name = Room}, reader = 0}, + {no_muc_message, HL})]), + Resource end, case MmbrRoom of error -> roster:info(?MODULE, "ERROR:add_member:RosterNotFound:~p", [PhoneId]), @@ -399,4 +405,8 @@ proc({send_push, NewMembers, Msg, Type}, #handler{} = H) -> end, roster_push:send_push_notification(Ses, Payload, PushAlert, PushType) end || {MemPhoneId, _} = Mem <- ToRoomMembers, Ses <- kvs:index('Auth', user_id, MemPhoneId) - ], {reply, [], H}. \ No newline at end of file + ], {reply, [], H}. + +handle_add_member({error,_})-> error; +handle_add_member({Member, _, Room}) when Member =/= error-> {Member, Room}; +handle_add_member(_)-> error. diff --git a/apps/roster/src/roster.erl b/apps/roster/src/roster.erl index 744222a8d..36406a262 100644 --- a/apps/roster/src/roster.erl +++ b/apps/roster/src/roster.erl @@ -557,9 +557,10 @@ add_message(#'Message'{feed_id = Feed} = Msg) -> add_message(#'Message'{} = Msg, Reader) -> kvs_stream:save(offset_reader(#writer{cache = LMsg} = add_message(Msg), Reader)), LMsg. --spec unread_msg(#muc{} |#p2p{} |#writer{} |#error{}, - integer() | #reader{}, - integer() |binary()|#'Member'{}) -> +-spec unread_msg(#muc{} | #p2p{} | #writer{} | #error{} | #'Message'{} | + {'Message', [] | integer() | #'Message'{}}, + integer() | #reader{}, + integer() | binary() | #'Member'{}) -> {integer() | binary(), #'Message'{} | update, [integer()]}. unread_msg({error, _}, _, _) -> {0, [], []}; unread_msg(_, {error, _}, _) -> {0, [], []}; -- GitLab From 065c92efbb4bb22ec9c1ed73611051844fa1dcfc Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Fri, 21 Jun 2019 10:14:42 +0300 Subject: [PATCH 09/20] [NY-7291] rest_chat_csv --- apps/roster/src/rest/rest_chat_csv.erl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/roster/src/rest/rest_chat_csv.erl b/apps/roster/src/rest/rest_chat_csv.erl index 822f1973c..4afdbba64 100644 --- a/apps/roster/src/rest/rest_chat_csv.erl +++ b/apps/roster/src/rest/rest_chat_csv.erl @@ -25,7 +25,7 @@ ]). %% Custom data types --type type_chat_element() :: {MsgDate::integer(), Username::string(), Message::string()}. +-type type_chat_element() :: {MsgDate::integer(), Username::string(), MessageType:: [] | binary(), Message::string()}. -type type_chat() :: [type_chat_element()]. -type type_user_data() :: {binary(), string()}. @@ -63,7 +63,7 @@ handle_request('GET', #{room := GroupChatId}, Req) -> try ChatHistory = get_chat_history({muc, RoomId}), Members = get_group_chat_members(RoomId), - GroupChatName = get_group_chat_name(RoomId), + GroupChatName = binary_to_list(get_group_chat_name(RoomId)), #'Member'{id = MemberId} = roster:muc_member(rest_main_helper:get_client_phone_id(Req), RoomId), ChatData = extract_chat_data(ChatHistory, Members, FromDate, ToDate, AllowedMessageTypes, MemberId), CsvText = conversation_to_csv(ChatData, GroupChatName, FromDate, ToDate, TimeZone, AllowedMessageTypes), @@ -110,7 +110,7 @@ conversation_to_csv(ChatData, ToUsername, FromDate, ToDate, TimeZone, AllowedMes TemplateRows = build_template_rows(ChatSpanTimezone, ToUsername, AllowedMessageTypes), build_message_rows(ChatData, TimeZone, TemplateRows). --spec build_template_rows(tuple(), string(), list()) -> list(). +-spec build_template_rows(tuple(), string(), list()) -> [string()]. build_template_rows({FromDate, ToDate}, ToUsername, AllowedMessageTypes) -> Template = ["NYNJA Chat Export", ?NEW_LINE, ?NEW_LINE, "From Date:", ?NEW_COLUMN, format_date(FromDate, "M dS Y"), ?NEW_LINE, @@ -200,8 +200,8 @@ get_chat_history(Feed) -> History -> History end. --spec get_chat_time_span(type_chat_element(), integer(), integer()) -> {integer(), integer()}. -get_chat_time_span([], FromDate, ToDate) -> throw({no_chat_history, get_chat_time_span}); +-spec get_chat_time_span(type_chat(), integer(), integer()) -> {integer(), integer()}. +get_chat_time_span([], _FromDate, _ToDate) -> throw({no_chat_history, get_chat_time_span}); get_chat_time_span(Chat, FromDate, ToDate) -> From = case FromDate of @@ -219,14 +219,15 @@ get_chat_time_span(Chat, FromDate, ToDate) -> end, {From, To}. --spec format_msg_type(binary()) -> list(binary()). +-spec format_msg_type(<<_:8,_:_*8>>) -> [[any()] | char()]. +% Due to the fact that we have a functionl pattern matching format_msg_type(<>) -> io_lib:format("~s~s", [string:uppercase(FirstLetter), Rest]). -spec format_date(tuple(), string()) -> string(). format_date(Date, Format) -> qdate:to_string(Format, Date). --spec format_timezone(integer(), string()) -> tuple() | integer(). +-spec format_timezone(integer() | tuple(), string()) -> tuple() | integer(). format_timezone(Timestamp, TimeZone) when is_integer(Timestamp), is_list(TimeZone) -> format_timezone(roster:msToUT(Timestamp), TimeZone); format_timezone({{_, _, _}, {_, _, _}} = Date, TimeZone) -> -- GitLab From f5c4e360c112c7589b24d209efa27c71079e8d42 Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Mon, 24 Jun 2019 14:09:16 +0300 Subject: [PATCH 10/20] [NY-7291] roster_channel_helper; roster; patt_match; miss_type_spec WIP --- apps/roster/include/roster.hrl | 2 +- apps/roster/priv/macbert/Model/Feature.swift | 7 ------- apps/roster/src/rest/rest_handler.erl | 1 - apps/roster/src/roster_channel_helper.erl | 8 ++++++-- apps/roster/src/test/roster_test.erl | 2 +- 5 files changed, 8 insertions(+), 12 deletions(-) delete mode 100644 apps/roster/priv/macbert/Model/Feature.swift diff --git a/apps/roster/include/roster.hrl b/apps/roster/include/roster.hrl index a4c621964..b96d21331 100644 --- a/apps/roster/include/roster.hrl +++ b/apps/roster/include/roster.hrl @@ -210,7 +210,7 @@ sms_code = [] :: [] | binary(), attempts = [] :: [] | integer(), services = [] :: list(term()), - settings = [] :: [] | list(#'Feature'{}), + settings = [] :: [] | binary() | list(#'Feature'{}), push = [] :: [] | binary(), os = [] :: [] | ios | android | web, created = [] :: [] | integer(), diff --git a/apps/roster/priv/macbert/Model/Feature.swift b/apps/roster/priv/macbert/Model/Feature.swift deleted file mode 100644 index 06325ae6e..000000000 --- a/apps/roster/priv/macbert/Model/Feature.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class Feature { - var id: String? - var key: String? - var value: String? - var group: String? -} \ No newline at end of file diff --git a/apps/roster/src/rest/rest_handler.erl b/apps/roster/src/rest/rest_handler.erl index 9beb7de3c..59dd9b26e 100644 --- a/apps/roster/src/rest/rest_handler.erl +++ b/apps/roster/src/rest/rest_handler.erl @@ -77,7 +77,6 @@ handle_request(Method, Path, Req) %% NOTE! uncomment the row under to turn on call bubbles %% handle_request(_, ?RCI_BUBBLE_ENDPOINT, Req) -> rest_cri :handle_request(Req); -handle_request(Method, "/metrics" = Path, Req) -> rest_metric :handle_request(Method, Path, Req); handle_request(Method, ?MSG_PUSH_ENDPOINT = Path, Req) -> rest_push:handle_request(Method, Path, Req); handle_request(Method, ?ROOM_ENDPOINT = Path, Req) -> rest_deeplink:handle_request(Method, Path, Req); handle_request(Method, ?PUBLISH_ENDPOINT = Path, Req) -> rest_publish:handle_request(Method, Path, Req); diff --git a/apps/roster/src/roster_channel_helper.erl b/apps/roster/src/roster_channel_helper.erl index c51cf8283..ea0e7186d 100644 --- a/apps/roster/src/roster_channel_helper.erl +++ b/apps/roster/src/roster_channel_helper.erl @@ -134,8 +134,12 @@ add_members(#'Room'{id = ChannelId, readers = ChannelReaders} = Channel, Members case MemberStatus of removed -> PrePatchedMember = roster:patch_member(ExistingMember#'Member'{status = member}, ExistingMember), - {PatchedMember, _, _} = roster:add_member(Channel, PrePatchedMember, {no_muc_message, ChannelReaders}), - kvs:put(PatchedMember); + case roster:add_member(Channel, PrePatchedMember, {no_muc_message, ChannelReaders}) of + {PatchedMember = #'Member'{}, _, _} -> kvs:put(PatchedMember); + {error,_} -> skip + % when ErrCode == duplicated; + % ErrCode == not_found; ErrCode == roster_not_found + end; _ -> skip end end diff --git a/apps/roster/src/test/roster_test.erl b/apps/roster/src/test/roster_test.erl index 93d7afe0c..b87e03ea5 100644 --- a/apps/roster/src/test/roster_test.erl +++ b/apps/roster/src/test/roster_test.erl @@ -610,7 +610,7 @@ test_update_contacts() -> PhoneA = <<"357">>, AClientId = roster_client:gen_name(PhoneA), Phones = [<<"53533">>, <<"53774">>], - length(Phones), + % length(Phones), [roster:purge_user(Phone) || Phone <- [PhoneA | Phones]], PCs = [{B, BClientId, _}, {C, CClientId, TC}, {From, AClientId, TA}] = [begin {ClientId, Token} = roster_client:reg_fake_user(Phone), -- GitLab From c416c09d0f04f92a1ed399b75ceed06ac08d6bd5 Mon Sep 17 00:00:00 2001 From: qomputer Date: Tue, 2 Jul 2019 15:28:34 +0300 Subject: [PATCH 11/20] Update sys.config for new n2o --- sys.config | 1 + 1 file changed, 1 insertion(+) diff --git a/sys.config b/sys.config index b56074507..4dde629d3 100644 --- a/sys.config +++ b/sys.config @@ -71,6 +71,7 @@ {protocols,[n2o_nitro,n2o_ftp,roster_proto]}, {log_modules,[roster, n2o_vnode]}, {log_level,roster}, + {mqtt_server,true}, {vnode, {roster, get_vnode}}, {validate, {roster, validate}} ]}, -- GitLab From 78a0fbb7753d8c881a963a6609d694b3985348b4 Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Wed, 3 Jul 2019 15:02:56 +0300 Subject: [PATCH 12/20] [NY-7291] remove autogenerated swift files, functional adjustment, explicitly defined required apps --- .gitignore | 7 +- apps/roster/include/roster.hrl | 2 +- apps/roster/priv/macbert/Model/Ack.swift | 5 - apps/roster/priv/macbert/Model/CDR.swift | 16 - apps/roster/priv/macbert/Model/Call.swift | 10 - .../priv/macbert/Model/CallMember.swift | 16 - apps/roster/priv/macbert/Model/Contact.swift | 17 - apps/roster/priv/macbert/Model/Cursor.swift | 6 - apps/roster/priv/macbert/Model/Desc.swift | 8 - .../priv/macbert/Model/ExtendedStar.swift | 5 - apps/roster/priv/macbert/Model/Friend.swift | 7 - apps/roster/priv/macbert/Model/History.swift | 9 - apps/roster/priv/macbert/Model/Index.swift | 5 - apps/roster/priv/macbert/Model/Link.swift | 9 - apps/roster/priv/macbert/Model/Loc.swift | 6 - apps/roster/priv/macbert/Model/Message.swift | 19 - apps/roster/priv/macbert/Model/Person.swift | 14 - .../priv/macbert/Model/PushService.swift | 9 - apps/roster/priv/macbert/Model/Room.swift | 21 - apps/roster/priv/macbert/Model/Search.swift | 9 - apps/roster/priv/macbert/Model/Service.swift | 10 - apps/roster/priv/macbert/Model/Star.swift | 9 - .../priv/macbert/Model/StickerPack.swift | 12 - apps/roster/priv/macbert/Model/Tag.swift | 7 - apps/roster/priv/macbert/Model/Test.swift | 5 - apps/roster/priv/macbert/Model/Typing.swift | 5 - apps/roster/priv/macbert/Model/Vox.swift | 6 - apps/roster/priv/macbert/Model/act.swift | 5 - apps/roster/priv/macbert/Model/amend.swift | 5 - .../priv/macbert/Model/beginEvent.swift | 6 - .../priv/macbert/Model/boundaryEvent.swift | 11 - apps/roster/priv/macbert/Model/chain.swift | 7 - apps/roster/priv/macbert/Model/complete.swift | 4 - .../roster/priv/macbert/Model/container.swift | 7 - apps/roster/priv/macbert/Model/create.swift | 5 - apps/roster/priv/macbert/Model/cur.swift | 10 - apps/roster/priv/macbert/Model/endEvent.swift | 6 - apps/roster/priv/macbert/Model/error.swift | 4 - apps/roster/priv/macbert/Model/error2.swift | 5 - apps/roster/priv/macbert/Model/errors.swift | 5 - apps/roster/priv/macbert/Model/histo.swift | 4 - apps/roster/priv/macbert/Model/io.swift | 5 - apps/roster/priv/macbert/Model/iter.swift | 8 - apps/roster/priv/macbert/Model/iterator.swift | 9 - .../priv/macbert/Model/join_application.swift | 6 - apps/roster/priv/macbert/Model/log.swift | 7 - apps/roster/priv/macbert/Model/max_tour.swift | 5 - apps/roster/priv/macbert/Model/mqi.swift | 6 - apps/roster/priv/macbert/Model/muc.swift | 4 - apps/roster/priv/macbert/Model/ok2.swift | 5 - .../roster/priv/macbert/Model/operation.swift | 9 - apps/roster/priv/macbert/Model/p2p.swift | 5 - apps/roster/priv/macbert/Model/proc.swift | 4 - apps/roster/priv/macbert/Model/process.swift | 25 - apps/roster/priv/macbert/Model/push.swift | 9 - .../priv/macbert/Model/receiveTask.swift | 7 - .../priv/macbert/Model/sequenceFlow.swift | 5 - .../priv/macbert/Model/serviceTask.swift | 7 - apps/roster/priv/macbert/Model/task.swift | 7 - .../priv/macbert/Model/timeoutEvent.swift | 11 - .../roster/priv/macbert/Model/tour_list.swift | 4 - apps/roster/priv/macbert/Model/userTask.swift | 7 - apps/roster/priv/macbert/Model/writer.swift | 8 - apps/roster/priv/macbert/Source/Bert.swift | 693 ------------------ apps/roster/priv/macbert/Source/Encoder.swift | 382 ---------- .../priv/macbert/Source/StringAtom.swift | 16 - .../roster/priv/macbert/Source/TypeSpec.swift | 376 ---------- apps/roster/priv/macbert/Spec/Ack_Spec.swift | 6 - apps/roster/priv/macbert/Spec/CDR_Spec.swift | 38 - .../priv/macbert/Spec/CallMember_Spec.swift | 48 -- apps/roster/priv/macbert/Spec/Call_Spec.swift | 24 - .../priv/macbert/Spec/Cursor_Spec.swift | 9 - .../priv/macbert/Spec/ExtendedStar_Spec.swift | 9 - .../priv/macbert/Spec/Friend_Spec.swift | 14 - .../priv/macbert/Spec/History_Spec.swift | 38 - .../roster/priv/macbert/Spec/Index_Spec.swift | 6 - apps/roster/priv/macbert/Spec/Link_Spec.swift | 27 - apps/roster/priv/macbert/Spec/Loc_Spec.swift | 11 - .../priv/macbert/Spec/Person_Spec.swift | 15 - .../priv/macbert/Spec/PushService_Spec.swift | 18 - .../priv/macbert/Spec/Search_Spec.swift | 16 - .../priv/macbert/Spec/Service_Spec.swift | 26 - .../priv/macbert/Spec/StickerPack_Spec.swift | 19 - apps/roster/priv/macbert/Spec/Tag_Spec.swift | 12 - apps/roster/priv/macbert/Spec/Test_Spec.swift | 9 - .../priv/macbert/Spec/Typing_Spec.swift | 4 - apps/roster/priv/macbert/Spec/Vox_Spec.swift | 11 - apps/roster/priv/macbert/Spec/act_Spec.swift | 9 - .../roster/priv/macbert/Spec/amend_Spec.swift | 8 - .../priv/macbert/Spec/beginEvent_Spec.swift | 9 - .../roster/priv/macbert/Spec/chain_Spec.swift | 12 - .../priv/macbert/Spec/complete_Spec.swift | 5 - .../priv/macbert/Spec/container_Spec.swift | 12 - .../priv/macbert/Spec/create_Spec.swift | 9 - apps/roster/priv/macbert/Spec/cur_Spec.swift | 21 - .../priv/macbert/Spec/endEvent_Spec.swift | 9 - .../priv/macbert/Spec/error2_Spec.swift | 9 - .../roster/priv/macbert/Spec/error_Spec.swift | 5 - .../priv/macbert/Spec/errors_Spec.swift | 8 - .../roster/priv/macbert/Spec/histo_Spec.swift | 5 - apps/roster/priv/macbert/Spec/iter_Spec.swift | 13 - .../priv/macbert/Spec/iterator_Spec.swift | 14 - .../macbert/Spec/join_application_Spec.swift | 5 - apps/roster/priv/macbert/Spec/log_Spec.swift | 12 - .../priv/macbert/Spec/max_tour_Spec.swift | 4 - apps/roster/priv/macbert/Spec/mqi_Spec.swift | 11 - apps/roster/priv/macbert/Spec/muc_Spec.swift | 3 - apps/roster/priv/macbert/Spec/ok2_Spec.swift | 11 - .../priv/macbert/Spec/operation_Spec.swift | 14 - apps/roster/priv/macbert/Spec/p2p_Spec.swift | 4 - apps/roster/priv/macbert/Spec/proc_Spec.swift | 5 - .../priv/macbert/Spec/process_Spec.swift | 56 -- apps/roster/priv/macbert/Spec/push_Spec.swift | 20 - .../priv/macbert/Spec/sequenceFlow_Spec.swift | 9 - .../priv/macbert/Spec/timeoutEvent_Spec.swift | 29 - .../priv/macbert/Spec/tour_list_Spec.swift | 3 - .../priv/macbert/Spec/writer_Spec.swift | 11 - apps/roster/priv/macbert/main.swift | 43 -- apps/roster/src/processes/job.erl | 12 +- apps/roster/src/protocol/micro_auth.erl | 4 +- apps/roster/src/protocol/micro_roster.erl | 2 +- apps/roster/src/protocol/roster_auth.erl | 4 +- apps/roster/src/protocol/roster_bpe.erl | 14 +- apps/roster/src/protocol/roster_friend.erl | 6 +- apps/roster/src/protocol/roster_ftp.erl | 8 +- apps/roster/src/protocol/roster_history.erl | 6 +- apps/roster/src/protocol/roster_message.erl | 10 +- apps/roster/src/protocol/roster_profile.erl | 2 +- apps/roster/src/protocol/roster_push.erl | 2 +- apps/roster/src/protocol/roster_room.erl | 12 +- apps/roster/src/protocol/roster_roster.erl | 12 +- apps/roster/src/protocol/roster_search.erl | 2 +- apps/roster/src/rest/rest_push.erl | 2 +- apps/roster/src/roster.app.src | 34 +- apps/roster/src/roster.erl | 25 +- apps/roster/src/roster_channel_helper.erl | 2 +- apps/roster/src/roster_client.erl | 8 +- rebar.config | 5 +- 138 files changed, 103 insertions(+), 2785 deletions(-) delete mode 100644 apps/roster/priv/macbert/Model/Ack.swift delete mode 100644 apps/roster/priv/macbert/Model/CDR.swift delete mode 100644 apps/roster/priv/macbert/Model/Call.swift delete mode 100644 apps/roster/priv/macbert/Model/CallMember.swift delete mode 100644 apps/roster/priv/macbert/Model/Contact.swift delete mode 100644 apps/roster/priv/macbert/Model/Cursor.swift delete mode 100644 apps/roster/priv/macbert/Model/Desc.swift delete mode 100644 apps/roster/priv/macbert/Model/ExtendedStar.swift delete mode 100644 apps/roster/priv/macbert/Model/Friend.swift delete mode 100644 apps/roster/priv/macbert/Model/History.swift delete mode 100644 apps/roster/priv/macbert/Model/Index.swift delete mode 100644 apps/roster/priv/macbert/Model/Link.swift delete mode 100644 apps/roster/priv/macbert/Model/Loc.swift delete mode 100644 apps/roster/priv/macbert/Model/Message.swift delete mode 100644 apps/roster/priv/macbert/Model/Person.swift delete mode 100644 apps/roster/priv/macbert/Model/PushService.swift delete mode 100644 apps/roster/priv/macbert/Model/Room.swift delete mode 100644 apps/roster/priv/macbert/Model/Search.swift delete mode 100644 apps/roster/priv/macbert/Model/Service.swift delete mode 100644 apps/roster/priv/macbert/Model/Star.swift delete mode 100644 apps/roster/priv/macbert/Model/StickerPack.swift delete mode 100644 apps/roster/priv/macbert/Model/Tag.swift delete mode 100644 apps/roster/priv/macbert/Model/Test.swift delete mode 100644 apps/roster/priv/macbert/Model/Typing.swift delete mode 100644 apps/roster/priv/macbert/Model/Vox.swift delete mode 100644 apps/roster/priv/macbert/Model/act.swift delete mode 100644 apps/roster/priv/macbert/Model/amend.swift delete mode 100644 apps/roster/priv/macbert/Model/beginEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/boundaryEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/chain.swift delete mode 100644 apps/roster/priv/macbert/Model/complete.swift delete mode 100644 apps/roster/priv/macbert/Model/container.swift delete mode 100644 apps/roster/priv/macbert/Model/create.swift delete mode 100644 apps/roster/priv/macbert/Model/cur.swift delete mode 100644 apps/roster/priv/macbert/Model/endEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/error.swift delete mode 100644 apps/roster/priv/macbert/Model/error2.swift delete mode 100644 apps/roster/priv/macbert/Model/errors.swift delete mode 100644 apps/roster/priv/macbert/Model/histo.swift delete mode 100644 apps/roster/priv/macbert/Model/io.swift delete mode 100644 apps/roster/priv/macbert/Model/iter.swift delete mode 100644 apps/roster/priv/macbert/Model/iterator.swift delete mode 100644 apps/roster/priv/macbert/Model/join_application.swift delete mode 100644 apps/roster/priv/macbert/Model/log.swift delete mode 100644 apps/roster/priv/macbert/Model/max_tour.swift delete mode 100644 apps/roster/priv/macbert/Model/mqi.swift delete mode 100644 apps/roster/priv/macbert/Model/muc.swift delete mode 100644 apps/roster/priv/macbert/Model/ok2.swift delete mode 100644 apps/roster/priv/macbert/Model/operation.swift delete mode 100644 apps/roster/priv/macbert/Model/p2p.swift delete mode 100644 apps/roster/priv/macbert/Model/proc.swift delete mode 100644 apps/roster/priv/macbert/Model/process.swift delete mode 100644 apps/roster/priv/macbert/Model/push.swift delete mode 100644 apps/roster/priv/macbert/Model/receiveTask.swift delete mode 100644 apps/roster/priv/macbert/Model/sequenceFlow.swift delete mode 100644 apps/roster/priv/macbert/Model/serviceTask.swift delete mode 100644 apps/roster/priv/macbert/Model/task.swift delete mode 100644 apps/roster/priv/macbert/Model/timeoutEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/tour_list.swift delete mode 100644 apps/roster/priv/macbert/Model/userTask.swift delete mode 100644 apps/roster/priv/macbert/Model/writer.swift delete mode 100644 apps/roster/priv/macbert/Source/Bert.swift delete mode 100644 apps/roster/priv/macbert/Source/Encoder.swift delete mode 100644 apps/roster/priv/macbert/Source/StringAtom.swift delete mode 100644 apps/roster/priv/macbert/Source/TypeSpec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Ack_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/CDR_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/CallMember_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Call_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Cursor_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/ExtendedStar_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Friend_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/History_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Index_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Link_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Loc_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Person_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/PushService_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Search_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Service_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/StickerPack_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Tag_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Test_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Typing_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Vox_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/act_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/amend_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/beginEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/chain_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/complete_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/container_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/create_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/cur_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/endEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/error2_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/error_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/errors_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/histo_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/iter_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/iterator_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/join_application_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/log_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/max_tour_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/mqi_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/muc_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/ok2_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/operation_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/p2p_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/proc_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/process_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/push_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/sequenceFlow_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/timeoutEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/tour_list_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/writer_Spec.swift delete mode 100644 apps/roster/priv/macbert/main.swift diff --git a/.gitignore b/.gitignore index 0381484ed..1cab9cf46 100644 --- a/.gitignore +++ b/.gitignore @@ -24,10 +24,7 @@ _build rebar.lock priv/protobuf/* -apps/roster/priv/macbert/Model/* -apps/roster/priv/macbert/Spec/* -apps/roster/priv/macbert/Source/* +apps/roster/src/roster_validator.erl +apps/roster/priv/* apps/service/priv/* -apps/roster/src/roster_validator.erl -apps/roster/priv/macbert/json-bert.js \ No newline at end of file diff --git a/apps/roster/include/roster.hrl b/apps/roster/include/roster.hrl index b96d21331..9f401fe7b 100644 --- a/apps/roster/include/roster.hrl +++ b/apps/roster/include/roster.hrl @@ -75,7 +75,7 @@ -record('Feature', {id = [] :: [] | binary(), key = [] :: binary(), - value = <<>> :: [] | binary(), + value = <<>> :: [] | binary() | true, group = ?DUMMY_GROUP :: [] | binary()}). -record('Service', {id = [] :: [] | binary(), diff --git a/apps/roster/priv/macbert/Model/Ack.swift b/apps/roster/priv/macbert/Model/Ack.swift deleted file mode 100644 index d5706c4af..000000000 --- a/apps/roster/priv/macbert/Model/Ack.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class Ack { - var table: StringAtom? - var id: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/CDR.swift b/apps/roster/priv/macbert/Model/CDR.swift deleted file mode 100644 index 1c4fc833a..000000000 --- a/apps/roster/priv/macbert/Model/CDR.swift +++ /dev/null @@ -1,16 +0,0 @@ - -class CDR { - var id: Int64? - var container: StringAtom? - var feed: AnyObject? - var next: Int64? - var prev: Int64? - var from: String? - var to: String? - var start: Int64? - var stop: Int64? - var type: AnyObject? - var desc: String? - var bill: Int64? - var tariff: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Call.swift b/apps/roster/priv/macbert/Model/Call.swift deleted file mode 100644 index b811320fd..000000000 --- a/apps/roster/priv/macbert/Model/Call.swift +++ /dev/null @@ -1,10 +0,0 @@ - -class Call { - var id: String? - var from: String? - var members: [CallMember]? - var start: Int64? - var stop: Int64? - var vox_url: String? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/CallMember.swift b/apps/roster/priv/macbert/Model/CallMember.swift deleted file mode 100644 index 543a635fa..000000000 --- a/apps/roster/priv/macbert/Model/CallMember.swift +++ /dev/null @@ -1,16 +0,0 @@ - -class CallMember { - var id: Int64? - var feed_id: String? - var prev: Int64? - var next: Int64? - var contact: AnyObject? - var start: Int64? - var stop: Int64? - var type: AnyObject? - var desc: String? - var tariff: String? - var bill: Int64? - var duration: Int64? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Contact.swift b/apps/roster/priv/macbert/Model/Contact.swift deleted file mode 100644 index 89af7d9d3..000000000 --- a/apps/roster/priv/macbert/Model/Contact.swift +++ /dev/null @@ -1,17 +0,0 @@ - -class Contact { - var phone_id: String? - var avatar: String? - var names: String? - var surnames: String? - var nick: String? - var reader: AnyObject? - var unread: Int64? - var last_msg: Message? - var update: Int64? - var created: Int64? - var settings: [Feature]? - var services: [Service]? - var presence: AnyObject? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Cursor.swift b/apps/roster/priv/macbert/Model/Cursor.swift deleted file mode 100644 index 715433bc2..000000000 --- a/apps/roster/priv/macbert/Model/Cursor.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class Cursor { - var feed: AnyObject? - var roster_id: String? - var position: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Desc.swift b/apps/roster/priv/macbert/Model/Desc.swift deleted file mode 100644 index 05ae37264..000000000 --- a/apps/roster/priv/macbert/Model/Desc.swift +++ /dev/null @@ -1,8 +0,0 @@ - -class Desc { - var id: String? - var mime: String? - var payload: String? - var parentid: String? - var data: [Feature]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/ExtendedStar.swift b/apps/roster/priv/macbert/Model/ExtendedStar.swift deleted file mode 100644 index 773d5ccd2..000000000 --- a/apps/roster/priv/macbert/Model/ExtendedStar.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class ExtendedStar { - var star: Star? - var from: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Friend.swift b/apps/roster/priv/macbert/Model/Friend.swift deleted file mode 100644 index 098158c1a..000000000 --- a/apps/roster/priv/macbert/Model/Friend.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class Friend { - var phone_id: String? - var friend_id: String? - var settings: [Feature]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/History.swift b/apps/roster/priv/macbert/Model/History.swift deleted file mode 100644 index ab4f1d13c..000000000 --- a/apps/roster/priv/macbert/Model/History.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class History { - var roster_id: String? - var feed: AnyObject? - var size: Int64? - var entity_id: Int64? - var data: [AnyObject]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Index.swift b/apps/roster/priv/macbert/Model/Index.swift deleted file mode 100644 index 4752fe439..000000000 --- a/apps/roster/priv/macbert/Model/Index.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class Index { - var id: AnyObject? - var roster: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Link.swift b/apps/roster/priv/macbert/Model/Link.swift deleted file mode 100644 index 1b763993d..000000000 --- a/apps/roster/priv/macbert/Model/Link.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class Link { - var id: String? - var name: String? - var room_id: String? - var created: Int64? - var type: AnyObject? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Loc.swift b/apps/roster/priv/macbert/Model/Loc.swift deleted file mode 100644 index 90a23dec7..000000000 --- a/apps/roster/priv/macbert/Model/Loc.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class Loc { - var x: String? - var y: String? - var place_id: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Message.swift b/apps/roster/priv/macbert/Model/Message.swift deleted file mode 100644 index 03e9429d3..000000000 --- a/apps/roster/priv/macbert/Model/Message.swift +++ /dev/null @@ -1,19 +0,0 @@ - -class Message { - var id: Int64? - var container: AnyObject? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var msg_id: String? - var from: String? - var to: String? - var created: Int64? - var files: [Desc]? - var type: [AnyObject]? - var link: AnyObject? - var seenby: [AnyObject]? - var repliedby: [AnyObject]? - var mentioned: [AnyObject]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Person.swift b/apps/roster/priv/macbert/Model/Person.swift deleted file mode 100644 index abba5ccf3..000000000 --- a/apps/roster/priv/macbert/Model/Person.swift +++ /dev/null @@ -1,14 +0,0 @@ - -class Person { - var id: String? - var phonelist: [AnyObject]? - var alias: [AnyObject]? - var localize: [AnyObject]? - var NotificationSettings: [AnyObject]? - var SoundSettings: [AnyObject]? - var ThemeID: String? - var BlockUsers: [AnyObject]? - var balance: Int64? - var isParticipants: [String]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/PushService.swift b/apps/roster/priv/macbert/Model/PushService.swift deleted file mode 100644 index b51d8ef0e..000000000 --- a/apps/roster/priv/macbert/Model/PushService.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class PushService { - var recipients: [AnyObject]? - var id: String? - var ttl: Int64? - var module: String? - var priority: String? - var payload: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Room.swift b/apps/roster/priv/macbert/Model/Room.swift deleted file mode 100644 index 5ecb7eed3..000000000 --- a/apps/roster/priv/macbert/Model/Room.swift +++ /dev/null @@ -1,21 +0,0 @@ - -class Room { - var id: String? - var name: String? - var links: [Link]? - var description: String? - var settings: [Feature]? - var members: [Member]? - var admins: [Member]? - var data: [Desc]? - var type: AnyObject? - var tos: String? - var tos_update: Int64? - var unread: Int64? - var mentions: [AnyObject]? - var readers: [AnyObject]? - var last_msg: AnyObject? - var update: Int64? - var created: Int64? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Search.swift b/apps/roster/priv/macbert/Model/Search.swift deleted file mode 100644 index daeafd5c6..000000000 --- a/apps/roster/priv/macbert/Model/Search.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class Search { - var id: Int64? - var ref: String? - var field: String? - var type: AnyObject? - var value: [AnyObject]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Service.swift b/apps/roster/priv/macbert/Model/Service.swift deleted file mode 100644 index 40de56080..000000000 --- a/apps/roster/priv/macbert/Model/Service.swift +++ /dev/null @@ -1,10 +0,0 @@ - -class Service { - var id: String? - var type: AnyObject? - var data: AnyObject? - var login: String? - var password: String? - var expiration: Int64? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Star.swift b/apps/roster/priv/macbert/Model/Star.swift deleted file mode 100644 index bd39a44ca..000000000 --- a/apps/roster/priv/macbert/Model/Star.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class Star { - var id: Int64? - var client_id: String? - var roster_id: Int64? - var message: Message? - var tags: [Tag]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/StickerPack.swift b/apps/roster/priv/macbert/Model/StickerPack.swift deleted file mode 100644 index fe47f7ecf..000000000 --- a/apps/roster/priv/macbert/Model/StickerPack.swift +++ /dev/null @@ -1,12 +0,0 @@ - -class StickerPack { - var id: Int64? - var name: String? - var keywords: [AnyObject]? - var description: String? - var author: String? - var stickers: [Desc]? - var created: Int64? - var updated: Int64? - var downloaded: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Tag.swift b/apps/roster/priv/macbert/Model/Tag.swift deleted file mode 100644 index 207ca2095..000000000 --- a/apps/roster/priv/macbert/Model/Tag.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class Tag { - var roster_id: String? - var name: String? - var color: String? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Test.swift b/apps/roster/priv/macbert/Model/Test.swift deleted file mode 100644 index 5fc1cf03d..000000000 --- a/apps/roster/priv/macbert/Model/Test.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class Test { - var type: AnyObject? - var count: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Typing.swift b/apps/roster/priv/macbert/Model/Typing.swift deleted file mode 100644 index f37b18267..000000000 --- a/apps/roster/priv/macbert/Model/Typing.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class Typing { - var phone_id: String? - var comments: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Vox.swift b/apps/roster/priv/macbert/Model/Vox.swift deleted file mode 100644 index 613a7ec15..000000000 --- a/apps/roster/priv/macbert/Model/Vox.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class Vox { - var id: String? - var login: String? - var password: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/act.swift b/apps/roster/priv/macbert/Model/act.swift deleted file mode 100644 index aeaa79c8d..000000000 --- a/apps/roster/priv/macbert/Model/act.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class act { - var name: String? - var data: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/amend.swift b/apps/roster/priv/macbert/Model/amend.swift deleted file mode 100644 index 0d08c444e..000000000 --- a/apps/roster/priv/macbert/Model/amend.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class amend { - var id: Int64? - var docs: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/beginEvent.swift b/apps/roster/priv/macbert/Model/beginEvent.swift deleted file mode 100644 index af7d4531b..000000000 --- a/apps/roster/priv/macbert/Model/beginEvent.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class beginEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/boundaryEvent.swift b/apps/roster/priv/macbert/Model/boundaryEvent.swift deleted file mode 100644 index 006afe0fb..000000000 --- a/apps/roster/priv/macbert/Model/boundaryEvent.swift +++ /dev/null @@ -1,11 +0,0 @@ - -class boundaryEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var payload: String? - var timeout: [AnyObject]? - var timeDate: String? - var timeDuration: String? - var timeCycle: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/chain.swift b/apps/roster/priv/macbert/Model/chain.swift deleted file mode 100644 index 14aea4f57..000000000 --- a/apps/roster/priv/macbert/Model/chain.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class chain { - var id: Int64? - var top: Int64? - var rear: Int64? - var count: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/complete.swift b/apps/roster/priv/macbert/Model/complete.swift deleted file mode 100644 index 80eb9dce6..000000000 --- a/apps/roster/priv/macbert/Model/complete.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class complete { - var id: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/container.swift b/apps/roster/priv/macbert/Model/container.swift deleted file mode 100644 index 1ef7e8601..000000000 --- a/apps/roster/priv/macbert/Model/container.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class container { - var id: Int64? - var top: Int64? - var rear: Int64? - var count: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/create.swift b/apps/roster/priv/macbert/Model/create.swift deleted file mode 100644 index a55abc4af..000000000 --- a/apps/roster/priv/macbert/Model/create.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class create { - var proc: AnyObject? - var docs: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/cur.swift b/apps/roster/priv/macbert/Model/cur.swift deleted file mode 100644 index 0ada6dd4d..000000000 --- a/apps/roster/priv/macbert/Model/cur.swift +++ /dev/null @@ -1,10 +0,0 @@ - -class cur { - var id: AnyObject? - var top: Int64? - var bot: Int64? - var dir: AnyObject? - var reader: [AnyObject]? - var writer: [AnyObject]? - var args: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/endEvent.swift b/apps/roster/priv/macbert/Model/endEvent.swift deleted file mode 100644 index 7e0f2b03e..000000000 --- a/apps/roster/priv/macbert/Model/endEvent.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class endEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/error.swift b/apps/roster/priv/macbert/Model/error.swift deleted file mode 100644 index 0bed53727..000000000 --- a/apps/roster/priv/macbert/Model/error.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class error { - var code: StringAtom? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/error2.swift b/apps/roster/priv/macbert/Model/error2.swift deleted file mode 100644 index 12818a9ed..000000000 --- a/apps/roster/priv/macbert/Model/error2.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class error2 { - var code: StringAtom? - var src: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/errors.swift b/apps/roster/priv/macbert/Model/errors.swift deleted file mode 100644 index 690f3d3ef..000000000 --- a/apps/roster/priv/macbert/Model/errors.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class errors { - var code: [AnyObject]? - var data: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/histo.swift b/apps/roster/priv/macbert/Model/histo.swift deleted file mode 100644 index 8e47f43d7..000000000 --- a/apps/roster/priv/macbert/Model/histo.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class histo { - var id: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/io.swift b/apps/roster/priv/macbert/Model/io.swift deleted file mode 100644 index 942786a26..000000000 --- a/apps/roster/priv/macbert/Model/io.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class io { - var code: AnyObject? - var data: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/iter.swift b/apps/roster/priv/macbert/Model/iter.swift deleted file mode 100644 index 9dc2533f7..000000000 --- a/apps/roster/priv/macbert/Model/iter.swift +++ /dev/null @@ -1,8 +0,0 @@ - -class iter { - var id: Int64? - var container: StringAtom? - var feed: AnyObject? - var next: Int64? - var prev: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/iterator.swift b/apps/roster/priv/macbert/Model/iterator.swift deleted file mode 100644 index 81dfcdfdd..000000000 --- a/apps/roster/priv/macbert/Model/iterator.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class iterator { - var id: Int64? - var container: StringAtom? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/join_application.swift b/apps/roster/priv/macbert/Model/join_application.swift deleted file mode 100644 index 1f859baba..000000000 --- a/apps/roster/priv/macbert/Model/join_application.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class join_application { - var id: Int64? - var name: String? - var data: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/log.swift b/apps/roster/priv/macbert/Model/log.swift deleted file mode 100644 index 5edb7154a..000000000 --- a/apps/roster/priv/macbert/Model/log.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class log { - var id: Int64? - var top: Int64? - var rear: Int64? - var count: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/max_tour.swift b/apps/roster/priv/macbert/Model/max_tour.swift deleted file mode 100644 index e34af7549..000000000 --- a/apps/roster/priv/macbert/Model/max_tour.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class max_tour { - var count: Int64? - var joined: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/mqi.swift b/apps/roster/priv/macbert/Model/mqi.swift deleted file mode 100644 index 66aebc732..000000000 --- a/apps/roster/priv/macbert/Model/mqi.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class mqi { - var feed_id: muc? - var query: String? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/muc.swift b/apps/roster/priv/macbert/Model/muc.swift deleted file mode 100644 index 231649474..000000000 --- a/apps/roster/priv/macbert/Model/muc.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class muc { - var name: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/ok2.swift b/apps/roster/priv/macbert/Model/ok2.swift deleted file mode 100644 index 2f2c76cbd..000000000 --- a/apps/roster/priv/macbert/Model/ok2.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class ok2 { - var code: StringAtom? - var src: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/operation.swift b/apps/roster/priv/macbert/Model/operation.swift deleted file mode 100644 index 5525550ed..000000000 --- a/apps/roster/priv/macbert/Model/operation.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class operation { - var id: Int64? - var container: StringAtom? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/p2p.swift b/apps/roster/priv/macbert/Model/p2p.swift deleted file mode 100644 index 326162f9e..000000000 --- a/apps/roster/priv/macbert/Model/p2p.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class p2p { - var from: String? - var to: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/proc.swift b/apps/roster/priv/macbert/Model/proc.swift deleted file mode 100644 index 91b8f6462..000000000 --- a/apps/roster/priv/macbert/Model/proc.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class proc { - var id: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/process.swift b/apps/roster/priv/macbert/Model/process.swift deleted file mode 100644 index 0069d0df1..000000000 --- a/apps/roster/priv/macbert/Model/process.swift +++ /dev/null @@ -1,25 +0,0 @@ - -class process { - var id: Int64? - var container: StringAtom? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? - var name: String? - var roles: [AnyObject]? - var tasks: [AnyObject]? - var events: [AnyObject]? - var hist: AnyObject? - var flows: [sequenceFlow]? - var rules: AnyObject? - var docs: [AnyObject]? - var options: AnyObject? - var task: StringAtom? - var timer: String? - var notifications: AnyObject? - var result: String? - var started: [AnyObject]? - var beginEvent: StringAtom? - var endEvent: StringAtom? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/push.swift b/apps/roster/priv/macbert/Model/push.swift deleted file mode 100644 index 15ffd0257..000000000 --- a/apps/roster/priv/macbert/Model/push.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class push { - var model: AnyObject? - var type: String? - var title: String? - var alert: String? - var badge: Int64? - var sound: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/receiveTask.swift b/apps/roster/priv/macbert/Model/receiveTask.swift deleted file mode 100644 index bdb436a8e..000000000 --- a/apps/roster/priv/macbert/Model/receiveTask.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class receiveTask { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var roles: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/sequenceFlow.swift b/apps/roster/priv/macbert/Model/sequenceFlow.swift deleted file mode 100644 index 2a0e73d3b..000000000 --- a/apps/roster/priv/macbert/Model/sequenceFlow.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class sequenceFlow { - var source: StringAtom? - var target: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/serviceTask.swift b/apps/roster/priv/macbert/Model/serviceTask.swift deleted file mode 100644 index 6927e6da4..000000000 --- a/apps/roster/priv/macbert/Model/serviceTask.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class serviceTask { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var roles: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/task.swift b/apps/roster/priv/macbert/Model/task.swift deleted file mode 100644 index b14868fa7..000000000 --- a/apps/roster/priv/macbert/Model/task.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class task { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var roles: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/timeoutEvent.swift b/apps/roster/priv/macbert/Model/timeoutEvent.swift deleted file mode 100644 index 422e1c9bd..000000000 --- a/apps/roster/priv/macbert/Model/timeoutEvent.swift +++ /dev/null @@ -1,11 +0,0 @@ - -class timeoutEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var payload: String? - var timeout: [AnyObject]? - var timeDate: String? - var timeDuration: String? - var timeCycle: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/tour_list.swift b/apps/roster/priv/macbert/Model/tour_list.swift deleted file mode 100644 index a1d556b22..000000000 --- a/apps/roster/priv/macbert/Model/tour_list.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class tour_list { - var users: [join_application]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/userTask.swift b/apps/roster/priv/macbert/Model/userTask.swift deleted file mode 100644 index ba5eb207e..000000000 --- a/apps/roster/priv/macbert/Model/userTask.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class userTask { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var roles: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/writer.swift b/apps/roster/priv/macbert/Model/writer.swift deleted file mode 100644 index 2aece090e..000000000 --- a/apps/roster/priv/macbert/Model/writer.swift +++ /dev/null @@ -1,8 +0,0 @@ - -class writer { - var id: AnyObject? - var count: Int64? - var cache: [AnyObject]? - var args: AnyObject? - var first: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Source/Bert.swift b/apps/roster/priv/macbert/Source/Bert.swift deleted file mode 100644 index f83117752..000000000 --- a/apps/roster/priv/macbert/Source/Bert.swift +++ /dev/null @@ -1,693 +0,0 @@ -// -// AppDelegate.swift -// Nynja -// -// Created by Anton Makarov on 15.05.17. -// Copyright © 2017 TecSynt Solutions. All rights reserved. -// - -import Foundation - -enum BertError: Error { - case NotValidBertObject - case NotValidErlangTerm - case UnexpectedErlangType - case IntegerValueToLarge - case AtomLengthToLarge -} - -enum BertType: UInt8 { - case Version = 131 - case SmallAtom = 115 - case Atom = 100 - case Binary = 109 - case SmallInteger = 97 - case Integer = 98 - case SmallBig = 110 - // case LargetBig = 111 - // case Float = 99 - case NewFloat = 70 - case String = 107 - // case Port = 102 - // case Pid = 103 - case SmallTuple = 104 - case LargeTuple = 105 - case List = 108 - // case Reference = 101 - // case NewReference = 114 - case Nil = 106 -} - -class BertObject{ - var type: UInt8 = 0 - - var description : String { - get { - return "BertObject" - } - } -} - -class BertAtom: BertObject { - var value = "" - - init (fromString string: String) { - value = string - } - - override var description : String { - get { - if value == "" { - return "[]" - } - return value - } - } -} - -class BertBool: BertObject { - var value: Bool - - init (fromBool b: Bool) { - value = b - } - override var description : String { - get { - if value.description == "" { - return "[]" - } - return value.description - } - } -} - -class BertUndefined: BertAtom { - init () { - super.init(fromString: "undefined") - } - - override var description : String { - get { - if value.description == "" { - return "[]" - } - return value.description - } - } -} - -class BertBinary: BertObject { - var value: NSData - - init (fromNSData d: NSData) { - value = d - } - - override var description : String { - get { - let d = String(data: value as Data, encoding: String.Encoding.utf8) - return d ?? "__Can't GET data__" - } - } -} - -class BertNumber: BertObject { - var value: Int64 - - init (fromUInt8 i: UInt8) { - value = Int64(i) - } - - init (fromInt32 i: Int32) { - value = Int64(i) - } - - init (fromInt64 i: Int64) { - value = i - } - - override var description : String { - get { - return value.description - } - } -} - -class BertFloat: BertObject { - var value: Double - - init (fromDouble d: Double) { - value = d - } - override var description : String { - get { - return value.description - } - } -} - -class BertNil: BertObject { - - override var description : String { - get { - return "NIL" - } - } -} - -class BertString: BertObject { - var value: String - - init (fromString s: String) { - value = s - } - - override var description : String { - get { - return value - } - } -} - -class BertTuple: BertObject { - var elements: [BertObject] - - override var description : String { - get { - var res = "{" - for i in 0.. NSData { - let length = try getEncodeSize(object: object) - var offset: Int = 0 - var data = [UInt8](repeating: 0, count: length + 1) - - data[offset] = BertType.Version.rawValue - offset += 1 - try encodeInner(object: object, data: &data, offset: &offset) - - return NSData(bytes: data, length: length + 1) - } - - class func getObjectClassName(object: BertObject) -> String { - let className = NSStringFromClass(object_getClass(object)!) - let classNameArr = className.components(separatedBy: ".") - - return classNameArr.last! - } - - class func getEncodeSize (object: BertObject) throws -> Int { - switch getObjectClassName(object: object) { - case "BertBool": - let bool = (object as! BertBool) - return 1 + 2 + (bool.value ? 4 : 5) - case "BertUndefined": - return 1 + 2 + 9 - case "BertAtom": - let atom = (object as! BertAtom) - return 1 + 2 + atom.value.characters.count - case "BertBinary": - let binary = (object as! BertBinary) - return 1 + 4 + binary.value.length - case "BertNil": - return 1 - case "BertNumber": - let number = (object as! BertNumber) - if number.value >= 0 && number.value <= 255 { - return 1 + 1 - } - if number.value >= -2147483648 && number.value <= 2147483647 { - return 1 + 4 - } - return 1 + 1 + 8 - case "BertFloat": - return 1 + 8 - case "BertString": - // TODO: implement encoding for length > 0xFF - let string = (object as! BertString) - return 1 + 2 + string.value.characters.count - case "BertTuple": - let tuple = (object as! BertTuple) - var n = 0 - for element in tuple.elements { - n += try getEncodeSize(object: element) - } - return 1 + (tuple.elements.count <= 255 ? 1 : 4) + n - case "BertList": - let list = (object as! BertList) - var n = 0 - for element in list.elements { - n += try getEncodeSize(object: element) - } - return 1 + 4 + 1 + n - default: - throw BertError.UnexpectedErlangType - } - } - - class func encodeInner(object: BertObject, data: inout [UInt8], offset: inout Int) throws { - switch getObjectClassName(object: object) { - case "BertAtom": encodeAtom(atom: object as! BertAtom, data: &data, offset: &offset) - case "BertBool": encodeBool(bool: object as! BertBool, data: &data, offset: &offset) - case "BertUndefined": encodeAtom(atom: object as! BertUndefined, data: &data, offset: &offset) - case "BertBinary": encodeBinary(binary: object as! BertBinary, data: &data, offset: &offset) - case "BertNumber": encodeNumber(number: object as! BertNumber, data: &data, offset: &offset) - case "BertFloat": encodeFloat(float: object as! BertFloat, data: &data, offset: &offset) - case "BertString": encodeString(string: object as! BertString, data: &data, offset: &offset) - case "BertTuple": try encodeTuple(tuple: object as! BertTuple, data: &data, offset: &offset) - case "BertList": try encodeList(list: object as! BertList, data: &data, offset: &offset) - case "BertNil": encodeNil(data: &data, offset: &offset) - default: - throw BertError.UnexpectedErlangType - } - } - - class func encodeAtom(atom: BertAtom, data: inout [UInt8], offset: inout Int) { - let length = UInt16(atom.value.characters.count) - data[offset] = BertType.Atom.rawValue - offset += 1 - writeUInt16(i: length, data: &data, offset: &offset) - - memcpy(&data[offset], (atom.value as NSString).utf8String, Int(length)) - offset += Int(length) - } - - class func encodeBool(bool: BertBool, data: inout [UInt8], offset: inout Int) { - let atom = BertAtom(fromString: (bool.value ? "true" : "false")) - encodeAtom(atom: atom, data: &data, offset: &offset) - } - - class func encodeNil(data: inout [UInt8], offset: inout Int) { - data[offset] = BertType.Nil.rawValue - offset += 1 - // writeUInt16(i: 2, data: &data, offset: &offset) - - //memcpy(&data[offset], (atom.value as NSString).utf8String, 1) - //offset += 1 - } - - class func encodeBinary(binary: BertBinary, data: inout [UInt8], offset: inout Int) { - data[offset] = BertType.Binary.rawValue - offset += 1 - let length = UInt32(binary.value.length) - - writeUInt32(i: length, data: &data, offset: &offset) - - memcpy(&data[offset], binary.value.bytes, Int(length)) - offset += Int(length) - } - - class func encodeNumber(number: BertNumber, data: inout [UInt8], offset: inout Int) { - if number.value >= 0 && number.value <= 255 { - data[offset] = BertType.SmallInteger.rawValue - offset += 1 - data[offset] = UInt8(number.value) - offset += 1 - } else if number.value >= -2147483648 && number.value <= 2147483647 { - data[offset] = BertType.Integer.rawValue - offset += 1 - writeUInt32(i: UInt32(number.value), data: &data, offset: &offset) - } else { - data[offset] = BertType.SmallBig.rawValue - offset += 1 - var i: UInt64 = UInt64(number.value < 0 ? -number.value : number.value) - var n = 0 - var pos = offset + 2 //arity, sign - - while (i > 0) { - data[pos] = UInt8(i % 256) - pos += 1 - i = UInt64(floor(Double(i / 256))) - n += 1 - } - data[offset] = UInt8(n) - offset += 1 - data[offset] = UInt8(Int(number.value < 0 ? 1:0)) - offset += n - } - } - - class func encodeFloat(float: BertFloat, data: inout [UInt8], offset: inout Int) { - data[offset] = BertType.NewFloat.rawValue - offset += 1 - let bytes = withUnsafePointer(to: &float.value) { - $0.withMemoryRebound(to: UInt8.self, capacity: 1, { - Array(UnsafeBufferPointer(start: $0, count: MemoryLayout.size)) - }) - } - var i = UnsafePointer(bytes).withMemoryRebound(to: UInt64.self, capacity: 1) { - $0.pointee - }.bigEndian - - memcpy(&data[offset],&i,MemoryLayout.size) - - offset += 8 - } - - class func encodeString(string: BertString, data: inout [UInt8], offset: inout Int) { - data[offset] = BertType.String.rawValue - offset += 1 - writeUInt16(i: UInt16(string.value.characters.count), data: &data, offset: &offset) - - memcpy(&data[offset], (string.value as NSString).utf8String, string.value.characters.count) - offset += string.value.characters.count - } - - class func encodeTuple(tuple: BertTuple, data: inout [UInt8], offset: inout Int) throws { - if tuple.elements.count <= 255 { - data[offset] = BertType.SmallTuple.rawValue - offset += 1 - data[offset] = UInt8(tuple.elements.count) - offset += 1 - } else { - data[offset] = BertType.LargeTuple.rawValue - offset += 1 - writeUInt32(i: UInt32(tuple.elements.count), data: &data, offset: &offset) - } - - for element in tuple.elements { - try encodeInner(object: element, data: &data, offset: &offset) - } - } - - class func encodeList(list: BertList, data: inout [UInt8], offset: inout Int) throws { - data[offset] = BertType.List.rawValue - offset += 1 - writeUInt32(i: UInt32(list.elements.count), data: &data, offset: &offset) - - for element in list.elements { - try encodeInner(object: element, data: &data, offset: &offset) - } - data[offset] = BertType.Nil.rawValue - offset += 1 - } - - class func writeUInt16(i: UInt16, data: inout [UInt8], offset: inout Int) { - data[offset] = UInt8((i & 0xFF00) >> 8) - offset += 1 - data[offset] = UInt8(i & 0xFF) - offset += 1 - } - - class func writeUInt32(i: UInt32, data: inout [UInt8], offset: inout Int) { - data[offset] = UInt8((i & 0xFF000000) >> 24) - offset += 1 - data[offset] = UInt8((i & 0xFF0000) >> 16) - offset += 1 - data[offset] = UInt8((i & 0xFF00) >> 8) - offset += 1 - data[offset] = UInt8(i & 0xFF) - offset += 1 - } - - class func decode (data: NSData) throws -> BertObject { - if data.length == 0 { - return BertUndefined() - } - - var offset = 0 - var buffer = [UInt8](repeating: 0, count: 1) - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let header = buffer[0] - - if header != BertType.Version.rawValue { - throw BertError.NotValidErlangTerm - } - - var printBuffer = [UInt8](repeating: 0, count: data.length) - data.getBytes(&printBuffer, length: data.length) - - return try decodeInner(data: data, offset: &offset) - } - - class func decodeInner (data: NSData, offset: inout Int) throws -> BertObject { - var buffer = [UInt8](repeating: 0, count: 1) - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - let type = buffer[0] - - switch type { - case BertType.Atom.rawValue: return try decodeAtom(data: data, offset: &offset) - case BertType.SmallAtom.rawValue: return try decodeAtom(data: data, offset: &offset) - case BertType.Binary.rawValue: return decodeBinary(data: data, offset: &offset) - case BertType.SmallInteger.rawValue: return try decodeNumber(data: data, offset: &offset) - case BertType.Integer.rawValue: return try decodeNumber(data: data, offset: &offset) - case BertType.SmallBig.rawValue: return try decodeNumber(data: data, offset: &offset) - case BertType.NewFloat.rawValue: return decodeDouble(data: data, offset: &offset) - case BertType.String.rawValue: return decodeString(data: data, offset: &offset) - case BertType.SmallTuple.rawValue: return try decodeTuple(data: data, offset: &offset) - case BertType.LargeTuple.rawValue: return try decodeTuple(data: data, offset: &offset) - case BertType.List.rawValue: return try decodeList(data: data, offset: &offset) - case BertType.Nil.rawValue: return decodeNil(data: data, offset: &offset) - default: - throw BertError.UnexpectedErlangType - } - } - - class func decodeAtom(data: NSData, offset: inout Int) throws -> BertObject { - var buffer = [UInt8](repeating: 0, count: 2) - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let type = buffer[0] - var n: Int - - switch type { - case BertType.Atom.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 2)) - offset += 2 - let u16 = UnsafePointer(buffer).withMemoryRebound(to: UInt16.self, capacity: 1) { - $0.pointee - } - n = Int(u16.bigEndian) - case BertType.SmallAtom.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - n = Int(buffer[0]) - default: - throw BertError.UnexpectedErlangType - } - - var buffer1 = [UInt8](repeating: 0, count: n) - data.getBytes(&buffer1, range: NSMakeRange(offset, n)) - offset += n - - let value = NSString(bytes: buffer1, length: n, encoding: String.Encoding.utf8.rawValue)! as String - - switch value { - case "true": return BertBool(fromBool: true) - case "false": return BertBool(fromBool: false) - case "undefined": return BertUndefined() - default: return BertAtom(fromString: value) - } - } - - class func decodeBinary(data: NSData, offset: inout Int) -> BertObject { - offset += 1 - - var buffer = [UInt8](repeating: 0, count: 4) - - data.getBytes(&buffer, range: NSMakeRange(offset, 4)) - offset += 4 - let u16 = UnsafePointer(buffer).withMemoryRebound(to: UInt32.self, capacity: 1) { - $0.pointee - } - let length = Int(u16.bigEndian) - var dataBuffer = [UInt8](repeating: 0, count: length) - data.getBytes(&dataBuffer, range: NSMakeRange(offset, length)) - offset += length - - return BertBinary(fromNSData: NSData(bytes: dataBuffer, length: length)) - } - - class func decodeNumber(data: NSData, offset: inout Int) throws -> BertObject { - var buffer = [UInt8](repeating: 0, count: 10) - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let type = buffer[0] - - switch type { - case BertType.SmallInteger.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let value = buffer[0] - return BertNumber(fromUInt8: value) - case BertType.Integer.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 4)) - offset += 4 - let u16 = UnsafePointer(buffer).withMemoryRebound(to: UInt32.self, capacity: 1) { - $0.pointee - } - let value = Int32(u16.bigEndian) - return BertNumber(fromInt32: value) - case BertType.SmallBig.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let arity = buffer[0] - if (arity > 7) { - throw BertError.IntegerValueToLarge - } - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let sign = buffer[0] - - var value: Int64 = 0 - var n: Int64 = 1 - for i in 0...arity-1 { - data.getBytes(&buffer, range:NSMakeRange(offset, 1)) - offset += 1 - let v = Int64(buffer[0]) - value += v * n - if i+1 != arity { - n *= 256 - } - } - - if sign > 0 { - value = -value - } - return BertNumber(fromInt64: Int64(value)) - default: - throw BertError.UnexpectedErlangType - } - } - - class func decodeDouble(data: NSData, offset: inout Int) -> BertObject { - offset += 1 - var buffer = [UInt8](repeating: 0, count: 8) - data.getBytes(&buffer, range: NSMakeRange(offset, 8)) - offset += 8 - var i = Int64(UnsafePointer(buffer).withMemoryRebound(to: UInt64.self, capacity: 1) { - $0.pointee - }.bigEndian) - var d: Double = 0 - memcpy(&d, &i, MemoryLayout.size) - return BertFloat(fromDouble: d) - } - - class func decodeString(data: NSData, offset: inout Int) -> BertObject { - offset += 1 - - var buffer = [UInt8](repeating: 0, count: 2) - data.getBytes(&buffer, range: NSMakeRange(offset, 2)) - offset += 2 - let length = Int(UnsafePointer(buffer).withMemoryRebound(to: UInt16.self, capacity: 1) { - $0.pointee - }.bigEndian) - - var stringBuffer = [UInt8](repeating: 0, count: length) - - data.getBytes(&stringBuffer, range: NSMakeRange(offset, length)) - offset += length - - return BertString(fromString: String(bytes: stringBuffer, encoding: String.Encoding.utf8)!) - } - - class func decodeTuple(data: NSData, offset: inout Int) throws -> BertObject { - var buffer = [UInt8](repeating: 0, count: 4) - var n: Int - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let type = buffer[0] - - switch type { - case BertType.SmallTuple.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - n = Int(buffer[0]) - case BertType.LargeTuple.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 4)) - offset += 4 - n = Int(UnsafePointer(buffer).withMemoryRebound(to: UInt32.self, capacity: 1) { - $0.pointee - }.bigEndian) - default: - throw BertError.UnexpectedErlangType - } - - var elements = [BertObject]() - if n > 0 { - for _ in 0...n-1 { - elements.append(try decodeInner(data: data, offset: &offset)) - } - } - - return BertTuple(fromElements: elements) - } - - class func decodeList(data: NSData, offset: inout Int) throws -> BertObject { - offset+=1 - - var buffer = [UInt8](repeating: 0, count: 4) - - data.getBytes(&buffer, range: NSMakeRange(offset, 4)) - offset += 4 - let n = Int(UnsafePointer(buffer).withMemoryRebound(to: UInt32.self, capacity: 1) { - $0.pointee - }.bigEndian) - var elements = [BertObject]() - if n > 0 { - for _ in 0...n-1 { - elements.append(try decodeInner(data: data, offset: &offset)) - } - } - - if data.length > offset { - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - if (buffer[0] == BertType.Nil.rawValue) { - offset += 1 - } - } - - return BertList(fromElements: elements) - } - - class func decodeNil(data: NSData, offset: inout Int) -> BertObject { - offset += 1 - return BertNil() - } -} diff --git a/apps/roster/priv/macbert/Source/Encoder.swift b/apps/roster/priv/macbert/Source/Encoder.swift deleted file mode 100644 index ab1e97b3b..000000000 --- a/apps/roster/priv/macbert/Source/Encoder.swift +++ /dev/null @@ -1,382 +0,0 @@ -// -// Serializer.swift -// NynjaParser -// -// Created by Anton Makarov on 18.07.2017. -// Copyright © 2017 TecSynt Solutions. All rights reserved. -// - -import Foundation - -func serialize(bert: BertObject?) -> [UInt8]? { - if bert != nil { - do { - let bytes = try Bert.encode(object: bert!) - var result = [UInt8](repeating: 0, count: bytes.length) - bytes.getBytes(&result, length: bytes.length) - return result - } catch { - return nil - } - } - return nil -} - -func stringToBertBinary(input: String?) -> BertObject { - if let data = input?.data(using: String.Encoding.utf8) { - let bert = BertBinary(fromNSData: data as NSData) - return bert - } - return BertNil() -} - -func stringToBertAtom(input: StringAtom?) -> BertObject { - if let str = input?.string { - let bert = BertAtom(fromString: str) - return bert - } - return BertNil() -} - -func listFromObjects(input: [T]?) -> BertObject { - if input == nil { - return BertNil() - } else { - if input!.count == 0 { - return BertNil() - } else { - var result = [BertObject]() - for i in input! { - result.append(serialize(object: i as AnyObject)) - } - return BertList(fromElements: result) - } - } -} - -func numberFromInt64(input: Int64?) -> BertObject { - if let id = input { - return BertNumber(fromInt64: Int64(id)) - } else { - return BertNil() - } -} - - -func serialize(object: AnyObject) -> BertTuple { - var items = [BertObject]() - if let instanse = object as? Approve { - items.append(BertAtom(fromString: "Approve")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.user)) - items.append(stringToBertBinary(input: instanse.room)) - } - if let instanse = object as? ok2 { - items.append(BertAtom(fromString: "ok2")) - if let s = instanse.src { - items.append(BertAtom(fromString: s)) - } else { - items.append(BertNil()) - } - items.append(stringToBertAtom(input: instanse.code)) - } - if let instanse = object as? error2 { - items.append(BertAtom(fromString: "error2")) - if let s = instanse.src { - items.append(BertAtom(fromString: s)) - } else { - items.append(BertNil()) - } - items.append(stringToBertAtom(input: instanse.code)) - } - if let instanse = object as? Auth { - items.append(BertAtom(fromString: "Auth")) - items.append(stringToBertBinary(input: instanse.token)) - items.append(stringToBertBinary(input: instanse.dev_key)) - items.append(stringToBertBinary(input: instanse.user_id)) - items.append(stringToBertBinary(input: instanse.phone)) - items.append(stringToBertBinary(input: instanse.client_id)) - items.append(stringToBertAtom(input: instanse.type)) - items.append(stringToBertBinary(input: instanse.sms_code)) - if let atempts = instanse.attempts { - items.append(BertNumber(fromInt64: Int64(atempts))) - } else { - items.append(BertNil()) - } - if let service = instanse.services { - var result = [BertAtom]() - for i in service { - let atom = BertAtom(fromString: i) - result.append(atom) - } - items.append(BertList(fromElements: result)) - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Confirm { - items.append(BertAtom(fromString: "Confirm")) - items.append(stringToBertBinary(input: instanse.id)) - if let rosterId = instanse.roster_id { - items.append(BertNumber(fromInt64: Int64(rosterId))) - } else { - items.append(BertNil()) - } - items.append(stringToBertBinary(input: instanse.friend_id)) - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Contact { - items.append(BertAtom(fromString: "Contact")) - items.append(stringToBertBinary(input: instanse.phone_id)) - items.append(stringToBertBinary(input: instanse.avatar)) - items.append(stringToBertBinary(input: instanse.names)) - items.append(stringToBertBinary(input: instanse.surnames)) - items.append(stringToBertBinary(input: instanse.person_id)) - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - - } - if let instanse = object as? error { - items.append(BertAtom(fromString: "error")) - if let string = instanse.code as? String { - items.append(stringToBertBinary(input: string)) - } else if let string = instanse.code as? StringAtom { - items.append(stringToBertAtom(input: string)) - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Friend { - items.append(BertAtom(fromString: "Friend")) - items.append(stringToBertBinary(input: instanse.id)) - if let rosterId = instanse.roster_id { - items.append(BertNumber(fromInt64: Int64(rosterId))) - } else { - items.append(BertNil()) - } - items.append(stringToBertBinary(input: instanse.friend_id)) - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - - } - if let instanse = object as? History { - items.append(BertAtom(fromString: "History")) - items.append(stringToBertBinary(input: instanse.roster_id)) - items.append(BertNil()) - if let msgs = instanse.data { - if msgs.count == 0 { - items.append(BertNil()) - } else { - var result = [BertTuple]() - for i in msgs { - result.append(serialize(object: i)) - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - - } - if let instanse = object as? io { - items.append(BertAtom(fromString: "io")) - if let o = instanse.code as? ok { - items.append(serialize(object: o)) - } else if let err = instanse.code as? error { - items.append(serialize(object: err)) - } else if let o2 = instanse.code as? ok2 { - items.append(serialize(object: o2)) - } else if let err2 = instanse.code as? error2 { - items.append(serialize(object: err2)) - } else { - items.append(BertNil()) - } - if let o = instanse.data as? String { - items.append(stringToBertBinary(input: o)) - /* //TODO: Model(value:Tuple(name:"",body:[ - Model(value:Atom()), - Model(value:Chain(types:[ - Model(value:Binary()), - Model(value:Number())]))]))]))]))} */ - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Join { - items.append(BertAtom(fromString: "Join")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.user)) - items.append(stringToBertBinary(input: instanse.room)) - } - if let instanse = object as? Leave { - items.append(BertAtom(fromString: "Leave")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.user)) - items.append(stringToBertBinary(input: instanse.room)) - } - if let instanse = object as? Message { - //TODO: - items.append(BertAtom(fromString: "Message")) - items.append(numberFromInt64(input: instanse.id)) - items.append(stringToBertAtom(input: instanse.container)) - items.append(BertNil()) - items.append(numberFromInt64(input: instanse.prev)) - items.append(numberFromInt64(input: instanse.next)) - items.append(BertNil()) - items.append(stringToBertBinary(input: instanse.msg_id)) - items.append(stringToBertBinary(input: instanse.from)) - items.append(stringToBertBinary(input: instanse.to)) - items.append(BertNil()) - items.append(BertNil()) - items.append(BertNil()) - items.append(BertNil()) - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - - } - if let instanse = object as? ok { - items.append(BertAtom(fromString: "ok")) - if let string = instanse.code as? String { - items.append(stringToBertBinary(input: string)) - } else if let string = instanse.code as? StringAtom { - items.append(stringToBertAtom(input: string)) - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Person { - //TODO: - items.append(BertAtom(fromString: "Person")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.names)) - items.append(stringToBertBinary(input: instanse.surnames)) - items.append(stringToBertBinary(input: instanse.username)) - items.append(BertNil()) - items.append(BertNil()) - items.append(stringToBertBinary(input: instanse.avatar)) - items.append(BertNil()) - items.append(BertNil()) - items.append(BertNil()) - items.append(stringToBertBinary(input: instanse.ThemeID)) - items.append(stringToBertBinary(input: instanse.voxImplantID)) - items.append(BertNil()) - items.append(numberFromInt64(input: instanse.balance)) - if let isParticipants = instanse.isParticipants { - if isParticipants.count == 0 { - items.append(BertNil()) - } else { - var result = [BertObject]() - for i in isParticipants { - if let j = stringToBertBinary(input: i) as? BertBinary { - result.append(j) - } - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - items.append(stringToBertAtom(input: instanse.status)) - } - if let instanse = object as? Profile { - items.append(BertAtom(fromString: "Profile")) - items.append(stringToBertBinary(input: instanse.phone)) - items.append(stringToBertBinary(input: instanse.data)) - items.append(stringToBertBinary(input: instanse.person_id)) - if let accounts = instanse.accounts as? [Roster] { - if accounts.count == 0 { - items.append(BertNil()) - } else { - var result = [BertTuple]() - for i in accounts { - result.append(serialize(object: i)) - } - items.append(BertList(fromElements: result)) - } - } else if let accounts = instanse.accounts as? [Int64] { - if accounts.count == 0 { - items.append(BertNil()) - } else { - var result = [BertNumber]() - for i in accounts { - if let n = numberFromInt64(input: i) as? BertNumber { - result.append(n) - } - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - items.append(stringToBertAtom(input: instanse.status)) - } - if let instanse = object as? Revoke { - items.append(BertAtom(fromString: "Revoke")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.user)) - items.append(stringToBertAtom(input: instanse.status)) - } - if let instanse = object as? Room { - items.append(BertAtom(fromString: "Room")) - items.append(stringToBertBinary(input: instanse.desc)) - items.append(listFromObjects(input: instanse.acl)) - items.append(listFromObjects(input: instanse.settings)) - } - if let instanse = object as? Roster { - items.append(BertAtom(fromString: "Roster")) - items.append(numberFromInt64(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.names)) - items.append(stringToBertBinary(input: instanse.surnames)) - items.append(numberFromInt64(input: instanse.size)) - if let userlist = instanse.userlist { - if userlist.count == 0 { - items.append(BertNil()) - } else { - var result = [BertTuple]() - for i in userlist { - result.append(serialize(object: i)) - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - if let roomlist = instanse.roomlist { - if roomlist.count == 0 { - items.append(BertNil()) - } else { - var result = [BertTuple]() - for i in roomlist { - result.append(serialize(object: i)) - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - items.append(BertNil()) //TODO - - } - if let instanse = object as? Typing { - - } - return BertTuple(fromElements: items) -} diff --git a/apps/roster/priv/macbert/Source/StringAtom.swift b/apps/roster/priv/macbert/Source/StringAtom.swift deleted file mode 100644 index 916adf2e5..000000000 --- a/apps/roster/priv/macbert/Source/StringAtom.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// StringAtom.swift -// macbert -// -// Created by Anton Makarov on 19.07.2017. -// Copyright © 2017 TecSynt Solutions. All rights reserved. -// - -import Foundation - -class StringAtom { - var string: String? = nil - init(string: String) { - self.string = string - } -} diff --git a/apps/roster/priv/macbert/Source/TypeSpec.swift b/apps/roster/priv/macbert/Source/TypeSpec.swift deleted file mode 100644 index 1c9fc6a90..000000000 --- a/apps/roster/priv/macbert/Source/TypeSpec.swift +++ /dev/null @@ -1,376 +0,0 @@ -// -// Model.swift -// Nynja -// -// Created by Anton Makarov on 11.07.2017. -// Copyright © 2017 TecSynt Solutions. All rights reserved. -// - -import Foundation -protocol Parsable { func parse(bert: BertObject) -> Any? } - -enum SelectType { - case chain - case tuple - case binary - case atom - case number - case list - case boolean -} - -class Model: Parsable { - var chain: Chain? - var tuple: Tuple? - var binary: Binary? - var number: Number? - var atom: Atom? - var list: List? - var boolean: Boolean? - var select: SelectType! - - init(value: Chain) { self.select = .chain; self.chain = value; } - init(value: Tuple) { self.select = .tuple; self.tuple = value; } - init(value: Atom) { self.select = .atom; self.atom = value; } - init(value: Binary) { self.select = .binary; self.binary = value; } - init(value: Number) { self.select = .number; self.number = value; } - init(value: List) { self.select = .list; self.list = value; } - init(value: Boolean){ self.select = .boolean;self.boolean = value;} - - var description : String { - get { - switch select! { - case .atom: - return atom!.description - case .binary: - return binary!.description - case .chain: - return chain!.description - case .number: - return number!.description - case .tuple: - return tuple!.description - case .list: - return list!.description - case .boolean: - return boolean!.description - } - } - } - func parse(bert: BertObject) -> Any? { - switch select! { - case .atom: - return atom!.parse(bert:bert) - case .binary: - return binary!.parse(bert:bert) - case .chain: - return chain!.parse(bert:bert) - case .number: - return number!.parse(bert:bert) - case .tuple: - return tuple!.parse(bert:bert) - case .list: - return list!.parse(bert: bert) - case .boolean: - return boolean!.parse(bert:bert) - } - } -} - -class Boolean: Parsable { - - func parse(bert: BertObject) -> Any? { - if let bool = bert as? BertBool { - return bool.value - } - return nil - } - - var description : String { - get { - return "Bool()" - } - } -} - - -func parse(bert: BertObject) -> Any? -{ - if let object = bert as? BertAtom { - return object.value - } - if let object = bert as? BertTuple { - var result = [Any]() - for i in object.elements { - if let any = parse(bert: i) { - result.append(any) - } - } - return result - } - if let _ = bert as? BertNil { - return [Any]() - } - if let object = bert as? BertBool { - return object.value as AnyObject - } - if let object = bert as? BertList { - var result = [Any]() - for i in object.elements { - if let any = parse(bert: i) { - result.append(any) - } - } - return result - } - if let object = bert as? BertString { - return object.value - } - if let object = bert as? BertBinary { - return object.value - } - if let object = bert as? BertNumber { - return object.value - } - if let object = bert as? BertFloat { - return object.value - } - return nil -} - - -class Tuple: Parsable { - var name: String? - var body: [Model]? - init(name: String? = nil , body: [Model]? = nil) { self.name = name; self.body = body;} - - func parse(bert: BertObject) -> Any? { - if let tuple = bert as? BertTuple { - if body == nil { - var result = [Any]() - for i in 0.. Any? { - if let const = constant { - if let string = bert as? BertString { - if string.value == const { - return const - } - } - } else { - if let list = bert as? BertList { - if let result = self.addToList(list: list) { - return result - } - } - } - return nil - } - - func addToList(list: BertList) -> [Any]? { - var result = [Any]() - if let mod = model { - for i in list.elements { - if let value = mod.parse(bert: i) { - result.append(value) - } else { - return nil - } - } - } else { - var result = [Any]() - for i in 0.. Any? { - if let atom = bert as? BertAtom { - if let const = constant { - if atom.value == const { - return StringAtom(string:atom.value) - } - } else { - return StringAtom(string:atom.value) - } - } - return nil - } - - var description : String { - get { - return constant ?? "Atom()" - } - } -} - - -class Binary: Parsable { - var constant: String? - init() { constant = nil } - init(constant: String) { self.constant = constant } - func parse(bert: BertObject) -> Any? { - if let bin = bert as? BertBinary { - if let const = constant { - let dataString = String(data: bin.value as Data, encoding: String.Encoding.utf8) - if dataString == const { - return String(data: bin.value as Data, encoding: String.Encoding.utf8) - } - } else { - - return String(data: bin.value as Data, encoding: String.Encoding.utf8) - } - } - return nil - } - var description : String { - get { - return constant ?? "Binary()" - } - } -} - -class Number: Parsable { - var constant: String? - init() { constant = nil } - init(constant: String) { self.constant = constant } - func parse(bert: BertObject) -> Any? { - if let num = bert as? BertNumber { - if let const = constant { - if const == "\(num.value)" { - return Int64(num.value) - } - } else { - return Int64(num.value) - } - } - return nil - } - var description : String { - get { - return constant ?? "Number()" - } - } -} - - -class Chain: Parsable { - var types: [Model]! - init(types: [Model]) { self.types = types } - - func parse(bert: BertObject) -> Any? { - for model in types { - if let obj = model.parse(bert: bert) { - return obj - } - } - return nil - } - - - var description : String { - get { - var text = "" - for i in 0.. Model { - return Model(value:Tuple(name:"Ack",body:[ - Model(value:Atom()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/CDR_Spec.swift b/apps/roster/priv/macbert/Spec/CDR_Spec.swift deleted file mode 100644 index 1e714c03c..000000000 --- a/apps/roster/priv/macbert/Spec/CDR_Spec.swift +++ /dev/null @@ -1,38 +0,0 @@ -func get_CDR() -> Model { - return Model(value:Tuple(name:"CDR",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"pstn")), - Model(value:Atom(constant:"inet"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/CallMember_Spec.swift b/apps/roster/priv/macbert/Spec/CallMember_Spec.swift deleted file mode 100644 index 8eb9ab141..000000000 --- a/apps/roster/priv/macbert/Spec/CallMember_Spec.swift +++ /dev/null @@ -1,48 +0,0 @@ -func get_CallMember() -> Model { - return Model(value:Tuple(name:"CallMember",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - get_Contact(), - get_Member()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"pstn")), - Model(value:Atom(constant:"inet"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"new")), - Model(value:Atom(constant:"join")), - Model(value:Atom(constant:"leave")), - Model(value:Atom(constant:"miss")), - Model(value:Atom(constant:"cancel")), - Model(value:Atom(constant:"active")), - Model(value:Atom(constant:"finish"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Call_Spec.swift b/apps/roster/priv/macbert/Spec/Call_Spec.swift deleted file mode 100644 index d827f117d..000000000 --- a/apps/roster/priv/macbert/Spec/Call_Spec.swift +++ /dev/null @@ -1,24 +0,0 @@ -func get_Call() -> Model { - return Model(value:Tuple(name:"Call",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil,model:get_CallMember())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"start")), - Model(value:Atom(constant:"cancel")), - Model(value:Atom(constant:"active")), - Model(value:Atom(constant:"finish"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Cursor_Spec.swift b/apps/roster/priv/macbert/Spec/Cursor_Spec.swift deleted file mode 100644 index 8cadac044..000000000 --- a/apps/roster/priv/macbert/Spec/Cursor_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_Cursor() -> Model { - return Model(value:Tuple(name:"Cursor",body:[ - Model(value:Chain(types:[ - get_muc(), - get_p2p()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/ExtendedStar_Spec.swift b/apps/roster/priv/macbert/Spec/ExtendedStar_Spec.swift deleted file mode 100644 index 45d891a2a..000000000 --- a/apps/roster/priv/macbert/Spec/ExtendedStar_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_ExtendedStar() -> Model { - return Model(value:Tuple(name:"ExtendedStar",body:[ - Model(value:Chain(types:[ - get_Star(), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - get_Contact(), - get_Room(), - Model(value:List(constant:""))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Friend_Spec.swift b/apps/roster/priv/macbert/Spec/Friend_Spec.swift deleted file mode 100644 index 34ced364e..000000000 --- a/apps/roster/priv/macbert/Spec/Friend_Spec.swift +++ /dev/null @@ -1,14 +0,0 @@ -func get_Friend() -> Model { - return Model(value:Tuple(name:"Friend",body:[ - Model(value:Binary()), - Model(value:Binary()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"ban")), - Model(value:Atom(constant:"unban")), - Model(value:Atom(constant:"request")), - Model(value:Atom(constant:"confirm")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"ignore"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/History_Spec.swift b/apps/roster/priv/macbert/Spec/History_Spec.swift deleted file mode 100644 index 879fccf91..000000000 --- a/apps/roster/priv/macbert/Spec/History_Spec.swift +++ /dev/null @@ -1,38 +0,0 @@ -func get_History() -> Model { - return Model(value:Tuple(name:"History",body:[ - Model(value:Binary()), - Model(value:Chain(types:[ - get_p2p(), - get_muc(), - get_act(), - get_StickerPack(), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_Message(), - get_Job(), - get_StickerPack()]))))])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"updated")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"last_loaded")), - Model(value:Atom(constant:"last_msg")), - Model(value:Atom(constant:"get_reply")), - Model(value:Atom(constant:"double_get")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"image")), - Model(value:Atom(constant:"video")), - Model(value:Atom(constant:"file")), - Model(value:Atom(constant:"link")), - Model(value:Atom(constant:"audio")), - Model(value:Atom(constant:"contact")), - Model(value:Atom(constant:"location")), - Model(value:Atom(constant:"text"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Index_Spec.swift b/apps/roster/priv/macbert/Spec/Index_Spec.swift deleted file mode 100644 index 9f7e4a1f6..000000000 --- a/apps/roster/priv/macbert/Spec/Index_Spec.swift +++ /dev/null @@ -1,6 +0,0 @@ -func get_Index() -> Model { - return Model(value:Tuple(name:"Index",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))))]))} diff --git a/apps/roster/priv/macbert/Spec/Link_Spec.swift b/apps/roster/priv/macbert/Spec/Link_Spec.swift deleted file mode 100644 index 35c091fac..000000000 --- a/apps/roster/priv/macbert/Spec/Link_Spec.swift +++ /dev/null @@ -1,27 +0,0 @@ -func get_Link() -> Model { - return Model(value:Tuple(name:"Link",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"group")), - Model(value:Atom(constant:"channel"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"gen")), - Model(value:Atom(constant:"check")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"join")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"delete"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Loc_Spec.swift b/apps/roster/priv/macbert/Spec/Loc_Spec.swift deleted file mode 100644 index 561dadfc1..000000000 --- a/apps/roster/priv/macbert/Spec/Loc_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_Loc() -> Model { - return Model(value:Tuple(name:"Loc",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/Person_Spec.swift b/apps/roster/priv/macbert/Spec/Person_Spec.swift deleted file mode 100644 index c72d2314a..000000000 --- a/apps/roster/priv/macbert/Spec/Person_Spec.swift +++ /dev/null @@ -1,15 +0,0 @@ -func get_Person() -> Model { - return Model(value:Tuple(name:"Person",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil, model:Model(value:Binary()))), - Model(value:List(constant:nil)), - Model(value:List(constant:nil)), - Model(value:List(constant:nil)), - Model(value:List(constant:nil)), - Model(value:Binary()), - Model(value:List(constant:nil, model:Model(value:Binary()))), - Model(value:Number()), - Model(value:List(constant:nil, model:Model(value:Atom()))), - Model(value:List(constant:""))]))} diff --git a/apps/roster/priv/macbert/Spec/PushService_Spec.swift b/apps/roster/priv/macbert/Spec/PushService_Spec.swift deleted file mode 100644 index 02fe4dd8f..000000000 --- a/apps/roster/priv/macbert/Spec/PushService_Spec.swift +++ /dev/null @@ -1,18 +0,0 @@ -func get_PushService() -> Model { - return Model(value:Tuple(name:"PushService",body:[ - Model(value:List(constant:nil, model:Model(value:Binary()))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/Search_Spec.swift b/apps/roster/priv/macbert/Spec/Search_Spec.swift deleted file mode 100644 index c5be4d12b..000000000 --- a/apps/roster/priv/macbert/Spec/Search_Spec.swift +++ /dev/null @@ -1,16 +0,0 @@ -func get_Search() -> Model { - return Model(value:Tuple(name:"Search",body:[ - Model(value:Number()), - Model(value:Binary()), - Model(value:Binary()), - Model(value:Chain(types:[ - Model(value:Atom(constant:"==")), - Model(value:Atom(constant:"!=")), - Model(value:Atom(constant:"like"))])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])))), - Model(value:Chain(types:[ - Model(value:Atom(constant:"profile")), - Model(value:Atom(constant:"roster")), - Model(value:Atom(constant:"contact")), - Model(value:Atom(constant:"member")), - Model(value:Atom(constant:"room"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Service_Spec.swift b/apps/roster/priv/macbert/Spec/Service_Spec.swift deleted file mode 100644 index 3360f9955..000000000 --- a/apps/roster/priv/macbert/Spec/Service_Spec.swift +++ /dev/null @@ -1,26 +0,0 @@ -func get_Service() -> Model { - return Model(value:Tuple(name:"Service",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"email")), - Model(value:Atom(constant:"vox")), - Model(value:Atom(constant:"aws")), - Model(value:Atom(constant:"wallet"))])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"verified")), - Model(value:Atom(constant:"added")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"remove"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/StickerPack_Spec.swift b/apps/roster/priv/macbert/Spec/StickerPack_Spec.swift deleted file mode 100644 index a37abc69a..000000000 --- a/apps/roster/priv/macbert/Spec/StickerPack_Spec.swift +++ /dev/null @@ -1,19 +0,0 @@ -func get_StickerPack() -> Model { - return Model(value:Tuple(name:"StickerPack",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil, model:Model(value:Binary()))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil,model:get_Desc())), - Model(value:Number()), - Model(value:Number()), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/Tag_Spec.swift b/apps/roster/priv/macbert/Spec/Tag_Spec.swift deleted file mode 100644 index 4f9ae9504..000000000 --- a/apps/roster/priv/macbert/Spec/Tag_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_Tag() -> Model { - return Model(value:Tuple(name:"Tag",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Binary()), - Model(value:Binary()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"create")), - Model(value:Atom(constant:"remove")), - Model(value:Atom(constant:"edit"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Test_Spec.swift b/apps/roster/priv/macbert/Spec/Test_Spec.swift deleted file mode 100644 index 08e0dc24b..000000000 --- a/apps/roster/priv/macbert/Spec/Test_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_Test() -> Model { - return Model(value:Tuple(name:"Test",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"message")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/Typing_Spec.swift b/apps/roster/priv/macbert/Spec/Typing_Spec.swift deleted file mode 100644 index 41ceda8a5..000000000 --- a/apps/roster/priv/macbert/Spec/Typing_Spec.swift +++ /dev/null @@ -1,4 +0,0 @@ -func get_Typing() -> Model { - return Model(value:Tuple(name:"Typing",body:[ - Model(value:Binary()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Vox_Spec.swift b/apps/roster/priv/macbert/Spec/Vox_Spec.swift deleted file mode 100644 index ad63c47cf..000000000 --- a/apps/roster/priv/macbert/Spec/Vox_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_Vox() -> Model { - return Model(value:Tuple(name:"Vox",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/act_Spec.swift b/apps/roster/priv/macbert/Spec/act_Spec.swift deleted file mode 100644 index 91273021b..000000000 --- a/apps/roster/priv/macbert/Spec/act_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_act() -> Model { - return Model(value:Tuple(name:"act",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:Binary()), - Model(value:Number()), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))))]))]))} diff --git a/apps/roster/priv/macbert/Spec/amend_Spec.swift b/apps/roster/priv/macbert/Spec/amend_Spec.swift deleted file mode 100644 index 7a08766c3..000000000 --- a/apps/roster/priv/macbert/Spec/amend_Spec.swift +++ /dev/null @@ -1,8 +0,0 @@ -func get_amend() -> Model { - return Model(value:Tuple(name:"amend",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Tuple())))]))]))} diff --git a/apps/roster/priv/macbert/Spec/beginEvent_Spec.swift b/apps/roster/priv/macbert/Spec/beginEvent_Spec.swift deleted file mode 100644 index f7eefc2ee..000000000 --- a/apps/roster/priv/macbert/Spec/beginEvent_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_beginEvent() -> Model { - return Model(value:Tuple(name:"beginEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple())))]))} diff --git a/apps/roster/priv/macbert/Spec/chain_Spec.swift b/apps/roster/priv/macbert/Spec/chain_Spec.swift deleted file mode 100644 index f492b041c..000000000 --- a/apps/roster/priv/macbert/Spec/chain_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_chain() -> Model { - return Model(value:Tuple(name:"chain",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/complete_Spec.swift b/apps/roster/priv/macbert/Spec/complete_Spec.swift deleted file mode 100644 index 3f6ac99bc..000000000 --- a/apps/roster/priv/macbert/Spec/complete_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_complete() -> Model { - return Model(value:Tuple(name:"complete",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/container_Spec.swift b/apps/roster/priv/macbert/Spec/container_Spec.swift deleted file mode 100644 index ea52d6cf2..000000000 --- a/apps/roster/priv/macbert/Spec/container_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_container() -> Model { - return Model(value:Tuple(name:"container",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/create_Spec.swift b/apps/roster/priv/macbert/Spec/create_Spec.swift deleted file mode 100644 index 40aeb3b46..000000000 --- a/apps/roster/priv/macbert/Spec/create_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_create() -> Model { - return Model(value:Tuple(name:"create",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - get_process(), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Tuple())))]))]))} diff --git a/apps/roster/priv/macbert/Spec/cur_Spec.swift b/apps/roster/priv/macbert/Spec/cur_Spec.swift deleted file mode 100644 index 1594fc906..000000000 --- a/apps/roster/priv/macbert/Spec/cur_Spec.swift +++ /dev/null @@ -1,21 +0,0 @@ -func get_cur() -> Model { - return Model(value:Tuple(name:"cur",body:[ - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:Number(constant:"0")), - Model(value:Number(constant:"1"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple())])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - Model(value:Tuple()), - Model(value:Number())]))))]))} diff --git a/apps/roster/priv/macbert/Spec/endEvent_Spec.swift b/apps/roster/priv/macbert/Spec/endEvent_Spec.swift deleted file mode 100644 index 9cd2fe816..000000000 --- a/apps/roster/priv/macbert/Spec/endEvent_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_endEvent() -> Model { - return Model(value:Tuple(name:"endEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple())))]))} diff --git a/apps/roster/priv/macbert/Spec/error2_Spec.swift b/apps/roster/priv/macbert/Spec/error2_Spec.swift deleted file mode 100644 index 1e8be3701..000000000 --- a/apps/roster/priv/macbert/Spec/error2_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_error2() -> Model { - return Model(value:Tuple(name:"error2",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/error_Spec.swift b/apps/roster/priv/macbert/Spec/error_Spec.swift deleted file mode 100644 index 838420e66..000000000 --- a/apps/roster/priv/macbert/Spec/error_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_error() -> Model { - return Model(value:Tuple(name:"error",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())]))]))} diff --git a/apps/roster/priv/macbert/Spec/errors_Spec.swift b/apps/roster/priv/macbert/Spec/errors_Spec.swift deleted file mode 100644 index 4fb43f80a..000000000 --- a/apps/roster/priv/macbert/Spec/errors_Spec.swift +++ /dev/null @@ -1,8 +0,0 @@ -func get_errors() -> Model { - return Model(value:Tuple(name:"errors",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Binary())))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))]))} diff --git a/apps/roster/priv/macbert/Spec/histo_Spec.swift b/apps/roster/priv/macbert/Spec/histo_Spec.swift deleted file mode 100644 index 1d8c29ee0..000000000 --- a/apps/roster/priv/macbert/Spec/histo_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_histo() -> Model { - return Model(value:Tuple(name:"histo",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/iter_Spec.swift b/apps/roster/priv/macbert/Spec/iter_Spec.swift deleted file mode 100644 index 478e58d57..000000000 --- a/apps/roster/priv/macbert/Spec/iter_Spec.swift +++ /dev/null @@ -1,13 +0,0 @@ -func get_iter() -> Model { - return Model(value:Tuple(name:"iter",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/iterator_Spec.swift b/apps/roster/priv/macbert/Spec/iterator_Spec.swift deleted file mode 100644 index e902370ae..000000000 --- a/apps/roster/priv/macbert/Spec/iterator_Spec.swift +++ /dev/null @@ -1,14 +0,0 @@ -func get_iterator() -> Model { - return Model(value:Tuple(name:"iterator",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil))]))} diff --git a/apps/roster/priv/macbert/Spec/join_application_Spec.swift b/apps/roster/priv/macbert/Spec/join_application_Spec.swift deleted file mode 100644 index db985eaa0..000000000 --- a/apps/roster/priv/macbert/Spec/join_application_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_join_application() -> Model { - return Model(value:Tuple(name:"join_application",body:[ - Model(value:Number()), - Model(value:Binary()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))} diff --git a/apps/roster/priv/macbert/Spec/log_Spec.swift b/apps/roster/priv/macbert/Spec/log_Spec.swift deleted file mode 100644 index dd14f37db..000000000 --- a/apps/roster/priv/macbert/Spec/log_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_log() -> Model { - return Model(value:Tuple(name:"log",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/max_tour_Spec.swift b/apps/roster/priv/macbert/Spec/max_tour_Spec.swift deleted file mode 100644 index 237c71183..000000000 --- a/apps/roster/priv/macbert/Spec/max_tour_Spec.swift +++ /dev/null @@ -1,4 +0,0 @@ -func get_max_tour() -> Model { - return Model(value:Tuple(name:"max_tour",body:[ - Model(value:Number()), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/mqi_Spec.swift b/apps/roster/priv/macbert/Spec/mqi_Spec.swift deleted file mode 100644 index 1dd03ebcc..000000000 --- a/apps/roster/priv/macbert/Spec/mqi_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_mqi() -> Model { - return Model(value:Tuple(name:"mqi",body:[ - get_muc(), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"admin")), - Model(value:Atom(constant:"member")), - Model(value:Atom(constant:"removed"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/muc_Spec.swift b/apps/roster/priv/macbert/Spec/muc_Spec.swift deleted file mode 100644 index 6074d67af..000000000 --- a/apps/roster/priv/macbert/Spec/muc_Spec.swift +++ /dev/null @@ -1,3 +0,0 @@ -func get_muc() -> Model { - return Model(value:Tuple(name:"muc",body:[ - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/ok2_Spec.swift b/apps/roster/priv/macbert/Spec/ok2_Spec.swift deleted file mode 100644 index 59c2675c1..000000000 --- a/apps/roster/priv/macbert/Spec/ok2_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_ok2() -> Model { - return Model(value:Tuple(name:"ok2",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple(name:nil,body:[ - Model(value:Binary()), - Model(value:Binary())])), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/operation_Spec.swift b/apps/roster/priv/macbert/Spec/operation_Spec.swift deleted file mode 100644 index d799e38c5..000000000 --- a/apps/roster/priv/macbert/Spec/operation_Spec.swift +++ /dev/null @@ -1,14 +0,0 @@ -func get_operation() -> Model { - return Model(value:Tuple(name:"operation",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil))]))} diff --git a/apps/roster/priv/macbert/Spec/p2p_Spec.swift b/apps/roster/priv/macbert/Spec/p2p_Spec.swift deleted file mode 100644 index b175ecd9f..000000000 --- a/apps/roster/priv/macbert/Spec/p2p_Spec.swift +++ /dev/null @@ -1,4 +0,0 @@ -func get_p2p() -> Model { - return Model(value:Tuple(name:"p2p",body:[ - Model(value:Binary()), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/proc_Spec.swift b/apps/roster/priv/macbert/Spec/proc_Spec.swift deleted file mode 100644 index 6f1007830..000000000 --- a/apps/roster/priv/macbert/Spec/proc_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_proc() -> Model { - return Model(value:Tuple(name:"proc",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/process_Spec.swift b/apps/roster/priv/macbert/Spec/process_Spec.swift deleted file mode 100644 index e9c7e0513..000000000 --- a/apps/roster/priv/macbert/Spec/process_Spec.swift +++ /dev/null @@ -1,56 +0,0 @@ -func get_process() -> Model { - return Model(value:Tuple(name:"process",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil)), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil)), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_task(), - get_serviceTask(), - get_userTask(), - get_receiveTask()])))), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_messageEvent(), - get_boundaryEvent(), - get_timeoutEvent()])))), - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_sequenceFlow())), - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple(name:nil,body:[ - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())]))]))} diff --git a/apps/roster/priv/macbert/Spec/push_Spec.swift b/apps/roster/priv/macbert/Spec/push_Spec.swift deleted file mode 100644 index ef9a76e40..000000000 --- a/apps/roster/priv/macbert/Spec/push_Spec.swift +++ /dev/null @@ -1,20 +0,0 @@ -func get_push() -> Model { - return Model(value:Tuple(name:"push",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/sequenceFlow_Spec.swift b/apps/roster/priv/macbert/Spec/sequenceFlow_Spec.swift deleted file mode 100644 index bc21a8ebe..000000000 --- a/apps/roster/priv/macbert/Spec/sequenceFlow_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_sequenceFlow() -> Model { - return Model(value:Tuple(name:"sequenceFlow",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom()), - Model(value:List(constant:nil, model:Model(value:Atom())))]))]))} diff --git a/apps/roster/priv/macbert/Spec/timeoutEvent_Spec.swift b/apps/roster/priv/macbert/Spec/timeoutEvent_Spec.swift deleted file mode 100644 index c4b03fdc2..000000000 --- a/apps/roster/priv/macbert/Spec/timeoutEvent_Spec.swift +++ /dev/null @@ -1,29 +0,0 @@ -func get_timeoutEvent() -> Model { - return Model(value:Tuple(name:"timeoutEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Number()), - Model(value:Number())]))]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/tour_list_Spec.swift b/apps/roster/priv/macbert/Spec/tour_list_Spec.swift deleted file mode 100644 index 01c5825fe..000000000 --- a/apps/roster/priv/macbert/Spec/tour_list_Spec.swift +++ /dev/null @@ -1,3 +0,0 @@ -func get_tour_list() -> Model { - return Model(value:Tuple(name:"tour_list",body:[ - Model(value:List(constant:nil,model:get_join_application()))]))} diff --git a/apps/roster/priv/macbert/Spec/writer_Spec.swift b/apps/roster/priv/macbert/Spec/writer_Spec.swift deleted file mode 100644 index 2fb05c68a..000000000 --- a/apps/roster/priv/macbert/Spec/writer_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_writer() -> Model { - return Model(value:Tuple(name:"writer",body:[ - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Number()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple())])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple())]))]))} diff --git a/apps/roster/priv/macbert/main.swift b/apps/roster/priv/macbert/main.swift deleted file mode 100644 index 9dc998a13..000000000 --- a/apps/roster/priv/macbert/main.swift +++ /dev/null @@ -1,43 +0,0 @@ - -import Foundation - -/* func test3() { - let bin: [UInt8] = [131,104,11,100,0,6,82,111,115,116,101,114,97,63,109,0,0, - 0,5,65,110,116,111,110,109,0,0,0,1,77,97,1,108,0,0,0,1, - 104,7,100,0,7,67,111,110,116,97,99,116,109,0,0,0,15,51, - 56,48,57,57,52,51,56,50,55,57,56,95,54,51,106,106,106, - 106,106,106,106,100,0,4,116,114,117,101,109,0,0,0,12,51, - 56,48,57,57,52,51,56,50,55,57,56,109,0,0,0,25,104,116, - 116,112,58,47,47,97,118,97,116,97,114,46,99,111,109,47, - 97,118,97,46,112,110,103,100,0,5,112,97,116,99,104] - let data = NSData(bytes: bin, length: bin.count) - do { - let bert = try Bert.decode(data: data) - if let roster = get_Roster().parse(bert: bert) as? Roster { - print("parsed") - } - } catch { - print("I Can't parse Bin to Bert") - } - -} */ - - -//test3() - - -func testProfile() { - let bin: [UInt8] = [131, 104, 7, 100, 0, 7, 80, 114, 111, 102, 105, 108, 101, 109, 0, 0, 0, 12, 51, 56, 48, 54, 51, 50, 56, 56, 57, 56, 57, 48, 106, 109, 0, 0, 0, 14, 51, 56, 48, 54, 51, 50, 56, 56, 57, 56, 57, 48, 95, 52, 108, 0, 0, 0, 1, 104, 12, 100, 0, 6, 82, 111, 115, 116, 101, 114, 97, 4, 106, 106, 97, 1, 108, 0, 0, 0, 1, 104, 10, 100, 0, 7, 67, 111, 110, 116, 97, 99, 116, 109, 0, 0, 0, 14, 51, 56, 48, 54, 51, 50, 56, 56, 57, 56, 57, 48, 95, 52, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 100, 0, 4, 116, 114, 117, 101, 109, 0, 0, 0, 12, 51, 56, 48, 54, 51, 50, 56, 56, 57, 56, 57, 48, 106, 106, 106, 106, 106, 100, 0, 3, 103, 101, 116] - let data = NSData(bytes: bin, length: bin.count) - do { - let bert = try Bert.decode(data: data) - if let profile = get_Profile().parse(bert: bert) { - print("parsed") - } - } catch { - print("I Can't parse Bin to Bert") - } -} - -testProfile() - diff --git a/apps/roster/src/processes/job.erl b/apps/roster/src/processes/job.erl index 77a4f9b4c..49c339edd 100644 --- a/apps/roster/src/processes/job.erl +++ b/apps/roster/src/processes/job.erl @@ -49,14 +49,14 @@ action({request,'Action'}, #process{id=Id, options=Opts}=Proc) -> %job_process:get_proc(Id,pos), case bpe:doc(#'Schedule'{},Proc) of #'Schedule'{data = <<"stop">>} -> {reply,'Stop',Proc}; - #'Schedule'{id=Time, data = []} -> catch n2o_async:pid(system,roster_bpe) ! {next, Proc, Time}, + #'Schedule'{id=Time, data = []} -> catch n2o_pi:pid(system,roster_bpe) ! {next, Proc, Time}, {reply,'Stop',Proc}; #'Schedule'{id=Time}=Sh when Time/=[] -> Timeout=Time-roster:now_msec(), case Timeout-CTimeout of T when T =<3*?QUANT -> %io:format("Pub ~p, ~p ~n", [Id,Timeout]), - catch n2o_async:pid(system,roster_bpe) ! {publish, Proc}, + catch n2o_pi:pid(system,roster_bpe) ! {publish, Proc}, {reply,'Stop',Proc}; - T -> catch n2o_async:pid(system,roster_bpe) ! {timeout, Sh, Timeout}, + T -> catch n2o_pi:pid(system,roster_bpe) ! {timeout, Sh, Timeout}, {reply,'Timeout',Proc} end; _ -> {reply,'Stop',Proc} end; @@ -64,8 +64,8 @@ action({request,'Action'}, #process{id=Id, options=Opts}=Proc) -> action({request,'Final'}, #process{id=Id, options=Opt}=Proc) -> io:format(" Final~n"), %roster:send_event(C, <<>>, <<>>, #'Job'{id=Id, status=delete}), - %n2o_async:pid(system,roster_bpe) ! #'Job'{id=Id, status=delete}, - n2o_async:pid(system,roster_bpe) ! {clean, Proc#process{}}, + %n2o_pi:pid(system,roster_bpe) ! #'Job'{id=Id, status=delete}, + n2o_pi:pid(system,roster_bpe) ! {clean, Proc#process{}}, {reply,Proc}. @@ -80,7 +80,7 @@ worker(#process{id=Id}=P) -> worker_do({Days,Time},P) when Days >= 14 -> skip; worker_do({Days,Time},#process{id=Id}=P) when P#process.task =:= 'Action' -> -% catch n2o_async:pid(system,roster_bpe) ! {restart, P}, +% catch n2o_pi:pid(system,roster_bpe) ! {restart, P}, bpe:start(P, []), %bpe:complite(Id), kvs:info(?MODULE,"BPE Start: ~p~n",[Id]); diff --git a/apps/roster/src/protocol/micro_auth.erl b/apps/roster/src/protocol/micro_auth.erl index 3d00ee7c4..8c7e44781 100644 --- a/apps/roster/src/protocol/micro_auth.erl +++ b/apps/roster/src/protocol/micro_auth.erl @@ -9,7 +9,7 @@ -compile(export_all). start() -> - n2o_async:start(#handler{module = micro_auth, class = system, group = roster, name = micro_auth, state = []}). + n2o_pi:start(#pi{module = micro_auth, table = system, sup = roster, name = micro_auth, state = []}). init([Listeners]) -> {ok, Listeners}. description() -> "Micro Authentication Module". @@ -31,7 +31,7 @@ check(#mqtt_client{client_id = <<"emqttd_", _/binary>> = ClientId, username = << {ok, AccUuid} -> emqttd_client:subscribe(ClientPid, [{roster:action_topic(ClientId), 2}]), PhoneId = micro:uuid_to_id('LinkRoster', AccUuid), - AuthPid = n2o_async:pid(system, ?MODULE), + AuthPid = n2o_pi:pid(system, ?MODULE), Ver = binary_to_list(BVer), case kvs:get('Auth', ClientId) of {ok, #'Auth'{user_id = PhoneId} = Auth} -> diff --git a/apps/roster/src/protocol/micro_roster.erl b/apps/roster/src/protocol/micro_roster.erl index 336d02974..5a2bd7593 100644 --- a/apps/roster/src/protocol/micro_roster.erl +++ b/apps/roster/src/protocol/micro_roster.erl @@ -4,7 +4,7 @@ -include_lib("n2o/include/n2o.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Roster'{status = add, phone = LinkPhone, id = LinkRosterId} = Roster, Req, #cx{params = <<"sys_", _/binary>> = ClientId} = State) -> diff --git a/apps/roster/src/protocol/roster_auth.erl b/apps/roster/src/protocol/roster_auth.erl index fdc1d85d7..0070fd796 100644 --- a/apps/roster/src/protocol/roster_auth.erl +++ b/apps/roster/src/protocol/roster_auth.erl @@ -16,9 +16,9 @@ -define(CHECK_FAKE_NUMBERS, application:get_env(roster, fake_numbers_check, false)). start() -> - n2o_async:start(#handler{module = roster_auth, class = system, group = roster, name = roster_auth, state = []}). + n2o_pi:start(#pi{module = roster_auth, table = system, sup = roster, name = roster_auth, state = []}). stop() -> - n2o_async:stop(system, roster_auth). + n2o_pi:stop(system, roster_auth). init([Listeners]) -> {ok, Listeners}. description() -> "Roster Authentication Module". diff --git a/apps/roster/src/protocol/roster_bpe.erl b/apps/roster/src/protocol/roster_bpe.erl index f7a4acc71..ae575beb3 100644 --- a/apps/roster/src/protocol/roster_bpe.erl +++ b/apps/roster/src/protocol/roster_bpe.erl @@ -12,7 +12,7 @@ -define(JOBS_MS_LIMIT, 500). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'History'{roster_id = Roster, feed = Feed, size = N, entity_id = MId, status = get} = Data, Req, #cx{params = ClientId} = State) -> @@ -72,7 +72,7 @@ info(#'Job'{id = [], feed_id = {act, <<"publish">>, PhoneId} = Feed, time = [], %J = J0#'Job'{id = Id = kvs:next_id('Job', 1)}, Replay = case roster:phone_id(ClientId) of PhoneId -> %roster:restart_module(Pid,?MODULE), - n2o_async:pid(system, ?MODULE) ! {send, Msgs}, <<>>; + n2o_pi:pid(system, ?MODULE) ! {send, Msgs}, <<>>; _ -> roster_channel_helper:error_response_400(RequestData) %% #io{code = #error{code = invalid_data}} end, @@ -108,7 +108,7 @@ info(#'Job'{id = [], feed_id = {act, <<"publish">>, PhoneId} = Feed, time = Time {J0#'Job'{time = round(Time / ?QUANT) * ?QUANT, context = NewR}, {0, 0}}; _ -> {J0#'Job'{time = round(Time / ?QUANT) * ?QUANT}, {0, 0}} end, - catch n2o_async:pid(system, ?MODULE) ! {update, J#'Job'{container = chain, data = D, status = pending}, Context, S}, + catch n2o_pi:pid(system, ?MODULE) ! {update, J#'Job'{container = chain, data = D, status = pending}, Context, S}, <<>>; _ -> roster_channel_helper:error_response_400(J0) %% #io{code = #error{code = invalid_data}} @@ -131,11 +131,11 @@ info(#'Job'{id = Id, time = T0, feed_id = {act, <<"publish">>, PhoneId} = Feed, {ok, #'Schedule'{id = SID, data = Data} = Sh} when abs(Time - OldTime) > 2 * ?QUANT, NData /= 0 -> case Data--[{'Job', Id}] of [] -> kvs:delete('Schedule', SID); ND -> kvs:put(Sh#'Schedule'{data = ND}) end, - n2o_async:pid(system, ?MODULE) ! {update, NewJ, {OldTime, 0}, S}, <<>>; + n2o_pi:pid(system, ?MODULE) ! {update, NewJ, {OldTime, 0}, S}, <<>>; {ok, #'Schedule'{}} when NData /= 0 -> kvs:put(NewJ), roster:send_ses(C, roster:phone(PhoneId), NewJ#'Job'{status = update}), <<>>; - _ when NData /= 0 -> n2o_async:pid(system, ?MODULE) ! {update, NewJ, {OldTime, 0}, S}, + _ when NData /= 0 -> n2o_pi:pid(system, ?MODULE) ! {update, NewJ, {OldTime, 0}, S}, <<>>; __________ -> roster_channel_helper:error_response_400(RequestData) %% #io{code = #error{code = invalid_data}} @@ -355,7 +355,7 @@ proc({clean, #'process'{id = Id} = P}, #handler{state = {C, Proc}} = H) -> proc({send, Msgs}, #handler{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC send", []), roster:restart_module(C,roster_bpe), -% [case kvs:get(mqtt_session, roster:get_vnode(Msg)) of {ok,#mqtt_session{sess_pid = Pid}} -> n2o_async:send(Pid,{publish, , Msg}); _ -> skip end || Msg = #'Message'{} <- Msgs], +% [case kvs:get(mqtt_session, roster:get_vnode(Msg)) of {ok,#mqtt_session{sess_pid = Pid}} -> n2o_pi:send(Pid,{publish, , Msg}); _ -> skip end || Msg = #'Message'{} <- Msgs], [begin roster:send_event(C, <<"sys_bpe">>, <<>>, Msg, roster:get_vnode(<<"sys_bpe">>,Msg)),timer:sleep(5) end || Msg = #'Message'{} <- Msgs], {reply, [], H#handler{state = {C, Proc}}}; @@ -364,7 +364,7 @@ proc({mqttc, C, connected}, State = #handler{state = {C, Proc}, seq = S}) -> {ok proc({mqttc, _C, disconnected}, State) -> {ok, State}. -publish(Proc) -> n2o_async:pid(system, ?MODULE) ! {publish, bpe:load(Proc)}. +publish(Proc) -> n2o_pi:pid(system, ?MODULE) ! {publish, bpe:load(Proc)}. restart_bpe(#process{id = Id} = P, _C) -> try case bpe:find_pid(Id) of diff --git a/apps/roster/src/protocol/roster_friend.erl b/apps/roster/src/protocol/roster_friend.erl index 5f206dac5..0580b965e 100644 --- a/apps/roster/src/protocol/roster_friend.erl +++ b/apps/roster/src/protocol/roster_friend.erl @@ -5,7 +5,7 @@ -include_lib("kvs/include/kvs.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Friend'{phone_id = Me, friend_id = Friend, status = request}, {Req, handled}, #cx{params = ClientId, client_pid = C} = State) -> @@ -25,7 +25,7 @@ info(#'Friend'{phone_id = Me, friend_id = Friend, status = request}, {Req, handl _Remote = roster:add_contacts(FromR, [Friendc]), roster:send_ses(C, To, roster:presence(#'Contact'{reader = Rs} = roster:readmsgs(Mec, Friend))), roster:send_ses(C, From, roster:presence(Friendc#'Contact'{reader = lists:reverse(Rs)})), - n2o_async:pid(system, ?MODULE) ! {send_push, Me, Friend, <<"request">>}, + n2o_pi:pid(system, ?MODULE) ! {send_push, Me, Friend, <<"request">>}, roster:info(?MODULE, "~p:~p:Friend/request:~p", [Me, ClientId, Friend]), <<>> end, @@ -88,7 +88,7 @@ info(#'Friend'{friend_id = Friend, status = confirm}, Req, #cx{params = ClientId [n2o_vnode:subscribe(Client, Topic) || Client <- Tos ++ Froms], roster:send_ses(C, To, Mec2 = roster:presence(#'Contact'{reader = Rs} = roster:readmsgs(Mec#'Contact'{update = Now, created = Now, unread = 1}, Friend))), roster:send_ses(C, From, roster:presence(Friendc#'Contact'{update = Now, created = Now, unread = 1, reader = lists:reverse(Rs)})), - n2o_async:pid(system, ?MODULE) ! {send_push, Mec2, Friend, <<"friend">>}, + n2o_pi:pid(system, ?MODULE) ! {send_push, Mec2, Friend, <<"friend">>}, {io, Local, Remote}; _ -> #io{code = #error{code = invalid_data}} end, diff --git a/apps/roster/src/protocol/roster_ftp.erl b/apps/roster/src/protocol/roster_ftp.erl index 4f19f9a44..b19208a16 100644 --- a/apps/roster/src/protocol/roster_ftp.erl +++ b/apps/roster/src/protocol/roster_ftp.erl @@ -45,14 +45,14 @@ info(#ftp{id = Link, status = <<"init">>, block = Block, offset = Offset} = FTP, Offset2 = case FileSize >= Offset of true -> FileSize; false -> 0 end, FTP2 = FTP#ftp{block = Block2, offset = Offset2, data = <<>>}, - n2o_async:stop(file, Link), - n2o_async:start(#handler{module = ?MODULE, class = file, group = n2o, state = FTP2, name = Link}), + n2o_pi:stop(file, Link), + n2o_pi:start(#pi{module = ?MODULE, table = file, sup = n2o, state = FTP2, name = Link}), {reply, {bert, FTP2}, Req, State}; info(#ftp{id = Link, status = <<"send">>} = FTP, Req, State) -> roster:info(?MODULE, "Info Send: ~p", [FTP#ftp{data = <<>>}]), - Reply = try gen_server:call(n2o_async:pid({file, Link}), FTP) + Reply = try gen_server:call(n2o_pi:pid({file, Link}), FTP) catch E:R -> skip, roster:info(?MODULE, "Info Error call the sync: ~p", [{E, R}]), FTP#ftp{data = <<>>, block = ?STOP} end, @@ -80,7 +80,7 @@ proc(#ftp{id = Link, sid = Sid, data = Data, status = <<"send">>, block = Block, FTP2 = FTP#ftp{data = <<>>, block = ?STOP}, FTP3 = FTP2#ftp{status = {event, stop}, filename = RelPath}, n2o_ring:send({publish, <<"events/1//index/anon/", ClientId/binary, "/", Sid/binary>>, term_to_binary(FTP3)}), - spawn(fun() -> n2o_async:stop(file, Link) end), + spawn(fun() -> n2o_pi:stop(file, Link) end), {stop, normal, FTP2, Async#handler{state = FTP2}}; _ -> {reply, {error, S3_Data}, Async} diff --git a/apps/roster/src/protocol/roster_history.erl b/apps/roster/src/protocol/roster_history.erl index 8dabf2e3e..b9158ed4c 100644 --- a/apps/roster/src/protocol/roster_history.erl +++ b/apps/roster/src/protocol/roster_history.erl @@ -4,7 +4,7 @@ -include_lib("kvs/include/kvs.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). -define(HISTORY_UPDATE_ACTION, <<"history_update">>). -define(HISTORY_DELETE_ACTION, <<"history_delete">>). @@ -185,7 +185,7 @@ info(#'History'{status = update, feed = Feed, entity_id = MId}, Req, end, Res = roster:update_field(Record, [{unread, Unread}, {reader, Readers }, {readers, Readers }, {status, last_msg}]), roster:send_ses(C, From, Res), - n2o_async:pid(system, ?MODULE) ! {send_push, PhoneId, Feed, ?HISTORY_UPDATE_ACTION}, + n2o_pi:pid(system, ?MODULE) ! {send_push, PhoneId, Feed, ?HISTORY_UPDATE_ACTION}, <<>>; false -> Unread end, @@ -207,7 +207,7 @@ info(#'History'{feed = Feed, status = delete}, Req, #cx{client_pid = C, params = %% D=case is_integer(Unread) of true -> roster:send_ses(C, From, roster:update_field(FList,Record,unread,Unread)), <<>>; false -> Unread end, roster:send_feed(C, Feed, roster:readmsgs(Internal#'Message'{next = []}, PhoneId)), %% send push if no history clean error occured - n2o_async:pid(system, ?MODULE) ! {send_push, PhoneId, Feed, ?HISTORY_DELETE_ACTION}, + n2o_pi:pid(system, ?MODULE) ! {send_push, PhoneId, Feed, ?HISTORY_DELETE_ACTION}, <<>>; {I,_} -> I end, {reply, {bert, IO}, Req, State}; diff --git a/apps/roster/src/protocol/roster_message.erl b/apps/roster/src/protocol/roster_message.erl index 6cbc3972b..595f77b02 100644 --- a/apps/roster/src/protocol/roster_message.erl +++ b/apps/roster/src/protocol/roster_message.erl @@ -10,7 +10,7 @@ -define(MSG_EDIT_ACTION, <<"message_edit">>). -define(MSG_DELETE_ACTION, <<"message_delete">>). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Typing'{phone_id = Phone, comments = Comments}, Req, #cx{} = State) -> @@ -98,7 +98,7 @@ info(#'Message'{status = [], id = [], feed_id = F, from=From0, to = To, roster:info(?MODULE, "~p:Message/new:~p", [From, To]), %% have to skip push notifications for call bubbles case [lists:keyfind(BubbleContentType, #'Desc'.mime, Descs) || BubbleContentType <- [?CONTENT_TYPE_VIDEOCALL, ?CONTENT_TYPE_AUDIOCALL]] of - [false, false] -> n2o_async:pid(system, ?MODULE) ! {send_push, From, To, Msg2, []}; + [false, false] -> n2o_pi:pid(system, ?MODULE) ! {send_push, From, To, Msg2, []}; _ -> skip end, <<>> @@ -147,7 +147,7 @@ info(#'Message'{status = edit, id = Id, msg_id = ClMID, feed_id = Feed, from = F %% move cursor kvs_stream:save(R = kvs_stream:top(kvs_stream:load_reader(Reader))), roster:put_readers(write_top, Ent, R), - n2o_async:pid(system, ?MODULE) ! {send_push, From1, To1, Internal, ?MSG_EDIT_ACTION}, + n2o_pi:pid(system, ?MODULE) ! {send_push, From1, To1, Internal, ?MSG_EDIT_ACTION}, %% publish roster:send_feed(C, Feed, Internal), <<>> end, @@ -230,7 +230,7 @@ info(#'Message'{id = Id, msg_id = ClMID, feed_id = Feed, from = From0, seenby = n2o_vnode:send(C, Topic, term_to_binary(Internal)), %% NOTE! send push about deleted msg only if acted user is in the seenby case Seen of [-1] -> - n2o_async:pid(system, ?MODULE) ! {send_push, From1, To1, Internal, ?MSG_DELETE_ACTION}; _ -> + n2o_pi:pid(system, ?MODULE) ! {send_push, From1, To1, Internal, ?MSG_DELETE_ACTION}; _ -> skip end, case {Type, Link} of {[reply], Link} when is_integer(Link) andalso NewSeen == [-1] -> @@ -250,7 +250,7 @@ info(#'Message'{status = update, id = Id, files = [#'Desc'{mime = <<"transcribe" when is_integer(Id), not is_tuple(Req)-> Type = case roster:get_data_val(<<"TYPE">>, Data) of [] -> short; T -> binary_to_atom(T, utf8) end, Lang = roster:get_data_val(?LANG_KEY, Data), - Pid = n2o_async:pid(system, roster_message), + Pid = n2o_pi:pid(system, roster_message), case kvs:get('Message', Id) of {ok, #'Message'{files = [#'Desc'{mime = <<"audio">>, payload = Uri}|_]}} when Type == short -> spawn(fun() -> diff --git a/apps/roster/src/protocol/roster_profile.erl b/apps/roster/src/protocol/roster_profile.erl index eb8fe4de4..4d6085413 100644 --- a/apps/roster/src/protocol/roster_profile.erl +++ b/apps/roster/src/protocol/roster_profile.erl @@ -3,7 +3,7 @@ -include_lib("n2o/include/n2o.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module=?MODULE,class=system,group=roster,name=?MODULE,state=[]}). +start() -> n2o_pi:start(#pi{module=?MODULE,table=system,sup=roster,name=?MODULE,state=[]}). %%info(#'Profile'{phone=Phone, rosters=Rosters, status=set} = Data, Req, %% #cx{params = ClientId} = State) -> diff --git a/apps/roster/src/protocol/roster_push.erl b/apps/roster/src/protocol/roster_push.erl index 961ea4961..fc368765f 100644 --- a/apps/roster/src/protocol/roster_push.erl +++ b/apps/roster/src/protocol/roster_push.erl @@ -4,7 +4,7 @@ -include_lib("kvs/include/kvs.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). proc(init, #handler{name = ?MODULE} = Async) -> roster:info(?MODULE, "ASYNC", []), diff --git a/apps/roster/src/protocol/roster_room.erl b/apps/roster/src/protocol/roster_room.erl index 22e7622ac..ea3a5ecbd 100644 --- a/apps/roster/src/protocol/roster_room.erl +++ b/apps/roster/src/protocol/roster_room.erl @@ -9,7 +9,7 @@ -define(MAX_ROOM_LENGTH, 32). -define(MIN_ROOM_LENGTH, 1). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Room'{status = create, id = Room, admins = [Admin|_], type=Type} = R, Req, #cx{state = verified} = State) -> @@ -65,7 +65,7 @@ info(#'Room'{status = patch, id = Room, name = Name, data = AvatarDesc} = R, Req files = [#'Desc'{payload = iolist_to_binary([?SYS_MSG_UPDATE_GROUP_NAME, " \"", NewName, "\""])}], type = [sys], status = []}, roster:get_reader(RoomFeed, PId)), roster:send_room(C, Room, NewNameMsg), - n2o_async:pid(system, ?MODULE) ! {send_push, [], NewNameMsg, name}, + n2o_pi:pid(system, ?MODULE) ! {send_push, [], NewNameMsg, name}, NewNameLastMsgId; _ -> StoredLastMsgId end, @@ -82,7 +82,7 @@ info(#'Room'{status = patch, id = Room, name = Name, data = AvatarDesc} = R, Req #'Desc'{payload = AvatarPayload, mime = AvatarMime}], type = [sys], status = []}, roster:get_reader(RoomFeed, PId)), roster:send_room(C, Room, NewAvatarMsg), - n2o_async:pid(system, ?MODULE) ! {send_push, [], NewAvatarMsg, photo}, + n2o_pi:pid(system, ?MODULE) ! {send_push, [], NewAvatarMsg, photo}, NewAvatarLastMsgId; _ -> NameLastMsgId end; @@ -191,7 +191,7 @@ info(#'Room'{status = St, id = Room, members = Members, admins = Admins, readers to = Room, msg_id = roster:msg_id(), files = [#'Desc'{payload = Payload}]}, Reader), {_, PutRoom} = roster:put_readers(write_top, AdmMember, R), - n2o_async:pid(system, ?MODULE) ! {send_push, NewMmbrs, Msg, RStatus2}, + n2o_pi:pid(system, ?MODULE) ! {send_push, NewMmbrs, Msg, RStatus2}, {PutRoom#'Room'{last_msg = Msg}, PutRoom#'Room'{last_msg = Msg#'Message'.id}} end, R5 = R3#'Room'{status = RStatus2, members = Members2, admins = Admins3, links=[roster_link:get_link({ok,R3})]}, [ begin roster:send_ses(C, roster:phone(PhId), @@ -245,7 +245,7 @@ info(#'Room'{status = remove, members = Members, admins = Admins0, id = Room}, R roster:send_room(C, R2), [roster:send_ses(C, roster:phone(PhoneId), Rec) || #'Member'{phone_id = PhoneId} <- Mmbrs, Rec <- [R2, Msg]], - n2o_async:pid(system, ?MODULE) ! {send_push, Mmbrs, Msg, remove}, + n2o_pi:pid(system, ?MODULE) ! {send_push, Mmbrs, Msg, remove}, roster:send_room(C, Room, Msg); #'Member'{} -> #io{code = #error{code = permission_denied}}; _ -> #io{code = #error{code = member_not_found}} end; @@ -301,7 +301,7 @@ info(#'Room'{status = leave, id = Room}, Req, #cx{params = ClientId, client_pid roster:send_room(C, R), [roster:cache_ses(PId, R)|| #'Member'{phone_id = PId} <-roster:members(#muc{name = Room}, active)], roster:send_room(C, Room, Msg), - n2o_async:pid(system, ?MODULE) ! {send_push, [], Msg, leave}, + n2o_pi:pid(system, ?MODULE) ! {send_push, [], Msg, leave}, Room2#'Room'{update = roster:now_msec(), last_msg = Msg#'Message'.id} end, kvs:put(M#'Member'{reader = 0, update = roster:now_msec(), status = removed}), diff --git a/apps/roster/src/protocol/roster_roster.erl b/apps/roster/src/protocol/roster_roster.erl index b509a392d..aebe8a8b5 100644 --- a/apps/roster/src/protocol/roster_roster.erl +++ b/apps/roster/src/protocol/roster_roster.erl @@ -7,7 +7,7 @@ -define(MIN_NAME_LENGTH, 2). -define(MIN_SURNAME_LENGTH, 1). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Roster'{status = patch, avatar = Avatar} = Data, Req, #cx{params = ClientId, client_pid = C, @@ -25,7 +25,7 @@ info(#'Roster'{status = patch, avatar = Avatar} = Data, Req, roster:send_ac(C, PhoneId, NewC#'Contact'{unread = []}), roster:send_ses(C, Phone, UpdRoster#'Roster'{userlist = [NewC#'Contact'{presence = online}], roomlist = [], favorite = []}), - n2o_async:send(system, ?MODULE, {update_ac, NewC}), + n2o_pi:send(system, ?MODULE, {update_ac, NewC}), %% TODO clarify logic of update user/member info case Avatar of OldAvatar -> skip; [] -> skip; _ -> [case roster:muc_member(PhoneId, Room) of @@ -97,10 +97,10 @@ info(#'Roster'{nick = NickToBeValidated, status = nick} = Data, Req, #cx{params %% index processing case NickLow of OldNickLow -> skip; - <<>> -> n2o_async:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}); + <<>> -> n2o_pi:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}); _ -> - n2o_async:send(system, ?MODULE, {update_index, #'Roster'{id = ActedRosterId, nick = NickLow}}), - n2o_async:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}) + n2o_pi:send(system, ?MODULE, {update_index, #'Roster'{id = ActedRosterId, nick = NickLow}}), + n2o_pi:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}) end, %% NOTE! Pay attention! Copypaste from Roster/Patch, need to check [NewC] = roster:to_contact([ActedRosterId], friend), @@ -108,7 +108,7 @@ info(#'Roster'{nick = NickToBeValidated, status = nick} = Data, Req, #cx{params PhoneId = roster:phone_id(Phone, ActedRosterId), roster:send_ac(C, PhoneId, UpdNewC), roster:send_ses(C, Phone, UpdRoster#'Roster'{userlist = [UpdNewC#'Contact'{presence = online}], roomlist = [], favorite = []}), - n2o_async:send(system, ?MODULE, {update_ac, UpdNewC}), + n2o_pi:send(system, ?MODULE, {update_ac, UpdNewC}), <<>>; true -> roster:info(?MODULE, "Debug.GotNickAlreadyUsedError", []), diff --git a/apps/roster/src/protocol/roster_search.erl b/apps/roster/src/protocol/roster_search.erl index 2a403d391..7df6301dd 100644 --- a/apps/roster/src/protocol/roster_search.erl +++ b/apps/roster/src/protocol/roster_search.erl @@ -3,7 +3,7 @@ -include_lib("n2o/include/n2o.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Search'{id = FromRosterId, ref = Ref, field = <<"link">>, type = '==', value = SearchVal, status = room}, Req, #cx{params = <<"emqttd_",_/binary>> = ClientId} = State) -> diff --git a/apps/roster/src/rest/rest_push.erl b/apps/roster/src/rest/rest_push.erl index 21fb0cf1c..2f3b3d843 100644 --- a/apps/roster/src/rest/rest_push.erl +++ b/apps/roster/src/rest/rest_push.erl @@ -21,7 +21,7 @@ handle_request('POST', _, Req) -> #'PushService'{payload = Payload, recipients = Recipient, module = Module} = 'PushServiceRest':from_json(jsx:decode(ReqBody), #'PushService'{}), %% also server should make all values from string to binary because erlang works with binary() data PushAlert = PushType = list_to_binary(Module), - [[n2o_async:pid(system, roster_push) ! {async_push, Auth, list_to_binary(Payload), PushAlert, PushType} + [[n2o_pi:pid(system, roster_push) ! {async_push, Auth, list_to_binary(Payload), PushAlert, PushType} || Auth <- kvs:index('Auth', user_id, PhoneId)] || PhoneId <- list_elements_to_binary(Recipient)], ?HTTP_CODE_200 end, diff --git a/apps/roster/src/roster.app.src b/apps/roster/src/roster.app.src index e5ed15838..6cf6b237f 100644 --- a/apps/roster/src/roster.app.src +++ b/apps/roster/src/roster.app.src @@ -1,7 +1,29 @@ {application, roster, - [{description, "Roster Protocol"}, - {vsn, "1"}, - {registered, []}, - {applications, [kernel,stdlib,mnesia,kvs,emqttd,n2o,bpe,locus,prometheus,libphonenumber_erlang]}, - {mod, { roster, []}}, - {env, []} ]}. + [ + {description, "Roster Protocol"}, + {vsn, "1"}, + {registered, []}, + {applications, + [ + kernel, + stdlib, + mnesia, + kvs, + ibrowse, + mimerl, + enenra, + hackney, + idna, + metrics, + unicode_util_compat, + emqttd, + n2o, + bpe, + locus, + prometheus, + libphonenumber_erlang + ]}, + {mod, { roster, []}}, + {env, []} + ] +}. diff --git a/apps/roster/src/roster.erl b/apps/roster/src/roster.erl index 36406a262..806d83ec9 100644 --- a/apps/roster/src/roster.erl +++ b/apps/roster/src/roster.erl @@ -447,7 +447,7 @@ on_client_disconnected(_Reason, _Client = #mqtt_client{}, _Env) -> ok. on_disconnect(<<"emqttd_", _/binary>> = ClientId) -> info(roster_auth, "~p:CLIENT DISCONNECT",[ClientId]), case kvs:get('Auth', ClientId) of - {ok, Auth} -> n2o_async:pid(system, roster_auth) ! {disconnect, Auth}, + {ok, Auth} -> n2o_pi:pid(system, roster_auth) ! {disconnect, Auth}, kvs:put(Auth#'Auth'{last_online = now_msec()}); _ -> skip end, ok. @@ -562,16 +562,21 @@ add_message(#'Message'{} = Msg, Reader) -> integer() | #reader{}, integer() | binary() | #'Member'{}) -> {integer() | binary(), #'Message'{} | update, [integer()]}. + +%% TODO: A temporary solution unread_msg({error, _}, _, _) -> {0, [], []}; unread_msg(_, {error, _}, _) -> {0, [], []}; unread_msg(#writer{cache = #'Message'{id = MaxReadId, type = [sys|_]} = LastMsg} = Writer, #reader{cache = {'Message', ReadMsgId}, pos = 0} = Reader, #'Member'{id = UID, status = removed}) when ReadMsgId /= [], ReadMsgId >= MaxReadId -> - GetFun = - fun (_T, MaxReadId, _D) -> {ok, LastMsg#'Message'{seenby = []}}; - (T, Id, D) -> kvs:get(T, Id, D) - end, + GetFun = fun(T, Id, D) -> + case Id of + N when MaxReadId /= [], MaxReadId >= N-> + {ok, LastMsg#'Message'{seenby = []}}; + _-> kvs:get(T, Id, D) + end + end, unread_msg(Writer#writer{cache = LastMsg}, Reader#reader{cache = {'Message', MaxReadId}}, UID, GetFun); unread_msg(#writer{} = Writer, #reader{} = Reader, #'Member'{id = UID}) -> unread_msg(Writer, Reader, UID); @@ -1956,7 +1961,7 @@ check(Module) -> case lists:all(fun(X) -> X == ok end, Module:suite()) of n2o_pid(Name) -> - case n2o_async:pid(system, Name) of + case n2o_pi:pid(system, Name) of Pid when is_pid(Pid) -> case process_info(Pid) of undefined -> @@ -1973,22 +1978,22 @@ restart_module(M) -> restart_module(Pid,M) when is_pid(Pid)-> case process_info(Pid) of undefined -> - n2o_async:pid(system, roster_profile) ! {restart, M}; + n2o_pi:pid(system, roster_profile) ! {restart, M}; _ -> Pid end; restart_module(Class,Name) -> - H=case n2o_async:pid(Class,Name) of + H=case n2o_pi:pid(Class,Name) of Pid when is_pid(Pid) -> #handler{group=Group} = Async=case process_info(Pid) of undefined -> #handler{module = Name, class = Class, group = roster, name = Name, state = []}; - _ -> n2o_async:send(Pid,{get}) + _ -> n2o_pi:send(Pid,{get}) end, [ supervisor:F(Group,{Class,Name}) || F <- [ terminate_child , delete_child ] ], n2o:cache(Class,{Class,Name},undefined), Async; _ -> #handler{module = Name, class = Class, group = roster, name = Name, state = []} end, - {NPid,_}=n2o_async:start(H), NPid. + {NPid,_}=n2o_pi:start(H), NPid. wait_for(Fun) -> diff --git a/apps/roster/src/roster_channel_helper.erl b/apps/roster/src/roster_channel_helper.erl index ea0e7186d..177aa2e2c 100644 --- a/apps/roster/src/roster_channel_helper.erl +++ b/apps/roster/src/roster_channel_helper.erl @@ -111,7 +111,7 @@ check_user_permissions(ChannelId, ClientId, PermissionKey) -> [] -> ResponseSuccess; _ -> %% check admin permission list - case lists:keyfind(PermissionKey, #'Feature'.key, PermList) of + case lists:keyfind(PermissionKey, #'Feature'.key, PermList) of %% TODO: "true ?" investigate ! #'Feature'{value = true} -> ResponseSuccess; _ -> ResponseError end diff --git a/apps/roster/src/roster_client.erl b/apps/roster/src/roster_client.erl index 49ea6752e..6b3b93269 100644 --- a/apps/roster/src/roster_client.erl +++ b/apps/roster/src/roster_client.erl @@ -18,7 +18,7 @@ start_client(ClientId, Token, Opts) -> receive_drop(), stop_client(ClientId), Username = proplists:get_value(username, Opts, <<"api">>), - n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, + n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, state = #state{mqtt_opts = [{password, Token}|Opts ++ ?DEFAULT_MQTTC_OPTS], username = Username, receive_pid = self()}, name = ClientId}), init = receive_test(ClientId, init), ok. @@ -33,13 +33,13 @@ start_cli_receive(ClientId, Token, Counter, Opts) -> start_client(ClientId, Toke stop_client(ClientIds) when is_list(ClientIds) -> [stop_client(ClientId) || ClientId <- ClientIds], ok; stop_client(ClientId) -> - case n2o_async:pid(system, ClientId) of + case n2o_pi:pid(system, ClientId) of Pid when is_pid(Pid) -> case process_info(Pid) of undefined -> catch [supervisor:F(roster, {system, ClientId}) || F <- [terminate_child, delete_child]], n2o:cache(system, {system, ClientId}, undefined), ok; - _ -> n2o_async:stop(system, ClientId), ok end; _ -> ok end. + _ -> n2o_pi:stop(system, ClientId), ok end; _ -> ok end. receive_drop() -> receive _ -> receive_drop() after ?DRP_TMOUT -> skip end. @@ -198,7 +198,7 @@ wait_for_last_res(ClientId, Count) -> Res -> Res end. send(ClientId, Term) -> write_log([Term]), - n2o_async:send(system, ClientId, Term), timer:sleep(50). + n2o_pi:send(system, ClientId, Term), timer:sleep(50). send_last(ClientId, ResultLen) -> send_last(ClientId, ResultLen, [], 5, 100). diff --git a/rebar.config b/rebar.config index b3576f61d..4722d3d3f 100644 --- a/rebar.config +++ b/rebar.config @@ -4,7 +4,6 @@ {deps, [ {active, ".*", {git, "git://github.com/synrc/active",{branch,"master"}}}, {esockd, ".*", {git, "https://github.com/voxoz/esockd",{ref, "a80634b961c315ffe5f020d73236473b53ae5dc9"}}}, - {kvs, ".*", {git, "git://github.com/qomputer/kvs", {tag,"master"}}}, {bpe, ".*", {git, "git://github.com/synrc/bpe", {branch,"v4.5"}}}, {emqttd, ".*", {git, "git://github.com/synrc/emqttd",{branch,"master"}}}, {emqttc, ".*", {git, "git://github.com/voxoz/emqttc",{branch,"master"}}}, @@ -30,9 +29,11 @@ % ===> Dependency failure: source for jose-erlang does not contain a recognizable project and can not be built % {'jose-erlang', ".*", {git, "https://github.com/manifest/jose-erlang.git", {branch,"master"}}}, {'erlang-uuid', ".*", {git, "https://github.com/avtobiff/erlang-uuid.git",{branch,"master"}}}, + {enenra, ".*", {git, "https://github.com/nlfiedler/enenra", {tag, "0.3.0"}}}, {'qdate', ".*", {git, "https://github.com/enterprizing/qdate.git",{ref,"fba988fc54214bb37a3ce11d5c5a3cc68752c3ce"}}} ]}. -{erl_opts, [{parse_transform,lager_transform},{parse_transform, oc_transform},debug_info]}. + +{erl_opts, [{parse_transform,lager_transform},{parse_transform, oc_transform},debug_info,nowarn_deprecated_function,nowarn_export_all]}. {relx, [{release, {server, "1.0.0"}, [roster, service]}, {sys_config, "./sys.config"}, -- GitLab From 926087e5a070db94fc078198c1bd338e6efea8d5 Mon Sep 17 00:00:00 2001 From: Namdak Tonpa Date: Wed, 3 Jul 2019 16:07:28 +0300 Subject: [PATCH 13/20] fix n2o v6.5 boot: * ETS tables: mqtt, ws in addition to ring * use mqtt_server env var to boot the MQTT ring by N2O --- sys.config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys.config b/sys.config index b56074507..dcec0ce7b 100644 --- a/sys.config +++ b/sys.config @@ -64,9 +64,10 @@ {n2o, [{port,8000}, {upload,"./storage"}, {app,review}, - {tables,[ cookies, file, caching, ring, async, nick, names, surnames, system]}, + {tables,[ cookies, file, caching, ring, mqtt, ws, async, nick, names, surnames, system]}, {pickler,nitro_pickle}, {formatter,n2o_bert}, + {mqtt_server,true}, {auth_ttl, 86400}, %% 24 h {protocols,[n2o_nitro,n2o_ftp,roster_proto]}, {log_modules,[roster, n2o_vnode]}, -- GitLab From 4e8b032a0d9893304b24fb9bbc0de443d68b2bec Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Wed, 3 Jul 2019 18:17:10 +0300 Subject: [PATCH 14/20] [NY-7291] provide porting to n2o_pi --- apps/roster/src/api/google_api.erl | 11 +- apps/roster/src/protocol/micro_auth.erl | 14 +- apps/roster/src/protocol/roster_auth.erl | 30 +- apps/roster/src/protocol/roster_bpe.erl | 34 +- apps/roster/src/protocol/roster_friend.erl | 6 +- apps/roster/src/protocol/roster_ftp.erl | 10 +- apps/roster/src/protocol/roster_history.erl | 5 +- apps/roster/src/protocol/roster_message.erl | 14 +- apps/roster/src/protocol/roster_profile.erl | 8 +- apps/roster/src/protocol/roster_push.erl | 4 +- apps/roster/src/protocol/roster_room.erl | 4 +- apps/roster/src/protocol/roster_roster.erl | 8 +- apps/roster/src/protocol/roster_search.erl | 2 +- apps/roster/src/roster.erl | 6 +- apps/roster/src/roster_client.erl | 38 +- apps/roster/src/roster_validator.erl | 973 -------------------- 16 files changed, 98 insertions(+), 1069 deletions(-) delete mode 100644 apps/roster/src/roster_validator.erl diff --git a/apps/roster/src/api/google_api.erl b/apps/roster/src/api/google_api.erl index a35be96ee..56c3ffb17 100644 --- a/apps/roster/src/api/google_api.erl +++ b/apps/roster/src/api/google_api.erl @@ -61,10 +61,8 @@ start() -> case filelib:is_file(PathFile) of true -> os:putenv("GOOGLE_APPLICATION_CREDENTIALS", PathFile), - case enenra:load_credentials(os:getenv("GOOGLE_APPLICATION_CREDENTIALS")) of - {ok, Creds} -> application:set_env(roster, google_creds, Creds); - Err-> roster:error(?MODULE, "cannot load googlr creds: ~p", [Err]) - end; + {ok, Creds} = enenra:load_credentials(os:getenv("GOOGLE_APPLICATION_CREDENTIALS")), + application:set_env(roster, google_creds, Creds); _ -> roster:error(?MODULE, "google credential file ~p not found", PathFile) end, case ?GOOGLE_API_KEY of @@ -238,7 +236,10 @@ gs_upload(FileIn, Bucket, ContentType) -> Size = filelib:file_size(FileOut), {ok, Md5} = enenra:compute_md5(FileOut), case enenra:upload_file(FileOut, - #object{name = Name, bucket = Bucket, contentType = ContentType, md5Hash = Md5, size = Size}, Creds) of + #object{name = Name, + bucket = Bucket, + contentType = ContentType, + md5Hash = Md5, size = Size}, Creds) of {ok, #object{}} -> roster:info(?MODULE, "object ~p is uploaded successfully", [GsUri = iolist_to_binary(["gs://",Bucket,"/",Name])]), [file:delete(filename:absname(File)) || File<-[FileIn2, FileOut]], diff --git a/apps/roster/src/protocol/micro_auth.erl b/apps/roster/src/protocol/micro_auth.erl index c89d97985..c33f541ad 100644 --- a/apps/roster/src/protocol/micro_auth.erl +++ b/apps/roster/src/protocol/micro_auth.erl @@ -98,31 +98,31 @@ info(#'Auth'{phone = Phone} = Auth, Req, #cx{params = ClientId} = State) -> {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. %% micro_auth handlers -proc(init, #handler{name = micro_auth} = Async) -> +proc(init, #pi{name = micro_auth} = Async) -> {ok, C} = emqttc:start_link([{client_id, <<"micro_auth">>}, {logger, {console, error}}, {reconnect, 5}]), roster:info(?MODULE, "ASYNC AUTH PROC started", []), - {ok, Async#handler{state = C, seq = 0}}; + {ok, Async#pi{state = C}}; proc(#'Auth'{type = {ver, Ver}, phone = Phone, client_id = <<"emqttd_", _/binary>> = ClientId}, - #handler{state = C} = H) -> + #pi{state = C} = H) -> roster:info(?MODULE, "~p:~p:Auth(micro)/login", [Phone, ClientId]), catch roster_presence:on_connect(Phone, ClientId, C, Ver), %%TODO send Auth updated session? {reply, [], H}; proc({disconnect, #'Auth'{client_id = <<"emqttd_", _/binary>>} = Auth}, - #handler{state = C} = H) -> roster_presence:on_disconnect(Auth, C), + #pi{state = C} = H) -> roster_presence:on_disconnect(Auth, C), {reply, [], H}; proc(#'Auth'{type = {reg, Ver}, client_id = <<"emqttd_", _/binary>> = ClientId, phone = Phone, user_id = UserId} = Stored, - #handler{state = C} = H) -> + #pi{state = C} = H) -> roster:info(?MODULE, "~p:~p:Auth(micro)/login(created session)", [Phone, ClientId]), roster_presence:on_verify(ClientId, UserId), roster_presence:on_connect(Phone, ClientId, C, Ver), {reply, [], H}; -proc({mqttc, C, connected}, State = #handler{state = C, seq = S}) -> {ok, State#handler{seq = S + 1}}; +proc({mqttc, C, connected}, State = #pi{state = C}) -> {ok, State}; proc({mqttc, _C, disconnected}, State) -> {ok, State}; -proc(Unknown, #handler{} = H) -> +proc(Unknown, #pi{} = H) -> roster:info(?MODULE, "invalid auth data :~p", [Unknown]), {reply, [], H}. diff --git a/apps/roster/src/protocol/roster_auth.erl b/apps/roster/src/protocol/roster_auth.erl index f151efbe8..b2b33297f 100644 --- a/apps/roster/src/protocol/roster_auth.erl +++ b/apps/roster/src/protocol/roster_auth.erl @@ -272,17 +272,17 @@ info(#'Auth'{phone = Phone} = Auth, Req, #cx{params = ClientId} = State) -> {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. %% roster_auth handlers -proc(init, #handler{name = roster_auth} = Async) -> +proc(init, #pi{name = roster_auth} = Async) -> {ok, C} = emqttc:start_link([{client_id, <<"roster_auth">>}, {logger, {console, error}}, {reconnect, 5}]), _ = (catch locus:start_loader(city, application:get_env(locus, url, ?GEO_URL))), case catch locus:wait_for_loader(city, 10000) of {ok, _} -> ok; Err -> roster:error(?MODULE, "error:~p:locus", [Err]) end, roster:info(?MODULE, "ASYNC AUTH PROC:~p started", [C]), - {ok, Async#handler{state = C, seq = 0}}; + {ok, Async#pi{state = C}}; -%%proc(#'Auth'{type = verified, client_id = <<"emqttd_", Post/binary>> = ClientId, user_id = UserId} = Stored, #handler{} = H) -> +%%proc(#'Auth'{type = verified, client_id = <<"emqttd_", Post/binary>> = ClientId, user_id = UserId} = Stored, #pi{} = H) -> %% proc(Stored#'Auth'{type = {reg,?VERSION}}, H); -proc(#'Auth'{type = {reg,Ver}, client_id = <<"emqttd_", Post/binary>> = ClientId, user_id = UserId} = Stored, #handler{} = H) -> +proc(#'Auth'{type = {reg,Ver}, client_id = <<"emqttd_", Post/binary>> = ClientId, user_id = UserId} = Stored, #pi{} = H) -> Reply = proc(Stored#'Auth'{type = {ver,Ver}}, H), RegClientId = <<"reg_", Post/binary>>, n2o_vnode:unsubscribe(RegClientId, roster:action_topic(RegClientId)), @@ -291,24 +291,24 @@ proc(#'Auth'{type = {reg,Ver}, client_id = <<"emqttd_", Post/binary>> = ClientId %%proc(#'Auth'{type = [], token = Token, phone = Phone, client_id = <<"emqttd_", _/binary>> = ClientId}=Auth,H)-> %% proc(Auth#'Auth'{type = {ver,?VERSION}}, H); proc(#'Auth'{type = {ver,Ver}, token = Token, phone = Phone, client_id = <<"emqttd_", _/binary>> = ClientId}, - #handler{state = C} = H) -> + #pi{state = C} = H) -> NewC=roster:restart_module(C,roster_auth), roster:info(?MODULE, "~p:~p:Auth/login:~p", [Phone, ClientId, binary:part(Token, 0, 16)]), catch roster_presence:on_connect(Phone, ClientId, NewC, Ver), - {reply, [], H#handler{state = NewC}}; -proc(#'Auth'{type = update, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, #handler{state = C} = H) -> + {reply, [], H#pi{state = NewC}}; +proc(#'Auth'{type = update, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, #pi{state = C} = H) -> {ok, #'Auth'{token = T}} = kvs:get('Auth', ClientId), %NewC=roster:restart_module(C,roster_auth), {'Token', Token2} = roster:gen_token([], binary:part(T, 0, 10)), roster:info(?MODULE, "~p:Auth/update:~p", [ClientId, binary:part(Token2, 0, 16)]), catch n2o_vnode:send(C, roster:action_topic(ClientId), term_to_binary(Auth#'Auth'{token = Token2}), [{qos, 0}]), - {reply, [], H#handler{state = C}}; -proc({disconnect, #'Auth'{client_id = <<"emqttd_", _/binary>>} = Auth}, #handler{state = C} = H) -> + {reply, [], H#pi{state = C}}; +proc({disconnect, #'Auth'{client_id = <<"emqttd_", _/binary>>} = Auth}, #pi{state = C} = H) -> % NewC=roster:restart_client(C,<<"roster_auth">>), % spawn(roster, client_pid, [C,<<"roster_auth">>]), catch roster_presence:on_disconnect(Auth, C), - {reply, [], H#handler{state = C}}; -proc({vox, #'Profile'{phone = Phone, services = Services} = Profile, Cli}, #handler{state = C} = H) -> + {reply, [], H#pi{state = C}}; +proc({vox, #'Profile'{phone = Phone, services = Services} = Profile, Cli}, #pi{state = C} = H) -> {VoxStatus, VoxResponse} = vox_api:create_voximplant_user(Phone), Service = case VoxStatus of ok -> {VoxResponse1} = VoxResponse, @@ -322,7 +322,7 @@ proc({vox, #'Profile'{phone = Phone, services = Services} = Profile, Cli}, #hand Profile2#'Profile'{presence = online, rosters = lists:map(fun roster:roster/1, Rosters)}) end, {reply, [], H}; -proc({sms, Phone, SmsCode}, #handler{} = H) -> +proc({sms, Phone, SmsCode}, #pi{} = H) -> roster:info(?MODULE, "~p:sms:~p", [Phone, SmsCode]), Half = size(SmsCode) - round(size(SmsCode) / 2), [Codes1, Codes2] = [binary:part(SmsCode, S, Half) || S <- [0, Half]], @@ -330,14 +330,14 @@ proc({sms, Phone, SmsCode}, #handler{} = H) -> spawn(fun () -> telesign_api:send_sms(Phone, ClientSms, fun(_) -> ok end) end), {reply, [], H}; -proc({voice, Phone, SmsCode, Lang}, #handler{} = H) -> +proc({voice, Phone, SmsCode, Lang}, #pi{} = H) -> roster:info(?MODULE, "~p:telesign:~p:~p", [Phone, SmsCode, Lang]), % telesign_api:telesign_voice_call(Phone, SmsCode, [], Lang), {reply, [], H}; -proc({mqttc, C, connected}, State = #handler{state = C, seq = S}) -> {ok, State#handler{seq = S + 1}}; +proc({mqttc, C, connected}, State = #pi{state = C}) -> {ok, State}; proc({mqttc, _C, disconnected}, State) -> {ok, State}; -proc(Unknown, #handler{} = H) -> +proc(Unknown, #pi{} = H) -> roster:info(?MODULE, "invalid auth data :~p", [Unknown]), {reply, [], H}. diff --git a/apps/roster/src/protocol/roster_bpe.erl b/apps/roster/src/protocol/roster_bpe.erl index ae575beb3..3dbc3aa90 100644 --- a/apps/roster/src/protocol/roster_bpe.erl +++ b/apps/roster/src/protocol/roster_bpe.erl @@ -190,7 +190,7 @@ info(#'Job'{feed_id = Feed} = RequestData, R, S) -> info(M, R, S) -> roster:info(?MODULE, "UNKNOWN:~w", [M]), {unknown, M, R, S}. -proc(init, #handler{name = roster_bpe} = Async) -> +proc(init, #pi{name = roster_bpe} = Async) -> {ok, C} = emqttc:start_link([{client_id, <<"sys_bpe">>}, {logger, {console, error}}, {reconnect, 5}]), Table = process, Proc = case kvs:get(feed, Table) of @@ -220,10 +220,10 @@ proc(init, #handler{name = roster_bpe} = Async) -> % bpe:amend(Proc,{send_pid, C},noflow), roster:info(?MODULE, "ASYNC BPE started: ~p; ~p", [C, Proc]), % Proc is transfered through state - {ok, Async#handler{state = {C, Proc}, seq = 0}}; + {ok, Async#pi{state = {C, Proc}}}; proc({update, #'Job'{id = Id0, time = Time, feed_id = {act, <<"publish">>, PhoneId} = Feed, data = D} = J, {OldTime, Limit}, - #cx{params = ClientId} = CX}, #handler{state = {C, Proc}} = H) when Limit < 8 -> + #cx{params = ClientId} = CX}, #pi{state = {C, Proc}} = H) when Limit < 8 -> roster:restart_module(C,roster_bpe), P = bpe:load(Proc), {NewJ0, Id} = case Id0 of [] -> NId = kvs:next_id('Job', 1), {J#'Job'{id = NId, proc = Proc}, NId}; _ -> @@ -266,24 +266,24 @@ proc({update, #'Job'{id = Id0, time = Time, feed_id = {act, <<"publish">>, Phone case NewD of [] -> roster:send_ses(C, roster:phone(PhoneId), case OldTime of 0 -> NewJ; _ -> NewJ#'Job'{status = update} end), - {reply, [], H#handler{state = {C, Proc}}}; + {reply, [], H#pi{state = {C, Proc}}}; _ -> try amend(Proc, NewSh = #'Schedule'{id = T, proc = Proc, data = NewD}, Par), roster:send_ses(C, roster:phone(PhoneId), case OldTime of 0 -> NewJ; _ -> NewJ#'Job'{status = update} end), - {reply, [], H#handler{state = {C, Proc}}} + {reply, [], H#pi{state = {C, Proc}}} catch Err:Rea -> roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]), restart_bpe(P, C), timer:sleep(300), bpe:complete(Proc), - proc({update, NewJ0, {OldTime, Limit + 1}, CX}, #handler{state = {C, Proc}, seq = S} = H) + proc({update, NewJ0, {OldTime, Limit + 1}, CX}, #pi{state = {C, Proc}} = H) end end; proc({update, #'Job'{id = Id0, time = Time, feed_id = {act, <<"publish">>, PhoneId} = Feed, data = D} = J, {OldTime, Limit}, - #cx{params = ClientId} = S}, #handler{state = {C, Proc}} = H) -> + #cx{params = ClientId} = S}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE update limit ~p; ~p", [C, Proc]), {reply, [], H}; -proc({publish, #process{id = Id} = P}, #handler{state = {C, Proc}, seq = S} = H) -> +proc({publish, #process{id = Id} = P}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC publish: ~p", [Id]), roster:restart_module(C,roster_bpe), %#act{data=Jobs}=bpe:doc(#act{},Proc), @@ -306,9 +306,9 @@ proc({publish, #process{id = Id} = P}, #handler{state = {C, Proc}, seq = S} = H) #'Schedule'{id = Current} -> Current; _ -> roster:now_msec() end, job:clear_hist(P), - proc({next, P, Curr}, #handler{state = {C, Proc}, seq = S} = H); + proc({next, P, Curr}, #pi{state = {C, Proc}} = H); -proc({next, #process{id = Id} = P, Current}, #handler{state = {C, Proc}, seq = S} = H) -> +proc({next, #process{id = Id} = P, Current}, #pi{state = {C, Proc}} = H) -> %roster:info(?MODULE, "BPE PROC next: ~p", [P]), FirstS = try mnesia:dirty_first('Schedule') of '$end_of_table' -> Current; Key -> Key catch _ -> Current end, Stop = #'Schedule'{id = roster:now_msec(), data = <<"stop">>}, @@ -326,14 +326,14 @@ proc({next, #process{id = Id} = P, Current}, #handler{state = {C, Proc}, seq = S {reply, [], H}; -proc({restart, #'process'{id = Id} = P}, #handler{state = {C, Proc}, seq = S} = H) -> +proc({restart, #'process'{id = Id} = P}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC restarted", []), % P1=job_process:update_event(P, 'Action', {0, {0, 0, 1}}), Proc = restart_bpe(P, C), bpe:complete(Proc), - {reply, [], #handler{state = {C, Proc}} = H}; + {reply, [], #pi{state = {C, Proc}} = H}; -proc({timeout, #'Schedule'{id = Current} = Sh, T}, #handler{state = {C, Proc}} = H) -> +proc({timeout, #'Schedule'{id = Current} = Sh, T}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC Timeout: ~p", [T]), %{value,#boundaryEvent{timeout = BT},_}=lists:keytake('*',#boundaryEvent.name,bpe:events(P)), %{ok, TRef} = timer:apply_after(T, bpe, complete, [Proc]), @@ -344,7 +344,7 @@ proc({timeout, #'Schedule'{id = Current} = Sh, T}, #handler{state = {C, Proc}} = {reply, [], H}; -proc({clean, #'process'{id = Id} = P}, #handler{state = {C, Proc}} = H) -> +proc({clean, #'process'{id = Id} = P}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC clean", []), bpe:complete(Id), {value, #boundaryEvent{timeout = BT}, _} = lists:keytake('*', #boundaryEvent.name, bpe:events(P)), @@ -352,15 +352,15 @@ proc({clean, #'process'{id = Id} = P}, #handler{state = {C, Proc}} = H) -> timer:apply_after(roster:daystimeToms(BT) + 5000, bpe, cleanup, [Id]), {reply, [], H}; -proc({send, Msgs}, #handler{state = {C, Proc}} = H) -> +proc({send, Msgs}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC send", []), roster:restart_module(C,roster_bpe), % [case kvs:get(mqtt_session, roster:get_vnode(Msg)) of {ok,#mqtt_session{sess_pid = Pid}} -> n2o_pi:send(Pid,{publish, , Msg}); _ -> skip end || Msg = #'Message'{} <- Msgs], [begin roster:send_event(C, <<"sys_bpe">>, <<>>, Msg, roster:get_vnode(<<"sys_bpe">>,Msg)),timer:sleep(5) end || Msg = #'Message'{} <- Msgs], - {reply, [], H#handler{state = {C, Proc}}}; + {reply, [], H#pi{state = {C, Proc}}}; -proc({mqttc, C, connected}, State = #handler{state = {C, Proc}, seq = S}) -> {ok, State#handler{seq = S + 1}}; +proc({mqttc, C, connected}, State = #pi{state = {C, Proc}}) -> {ok, State}; proc({mqttc, _C, disconnected}, State) -> {ok, State}. diff --git a/apps/roster/src/protocol/roster_friend.erl b/apps/roster/src/protocol/roster_friend.erl index 67759380a..43b7ad409 100644 --- a/apps/roster/src/protocol/roster_friend.erl +++ b/apps/roster/src/protocol/roster_friend.erl @@ -164,14 +164,14 @@ info(#'Friend'{phone_id = Roster, friend_id = Friend} = F, Req, State) -> roster:info(?MODULE, "~p:~p:Friend/unknown", [Roster, F]), {reply, {bert, <<>>}, Req, State}. -proc(init, #handler{name = ?MODULE} = Async) -> +proc(init, #pi{name = ?MODULE} = Async) -> roster:info(?MODULE, "ASYNC", []), {ok, Async}; -proc({send_push, #'Contact'{names = FromName} = FromContactPayload, To, PushType}, #handler{} = H) -> +proc({send_push, #'Contact'{names = FromName} = FromContactPayload, To, PushType}, #pi{} = H) -> ActionText = case PushType of <<"request">> -> " wants to add you on NYNJA!"; _ -> " accepted your contact request! Send a message!" end, PushAlert = iolist_to_binary([FromName, ActionText]), [roster_push:send_push_notification(Ses, FromContactPayload, PushAlert, PushType) || #'Auth'{} = Ses <- kvs:index('Auth', user_id, To)], {reply, [], H}; -proc({send_push, From, To, PushType}, #handler{} = H) -> +proc({send_push, From, To, PushType}, #pi{} = H) -> proc({send_push, roster:user(roster:roster_id(To), From), To, PushType}, H). diff --git a/apps/roster/src/protocol/roster_ftp.erl b/apps/roster/src/protocol/roster_ftp.erl index b19208a16..85542215c 100644 --- a/apps/roster/src/protocol/roster_ftp.erl +++ b/apps/roster/src/protocol/roster_ftp.erl @@ -63,7 +63,7 @@ info(Message, Req, State) -> {unknown, Message, Req, State}. % n2o Handlers -proc(init, #handler{state = #ftp{sid = Sid, meta = ClientId} = FTP} = Async) -> +proc(init, #pi{state = #ftp{sid = Sid, meta = ClientId} = FTP} = Async) -> roster:info(?MODULE, "Proc Init: ~p~n Sid: ~p ClientId: ~p", [FTP#ftp{data = <<>>}, Sid, ClientId]), FTP2 = FTP#ftp{data = <<>>, status = {event, init}}, roster:info(?MODULE, "~n~n~n~n FTP2 ~p ~n~n~n~n", [FTP2]), @@ -72,7 +72,7 @@ proc(init, #handler{state = #ftp{sid = Sid, meta = ClientId} = FTP} = Async) -> proc(#ftp{id = Link, sid = Sid, data = Data, status = <<"send">>, block = Block, meta = ClientId} = FTP, - #handler{state = #ftp{size = TotalSize, offset = Offset, filename = RelPath}} = Async) when Offset + Block >= TotalSize -> + #pi{state = #ftp{size = TotalSize, offset = Offset, filename = RelPath}} = Async) when Offset + Block >= TotalSize -> {S3_Status, S3_Data} = amazon_api:push_to_s3([], RelPath, Data, []), case S3_Status of ok -> @@ -81,20 +81,20 @@ proc(#ftp{id = Link, sid = Sid, data = Data, status = <<"send">>, block = Block, FTP3 = FTP2#ftp{status = {event, stop}, filename = RelPath}, n2o_ring:send({publish, <<"events/1//index/anon/", ClientId/binary, "/", Sid/binary>>, term_to_binary(FTP3)}), spawn(fun() -> n2o_pi:stop(file, Link) end), - {stop, normal, FTP2, Async#handler{state = FTP2}}; + {stop, normal, FTP2, Async#pi{state = FTP2}}; _ -> {reply, {error, S3_Data}, Async} end; proc(#ftp{data = Data, block = Block} = FTP, - #handler{state = #ftp{offset = Offset, filename = RelPath}} = Async) -> + #pi{state = #ftp{offset = Offset, filename = RelPath}} = Async) -> FTP2 = FTP#ftp{status = <<"send">>, offset = Offset + Block}, roster:info(?MODULE, "Proc Process ~p", [FTP2#ftp{data = <<>>}]), {S3_Status, S3_Data} = amazon_api:push_to_s3([], RelPath, Data, []), case S3_Status of ok -> roster:info(?MODULE, "~n~n Uploaded to S3 file with link ~p ~n~n", [S3_Data]), - {reply, FTP2#ftp{data = <<>>}, Async#handler{state = FTP2#ftp{filename = RelPath}}}; + {reply, FTP2#ftp{data = <<>>}, Async#pi{state = FTP2#ftp{filename = RelPath}}}; _ -> {reply, {error, S3_Data }, Async} end; diff --git a/apps/roster/src/protocol/roster_history.erl b/apps/roster/src/protocol/roster_history.erl index b62ca3204..cae3a1dfd 100644 --- a/apps/roster/src/protocol/roster_history.erl +++ b/apps/roster/src/protocol/roster_history.erl @@ -47,6 +47,7 @@ info(#'History'{status = get} = History, Req, #cx{state = []} = State) -> info(History, Req, State#cx{state = {status, get}}); info(#'History'{status = get, feed = [], data = [#'Message'{feed_id = Feed}|_]} = History, Req, State) when Feed /= []-> info(History#'History'{feed = Feed}, Req, State); + info(#'History'{status = get, roster_id = Roster0, feed = Feed, size = N, entity_id = MId, data = MsgData} = History, Req, #cx{params = ClientId, state = {status, InitialStatus}} = State) when N /= 0 andalso (is_record(Feed, p2p) orelse is_record(Feed, muc)) andalso @@ -257,11 +258,11 @@ clean_history(Feed, From, To, Rs) -> _ -> {#io{code = #error{code = invalid_data}}, <<>>} end. -proc(init, #handler{name = roster_history} = Async) -> +proc(init, #pi{name = roster_history} = Async) -> roster:info(?MODULE, "ASYNC:~p", [?MODULE]), {ok, Async}; -proc({send_push, ToPhoneId, Feed, Action}, #handler{} = H) -> +proc({send_push, ToPhoneId, Feed, Action}, #pi{} = H) -> PushType = <<"message">>, Payload = case Feed of {muc, RoomId} -> diff --git a/apps/roster/src/protocol/roster_message.erl b/apps/roster/src/protocol/roster_message.erl index 70c0d7e91..fa70df8c7 100644 --- a/apps/roster/src/protocol/roster_message.erl +++ b/apps/roster/src/protocol/roster_message.erl @@ -348,12 +348,12 @@ info(#'Message'{from = From, to = To} = ReqData, Req, State) -> roster:info(?MODULE, "~p:~p:Message/unknown:~p", [From, To, {ReqData, Req}]), {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. -proc(init, #handler{name = roster_message} = Async) -> +proc(init, #pi{name = roster_message} = Async) -> roster:info(?MODULE, "ASYNC:~p", [?MODULE]), {ok, C} = emqttc:start_link([{client_id, <<"roster_message">>}, {logger, {console, error}}, {reconnect, 5}]), - {ok, Async#handler{state = C, seq = 0}}; + {ok, Async#pi{state = C}}; -proc({send_push, From, To, #'Message'{type = TypeList} = Msg, Action}, #handler{} = H) -> +proc({send_push, From, To, #'Message'{type = TypeList} = Msg, Action}, #pi{} = H) -> %% Check should server proceed push %% TODO add push for message/delete case From of @@ -361,10 +361,10 @@ proc({send_push, From, To, #'Message'{type = TypeList} = Msg, Action}, #handler{ _ -> notify(From, To, Msg, Action) end, {reply, [], H}; -proc({#io{} = IO, ClientId}, #handler{state = C} = H) -> +proc({#io{} = IO, ClientId}, #pi{state = C} = H) -> roster:send_action(C, ClientId, IO), {reply, [], H}; -proc({#'Message'{status = update} = Msg, ClientId}, #handler{state = C} = H) -> +proc({#'Message'{status = update} = Msg, ClientId}, #pi{state = C} = H) -> roster:info(?MODULE, "UPDATE TRANSCRIBE: ~p", [Msg]), try {reply, {bert, IO}, _, _} = info(Msg, {[], handled}, #cx{params = ClientId, client_pid = C, state = ack}), roster:send_action(C, ClientId, IO) @@ -372,9 +372,9 @@ proc({#'Message'{status = update} = Msg, ClientId}, #handler{state = C} = H) -> roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, {reply, [], H}; -proc({mqttc, C, connected}, State = #handler{state = C, seq = S}) -> {ok, State#handler{seq = S + 1}}; +proc({mqttc, C, connected}, State = #pi{state = C}) -> {ok, State}; proc({mqttc, _C, disconnected}, State) -> {ok, State}; -proc(Unknown, #handler{} = H) -> +proc(Unknown, #pi{} = H) -> roster:info(?MODULE, "invalid message data :~p", [Unknown]), {reply, [], H}. diff --git a/apps/roster/src/protocol/roster_profile.erl b/apps/roster/src/protocol/roster_profile.erl index 7952da51b..38ac5bf3b 100644 --- a/apps/roster/src/protocol/roster_profile.erl +++ b/apps/roster/src/protocol/roster_profile.erl @@ -82,18 +82,18 @@ info(#'Profile'{status = init} = Data, Req, State) -> info(#'Profile'{} = Data, Req, State) -> {reply, {bert, Data}, Req, State}. -proc(init,#handler{name=?MODULE} = Async) -> +proc(init,#pi{name=?MODULE} = Async) -> roster:info(?MODULE, "ASYNC",[]), {ok,Async}; -proc({restart, M}, #handler{state = {C, Proc}, seq = S} = H) -> +proc({restart, M}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC restarted", []), roster:restart_module(M), {reply, [], H}. %% TODO maybe in future -%%proc({send_email,#'Service'{id = Addr, data = Code}}, #handler{}=H) -> +%%proc({send_email,#'Service'{id = Addr, data = Code}}, #pi{}=H) -> %% Half = size(Code)-round(size(Code)/2), %% Codes1 = binary:part(Code, 0, Half), %% Codes2 = binary:part(Code, Half, Half), @@ -104,7 +104,7 @@ proc({restart, M}, #handler{state = {C, Proc}, seq = S} = H) -> %% {reply, [], H}; %% TODO maybe in future -%%proc({aws, ClientId}, #handler{state = C} = H) -> +%%proc({aws, ClientId}, #pi{state = C} = H) -> %% Res = case amazon_api:gen_temp_creds() of %% {error, Reason} -> #io{code = #error{code = Reason}}; %% {ok, {AccessKeyId, SecretAccessKey, SessionToken, Expiration}} -> diff --git a/apps/roster/src/protocol/roster_push.erl b/apps/roster/src/protocol/roster_push.erl index fc368765f..7c2445c60 100644 --- a/apps/roster/src/protocol/roster_push.erl +++ b/apps/roster/src/protocol/roster_push.erl @@ -6,11 +6,11 @@ start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). -proc(init, #handler{name = ?MODULE} = Async) -> +proc(init, #pi{name = ?MODULE} = Async) -> roster:info(?MODULE, "ASYNC", []), {ok, Async}; -proc({async_push, Session, Payload, PushAlert, PushType}, #handler{} = H) -> +proc({async_push, Session, Payload, PushAlert, PushType}, #pi{} = H) -> send_push_notification(Session, Payload, PushAlert, PushType), {reply, [], H}. diff --git a/apps/roster/src/protocol/roster_room.erl b/apps/roster/src/protocol/roster_room.erl index ea3a5ecbd..8ac837367 100644 --- a/apps/roster/src/protocol/roster_room.erl +++ b/apps/roster/src/protocol/roster_room.erl @@ -350,11 +350,11 @@ info(#'Member'{} = Member, Req, #cx{params = ClientId} = State) -> {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. -proc(init, #handler{name = roster_room} = Async) -> +proc(init, #pi{name = roster_room} = Async) -> roster:info(?MODULE, "ASYNC ROOM PROC started", []), {ok, Async}; %% TODO use roster_push instead -proc({send_push, NewMembers, Msg, Type}, #handler{} = H) -> +proc({send_push, NewMembers, Msg, Type}, #pi{} = H) -> PushType = <<"message">>, #'Message'{from = FromPhoneId, to = RoomId} = Msg, {ok, #'Room'{name = RoomName}} = kvs:get('Room', RoomId), diff --git a/apps/roster/src/protocol/roster_roster.erl b/apps/roster/src/protocol/roster_roster.erl index 4bc2203c5..84799da43 100644 --- a/apps/roster/src/protocol/roster_roster.erl +++ b/apps/roster/src/protocol/roster_roster.erl @@ -161,11 +161,11 @@ info(#'Roster'{id = RosterId, status = Status}, Req, #cx{params = ClientId} = St roster:info(?MODULE, "~p:~p:Roster/unknown:~p", [RosterId, ClientId, Status]), {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. -proc(init, #handler{name = ?MODULE} = Async) -> +proc(init, #pi{name = ?MODULE} = Async) -> roster:info(?MODULE, "ASYNC", []), {ok, Async}; -proc({update_ac, #'Contact'{phone_id = PhoneId} = C}, #handler{} = H) -> +proc({update_ac, #'Contact'{phone_id = PhoneId} = C}, #pi{} = H) -> [Phone, RosterId] = roster:parts_phone_id(PhoneId), [begin [P, FriendId] = roster:parts_phone_id(PId), Res = case roster:get_contact(FriendId, PhoneId) of @@ -175,12 +175,12 @@ proc({update_ac, #'Contact'{phone_id = PhoneId} = C}, #handler{} = H) -> || #'Contact'{phone_id = PId} <- roster:get_on_status(RosterId, friend)], {reply, [], H}; -proc({update_index, #'Roster'{id = RosterId, nick = Nick}}, #handler{} = H) -> +proc({update_index, #'Roster'{id = RosterId, nick = Nick}}, #pi{} = H) -> kvs:put(#'Index'{id = {nick, Nick}, roster = [RosterId]}), %% @TODO: Have to be code for adding new nick into B-tree for nicks {reply, [], H}; %% TODO refactor me -proc({delete_index, #'Roster'{id = RosterId, nick = Nick}}, #handler{} = H) -> +proc({delete_index, #'Roster'{id = RosterId, nick = Nick}}, #pi{} = H) -> kvs:delete('Index', {nick, Nick}), {reply, [], H}. \ No newline at end of file diff --git a/apps/roster/src/protocol/roster_search.erl b/apps/roster/src/protocol/roster_search.erl index 57a0b2ae4..569e7c64c 100644 --- a/apps/roster/src/protocol/roster_search.erl +++ b/apps/roster/src/protocol/roster_search.erl @@ -65,7 +65,7 @@ info(#'Search'{} = Data, Req, State) -> roster:info(?MODULE, "Search/unknown:~p", [Data]), {reply, {bert, {io, {error,invalid_data}}}, Req, State}. -proc(init, #handler{name = roster_search} = Async) -> +proc(init, #pi{name = roster_search} = Async) -> roster:info(?MODULE, "Search ASYNC started", []), case mnesia:wait_for_tables(['Index'], 1000000) of ok -> index('Index', nick); diff --git a/apps/roster/src/roster.erl b/apps/roster/src/roster.erl index 3e400fd4b..4fd78e2a4 100644 --- a/apps/roster/src/roster.erl +++ b/apps/roster/src/roster.erl @@ -1997,14 +1997,14 @@ restart_module(Pid,M) when is_pid(Pid)-> restart_module(Class,Name) -> H=case n2o_pi:pid(Class,Name) of Pid when is_pid(Pid) -> - #handler{group=Group} = Async=case process_info(Pid) of - undefined -> #handler{module = Name, class = Class, group = roster, name = Name, state = []}; + #pi{sup=Group} = Async=case process_info(Pid) of + undefined -> #pi{module = Name, table = Class, sup = roster, name = Name, state = []}; _ -> n2o_pi:send(Pid,{get}) end, [ supervisor:F(Group,{Class,Name}) || F <- [ terminate_child , delete_child ] ], n2o:cache(Class,{Class,Name},undefined), Async; - _ -> #handler{module = Name, class = Class, group = roster, name = Name, state = []} + _ -> #pi{module = Name, table = Class, sup = roster, name = Name, state = []} end, {NPid,_}=n2o_pi:start(H), NPid. diff --git a/apps/roster/src/roster_client.erl b/apps/roster/src/roster_client.erl index 511542026..ddeeb39aa 100644 --- a/apps/roster/src/roster_client.erl +++ b/apps/roster/src/roster_client.erl @@ -62,48 +62,48 @@ filter_friend(Term, State) -> Status == ban;Status == unban;Status == banned;Status == friend;Status == update -> send; {_, Res} -> Res end. -proc(#mqttc{}, #handler{} = H) -> {reply, [], H}; -proc(init, #handler{name = ?SYS_REST_CLIENT, state = #state{receive_pid = Self} = State} = Async) -> +proc(#mqttc{}, #pi{} = H) -> {reply, [], H}; +proc(init, #pi{name = ?SYS_REST_CLIENT, state = #state{receive_pid = Self} = State} = Async) -> {ok, C} = application:get_env(rest, rest_pid), Self ! init, - {ok, Async#handler{state = State#state{mqttc = C, client_id = ?SYS_REST_CLIENT}, seq = 0}}; -proc(init, #handler{name = ?SYS_BRIDGE_TEST_CLIENT, state = #state{receive_pid = Self} = State} = Async) -> + {ok, Async#pi{state = State#state{mqttc = C, client_id = ?SYS_REST_CLIENT}}}; +proc(init, #pi{name = ?SYS_BRIDGE_TEST_CLIENT, state = #state{receive_pid = Self} = State} = Async) -> {ok, C} = emqttc:start_link([{client_id, ?SYS_BRIDGE_TEST_CLIENT}, {logger, {console, error}}, {reconnect, 5}]), roster:info(?MODULE, "MICRO BRIDGE SIMULATOR PROC started", []), register(sys_bridge, C), Self ! init, - {ok, Async#handler{state = State#state{mqttc = whereis(sys_bridge), client_id = ?SYS_BRIDGE_TEST_CLIENT}, seq = 0}}; -proc(init, #handler{name = ClientId, state = #state{mqtt_opts = Opts, receive_pid = Self, username = Username} = State} = Async) -> + {ok, Async#pi{state = State#state{mqttc = whereis(sys_bridge), client_id = ?SYS_BRIDGE_TEST_CLIENT}}}; +proc(init, #pi{name = ClientId, state = #state{mqtt_opts = Opts, receive_pid = Self, username = Username} = State} = Async) -> roster:info(?MODULE, "ClientInit:~p\r", [ClientId]), {ok, C} = emqttc:start_link([{client_id, ClientId}, {clean_sess, false}, {logger, {console, error}}, {username, Username}, {reconnect, 5}] ++ Opts), Self ! init, - {ok, Async#handler{state = State#state{mqttc = C, client_id = ClientId}, seq = 0}}; + {ok, Async#pi{state = State#state{mqttc = C, client_id = ClientId}}}; -proc({filter, Filter}, #handler{state = #state{receive_pid = Self} = State} = H) -> +proc({filter, Filter}, #pi{state = #state{receive_pid = Self} = State} = H) -> Self ! ok, - {reply, [], H#handler{state = State#state{filter = Filter}}}; + {reply, [], H#pi{state = State#state{filter = Filter}}}; -proc(last_res, #handler{state = #state{receive_pid = Self, last_res = LastRes} = State} = H) -> +proc(last_res, #pi{state = #state{receive_pid = Self, last_res = LastRes} = State} = H) -> Self ! lists:ukeysort(1, LastRes), - {reply, [], H#handler{state = State#state{last_res = []}}}; -proc(unsort_last_res, #handler{state = #state{receive_pid = Self, last_res = LastRes} = State} = H) -> + {reply, [], H#pi{state = State#state{last_res = []}}}; +proc(unsort_last_res, #pi{state = #state{receive_pid = Self, last_res = LastRes} = State} = H) -> Self ! LastRes, - {reply, [], H#handler{state = State#state{last_res = []}}}; -proc({publish, _, BinTerm}, #handler{state = #state{receive_pid = Self, last_res = LastRes, filter = FilterFun} = State} = H) -> + {reply, [], H#pi{state = State#state{last_res = []}}}; +proc({publish, _, BinTerm}, #pi{state = #state{receive_pid = Self, last_res = LastRes, filter = FilterFun} = State} = H) -> case ?MODULE:FilterFun(Term = binary_to_term(BinTerm), State) of send -> write_log([Term]), Self ! Term; _ -> skip end, - {reply, [], H#'handler'{state = State#state{last_res = [Term | LastRes]}}}; -proc(_Term, #handler{state = #state{mqttc = {error, _} = Err}} = H) -> + {reply, [], H#pi{state = State#state{last_res = [Term | LastRes]}}}; +proc(_Term, #pi{state = #state{mqttc = {error, _} = Err}} = H) -> roster:info("mqttc error: ~p", [Err]), {reply, [], H}; -proc({callback, CallbackFun}, #handler{state = State} = H) -> +proc({callback, CallbackFun}, #pi{state = State} = H) -> State2 = CallbackFun(State), - {reply, [], H#handler{state = State2}}; -proc(Term, #handler{state = #state{mqttc = C}} = H) -> + {reply, [], H#pi{state = State2}}; +proc(Term, #pi{state = #state{mqttc = C}} = H) -> roster:send_event(C, <<>>, <<>>, Term), {reply, [], H}. diff --git a/apps/roster/src/roster_validator.erl b/apps/roster/src/roster_validator.erl deleted file mode 100644 index 230e5d646..000000000 --- a/apps/roster/src/roster_validator.erl +++ /dev/null @@ -1,973 +0,0 @@ --module(roster_validator). --include_lib("bpe/include/bpe.hrl"). --include_lib("emqttd/include/emqttd.hrl"). --include_lib("kvs/include/feed.hrl"). --include_lib("kvs/include/group.hrl"). --include_lib("kvs/include/kvs.hrl"). --include_lib("kvs/include/metainfo.hrl"). --include_lib("kvs/include/user.hrl"). --include_lib("n2o/include/n2o.hrl"). --include_lib("roster/include/roster.hrl"). --include_lib("roster/include/static_auth.hrl"). --compile(export_all). - -custom_validate(_Obj) -> []. -validate(Obj) -> validate(Obj, [], application:get_env(bert, custom_validate, {?MODULE, custom_validate})). -validate(Obj, Acc, _) when is_atom(Obj) -> Acc; -validate(Obj, Acc, _) when is_integer(Obj) -> Acc; -validate(Obj, Acc, _) when is_binary(Obj) -> Acc; - -validate(D = #'writer'{id = Id, count = Count, cache = Cache, args = Args, first = First}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - {cache,_} when Cache==[] orelse is_tuple(Cache) -> Acc2; - {args,_} -> Acc2; - {first,_} when First==[] orelse is_tuple(First) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'writer'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'reader'{id = Id, pos = Pos, cache = Cache, args = Args, feed = Feed, dir = Dir}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} -> Acc2; - {pos,_} when Pos==[] orelse is_integer(Pos) -> Acc2; - {cache,_} when Cache==[] orelse is_integer(Cache) -> Acc2; - {args,_} -> Acc2; - {feed,_} -> Acc2; - {dir,_} when Dir==0 orelse Dir==1 -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'reader'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'cur'{id = Id, top = Top, bot = Bot, dir = Dir, reader = Reader, writer = Writer, args = Args}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {bot,_} when Bot==[] orelse is_integer(Bot) -> Acc2; - {dir,_} when Dir==0 orelse Dir==1 -> Acc2; - {reader,_} when Reader==[] orelse is_tuple(Reader) -> Acc2; - {writer,_} when Writer==[] orelse is_tuple(Writer) -> Acc2; - {args,_} when is_list(Args) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) orelse is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{args, D}|Acc3] end, Acc2, Args); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'cur'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'iter'{id = Id, container = Container, feed = Feed, next = Next, prev = Prev}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed,_} -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'iter'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'container'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'container'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'iterator'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'iterator'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'log'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'log'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'operation'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'operation'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'feed'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'feed'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'task'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'task'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'userTask'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'userTask'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'serviceTask'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'serviceTask'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'receiveTask'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'receiveTask'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'messageEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when is_binary(Payload) -> Acc2; - {timeout,_} when is_tuple(Timeout) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'messageEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'boundaryEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout, timeDate = TimeDate, timeDuration = TimeDuration, timeCycle = TimeCycle}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when is_binary(Payload) -> Acc2; - {timeout,_} when is_tuple(Timeout) -> Acc2; - {timeDate,_} when is_binary(TimeDate) -> Acc2; - {timeDuration,_} when is_binary(TimeDuration) -> Acc2; - {timeCycle,_} when is_binary(TimeCycle) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'boundaryEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'timeoutEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout, timeDate = TimeDate, timeDuration = TimeDuration, timeCycle = TimeCycle}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - {timeout,_} when Timeout==[] orelse is_tuple(Timeout) -> Acc2; - {timeDate,_} when TimeDate==[] orelse is_binary(TimeDate) -> Acc2; - {timeDuration,_} when TimeDuration==[] orelse is_binary(TimeDuration) -> Acc2; - {timeCycle,_} when TimeCycle==[] orelse is_binary(TimeCycle) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'timeoutEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'beginEvent'{name = Name, module = Module, prompt = Prompt}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'beginEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'endEvent'{name = Name, module = Module, prompt = Prompt}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'endEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'sequenceFlow'{source = Source, target = Target}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {source,_} when Source==[] orelse is_atom(Source) -> Acc2; - {target,_} when Target==[] orelse is_atom(Target) orelse is_list(Target) -> - lists:foldl(fun(Tmp, Acc3) when is_atom(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{target, D}|Acc3] end, Acc2, Target); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'sequenceFlow'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'hist'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, name = Name, task = Task, docs = Docs, time = Time}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {task,_} when is_atom(Task) -> Acc2; - {docs,_} when is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - {time,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'hist'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'process'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, name = Name, roles = Roles, tasks = Tasks, events = Events, hist = Hist, flows = Flows, rules = Rules, docs = Docs, options = Options, task = Task, timer = Timer, notifications = Notifications, result = Result, started = Started, beginEvent = BeginEvent, endEvent = EndEvent}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {roles,_} when is_list(Roles) -> []; - {tasks,_} when is_list(Tasks) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'task') orelse is_record(Tmp,'serviceTask') orelse is_record(Tmp,'userTask') orelse is_record(Tmp,'receiveTask') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{tasks, D}|Acc3] end, Acc2, Tasks); - {events,_} when is_list(Events) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'messageEvent') orelse is_record(Tmp,'boundaryEvent') orelse is_record(Tmp,'timeoutEvent') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{events, D}|Acc3] end, Acc2, Events); - - {flows,_} when is_list(Flows) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'sequenceFlow') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{flows, D}|Acc3] end, Acc2, Flows); - - {docs,_} when is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - {options,_} -> Acc2; - {task,_} when Task==[] orelse is_atom(Task) -> Acc2; - {timer,_} when Timer==[] orelse is_binary(Timer) -> Acc2; - {notifications,_} when Notifications==[] orelse true -> Acc2; - {result,_} when Result==[] orelse is_binary(Result) -> Acc2; - {started,_} when Started==[] orelse is_tuple(Started) -> Acc2; - {beginEvent,_} when BeginEvent==[] orelse is_atom(BeginEvent) -> Acc2; - {endEvent,_} when EndEvent==[] orelse is_atom(EndEvent) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'process'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'complete'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'complete'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'proc'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'proc'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'load'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'load'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'histo'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'histo'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'create'{proc = Proc, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {proc,_} when Proc==[] orelse is_record(Proc,'process') orelse is_binary(Proc) -> Acc2; - {docs,_} when Docs==[] orelse is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'create'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'amend'{id = Id, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {docs,_} when Docs==[] orelse is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'amend'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'chain'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'chain'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'push'{model = Model, type = Type, title = Title, alert = Alert, badge = Badge, sound = Sound}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {model,_} when Model==[] orelse true -> Acc2; - {type,_} when Type==[] orelse is_binary(Type) -> Acc2; - {title,_} when Title==[] orelse is_binary(Title) -> Acc2; - {alert,_} when Alert==[] orelse is_binary(Alert) -> Acc2; - {badge,_} when Badge==[] orelse is_integer(Badge) -> Acc2; - {sound,_} when Sound==[] orelse is_binary(Sound) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'push'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Search'{id = Id, ref = Ref, field = Field, type = Type, value = Value, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when is_integer(Id) -> Acc2; - {ref,_} when is_binary(Ref) -> Acc2; - {field,_} when is_binary(Field) -> Acc2; - {type,_} when Type=='==' orelse Type=='!=' orelse Type=='like' -> Acc2; - {value,_} when is_list(Value) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{value, D}|Acc3] end, Acc2, Value); - {status,_} when Status=='profile' orelse Status=='roster' orelse Status=='contact' orelse Status=='member' orelse Status=='room' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Search'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'p2p'{from = From, to = To}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {from,_} when is_binary(From) -> Acc2; - {to,_} when is_binary(To) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'p2p'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'muc'{name = Name}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when is_binary(Name) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'muc'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqi'{feed_id = Feed_id, query = Query, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {feed_id, #'muc'{}} -> Acc2; - {query,_} when Query==[] orelse is_binary(Query) -> Acc2; - {status,_} when Status==[] orelse Status=='admin' orelse Status=='member' orelse Status=='removed' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqi'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Feature'{id = Id, key = Key, value = Value, group = Group}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {key,_} when is_binary(Key) -> Acc2; - {value,_} when is_binary(Value) -> Acc2; - {group,_} when is_binary(Group) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Feature'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Service'{id = Id, type = Type, data = Data, login = Login, password = Password, expiration = Expiration, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {type,_} when Type=='email' orelse Type=='vox' orelse Type=='aws' orelse Type=='wallet' -> Acc2; - {data,_} -> Acc2; - {login,_} when Login==[] orelse is_binary(Login) -> Acc2; - {password,_} when Password==[] orelse is_binary(Password) -> Acc2; - {expiration,_} when Expiration==[] orelse is_integer(Expiration) -> Acc2; - {status,_} when Status==[] orelse Status=='verified' orelse Status=='added' orelse Status=='add' orelse Status=='remove' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Service'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Member'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, phone_id = Phone_id, avatar = Avatar, names = Names, surnames = Surnames, alias = Alias, reader = Reader, update = Update, settings = Settings, services = Services, presence = Presence, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when Container=='chain' orelse Container=='cur' orelse Container==[] -> Acc2; - {feed_id,_} when is_record(Feed_id,'muc') orelse is_record(Feed_id,'p2p') orelse Feed_id==[] -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {phone_id,_} when Phone_id==[] orelse is_binary(Phone_id) -> Acc2; - {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; - {names,_} when Names==[] orelse is_binary(Names) -> Acc2; - {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; - {alias,_} when Alias==[] orelse is_binary(Alias) -> Acc2; - {reader,_} when Reader==[] orelse is_integer(Reader) -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {services,_} when Services==[] orelse is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {presence,_} when Presence==[] orelse Presence=='online' orelse Presence=='offline' -> Acc2; - {status,_} when Status==[] orelse Status=='admin' orelse Status=='member' orelse Status=='removed' orelse Status=='patch' orelse Status=='owner' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Member'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Desc'{id = Id, mime = Mime, payload = Payload, parentid = Parentid, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {mime,_} when Mime==[] orelse is_binary(Mime) -> Acc2; - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - {parentid,_} when Parentid==[] orelse is_binary(Parentid) -> Acc2; - {data,_} when is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Desc'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'StickerPack'{id = Id, name = Name, keywords = Keywords, description = Description, author = Author, stickers = Stickers, created = Created, updated = Updated, downloaded = Downloaded}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {keywords,_} when is_list(Keywords) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{keywords, D}|Acc3] end, Acc2, Keywords); - {description,_} when Description==[] orelse is_binary(Description) -> Acc2; - {author,_} when Author==[] orelse is_binary(Author) -> Acc2; - {stickers,_} when is_list(Stickers) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Desc') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{stickers, D}|Acc3] end, Acc2, Stickers); - {created,_} when is_integer(Created) -> Acc2; - {updated,_} when is_integer(Updated) -> Acc2; - {downloaded,_} when is_integer(Downloaded) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'StickerPack'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Message'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, msg_id = Msg_id, from = From, to = To, created = Created, files = Files, type = Type, link = Link, seenby = Seenby, repliedby = Repliedby, mentioned = Mentioned, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when Container=='chain' orelse Container=='cur' orelse Container==[] -> Acc2; - {feed_id,_} when is_record(Feed_id,'muc') orelse is_record(Feed_id,'p2p') -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {msg_id,_} when Msg_id==[] orelse is_binary(Msg_id) -> Acc2; - {from,_} when From==[] orelse is_binary(From) -> Acc2; - {to,_} when To==[] orelse is_binary(To) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {files,_} when is_list(Files) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Desc') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{files, D}|Acc3] end, Acc2, Files); - {type,_} when is_list(Type) -> - lists:foldl(fun(Tmp, Acc3) when Tmp=='sys' orelse Tmp=='reply' orelse Tmp=='forward' orelse Tmp=='read' orelse Tmp=='edited' orelse Tmp=='cursor' -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{type, D}|Acc3] end, Acc2, Type); - {link,_} when Link==[] orelse is_integer(Link) orelse is_record(Link,'Message') -> Acc2; - {seenby,_} when Seenby==[] orelse is_list(Seenby) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) orelse is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{seenby, D}|Acc3] end, Acc2, Seenby); - {repliedby,_} when Repliedby==[] orelse is_list(Repliedby) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{repliedby, D}|Acc3] end, Acc2, Repliedby); - {mentioned,_} when Mentioned==[] orelse is_list(Mentioned) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{mentioned, D}|Acc3] end, Acc2, Mentioned); - {status,_} when Status==[] orelse Status=='async' orelse Status=='delete' orelse Status=='clear' orelse Status=='update' orelse Status=='edit' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Message'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Link'{id = Id, name = Name, room_id = Room_id, created = Created, type = Type, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {room_id,_} when Room_id==[] orelse is_binary(Room_id) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {type,_} when Type==[] orelse Type=='group' orelse Type=='channel' -> Acc2; - {status,_} when Status==[] orelse Status=='gen' orelse Status=='check' orelse Status=='add' orelse Status=='get' orelse Status=='join' orelse Status=='update' orelse Status=='delete' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Link'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Room'{id = Id, name = Name, links = Links, description = Description, settings = Settings, members = Members, admins = Admins, data = Data, type = Type, tos = Tos, tos_update = Tos_update, unread = Unread, mentions = Mentions, readers = Readers, last_msg = Last_msg, update = Update, created = Created, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {links,_} when Links==[] orelse is_list(Links) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Link') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{links, D}|Acc3] end, Acc2, Links); - {description,_} when Description==[] orelse is_binary(Description) -> Acc2; - {settings,_} when is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {members,_} when is_list(Members) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Member') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{members, D}|Acc3] end, Acc2, Members); - {admins,_} when is_list(Admins) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Member') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{admins, D}|Acc3] end, Acc2, Admins); - {data,_} when is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Desc') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {type,_} when Type==[] orelse Type=='group' orelse Type=='channel' orelse Type=='call' -> Acc2; - {tos,_} when Tos==[] orelse is_binary(Tos) -> Acc2; - {tos_update,_} when Tos_update==[] orelse is_integer(Tos_update) -> Acc2; - {unread,_} when Unread==[] orelse is_integer(Unread) -> Acc2; - {mentions,_} when is_list(Mentions) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{mentions, D}|Acc3] end, Acc2, Mentions); - {readers,_} when is_list(Readers) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{readers, D}|Acc3] end, Acc2, Readers); - {last_msg,_} when Last_msg==[] orelse is_integer(Last_msg) orelse is_record(Last_msg,'Message') -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {status,_} when Status==[] orelse Status=='create' orelse Status=='leave' orelse Status=='add' orelse Status=='remove' orelse Status=='removed' orelse Status=='join' orelse Status=='joined' orelse Status=='info' orelse Status=='patch' orelse Status=='get' orelse Status=='delete' orelse Status=='last_msg' orelse Status=='mute' orelse Status=='unmute' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Room'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Tag'{roster_id = Roster_id, name = Name, color = Color, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {roster_id,_} when Roster_id==[] orelse is_binary(Roster_id) -> Acc2; - {name,_} when is_binary(Name) -> Acc2; - {color,_} when is_binary(Color) -> Acc2; - {status,_} when Status==[] orelse Status=='create' orelse Status=='remove' orelse Status=='edit' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Tag'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Star'{id = Id, client_id = Client_id, roster_id = Roster_id, message = Message, tags = Tags, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {client_id,_} when Client_id==[] orelse is_binary(Client_id) -> Acc2; - {roster_id,_} when Roster_id==[] orelse is_integer(Roster_id) -> Acc2; - {message,_} when Message==[] orelse is_record(Message,'Message') -> Acc2; - {tags,_} when is_list(Tags) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Tag') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{tags, D}|Acc3] end, Acc2, Tags); - {status,_} when Status==[] orelse Status=='add' orelse Status=='remove' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Star'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Typing'{phone_id = Phone_id, comments = Comments}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone_id,_} when is_binary(Phone_id) -> Acc2; - {comments,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Typing'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Contact'{phone_id = Phone_id, avatar = Avatar, names = Names, surnames = Surnames, nick = Nick, reader = Reader, unread = Unread, last_msg = Last_msg, update = Update, created = Created, settings = Settings, services = Services, presence = Presence, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone_id,_} when Phone_id==[] orelse is_binary(Phone_id) -> Acc2; - {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; - {names,_} when Names==[] orelse is_binary(Names) -> Acc2; - {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; - {nick,_} when Nick==[] orelse is_binary(Nick) -> Acc2; - {reader,_} when Reader==[] orelse is_integer(Reader) orelse is_list(Reader) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{reader, D}|Acc3] end, Acc2, Reader); - {unread,_} when Unread==[] orelse is_integer(Unread) -> Acc2; - {last_msg,_} when Last_msg==[] orelse is_record(Last_msg,'Message') -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {settings,_} when is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {services,_} when is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {presence,_} when Presence==[] orelse Presence=='online' orelse Presence=='offline' orelse is_binary(Presence) -> Acc2; - {status,_} when Status==[] orelse Status=='request' orelse Status=='authorization' orelse Status=='ignore' orelse Status=='internal' orelse Status=='friend' orelse Status=='last_msg' orelse Status=='ban' orelse Status=='banned' orelse Status=='deleted' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Contact'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'ExtendedStar'{star = Star, from = From}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {star,_} when is_record(Star,'Star') orelse Star==[] -> Acc2; - {from,_} when is_record(From,'Contact') orelse is_record(From,'Room') orelse From==[] -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'ExtendedStar'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Auth'{client_id = Client_id, dev_key = Dev_key, user_id = User_id, phone = Phone, token = Token, type = Type, sms_code = Sms_code, attempts = Attempts, services = Services, settings = Settings, push = Push, os = Os, created = Created, last_online = Last_online}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {client_id,_} when Client_id==[] orelse is_binary(Client_id) -> Acc2; - {dev_key,_} when Dev_key==[] orelse is_binary(Dev_key) -> Acc2; - {user_id,_} when User_id==[] orelse is_binary(User_id) -> Acc2; - {phone,_} when Phone==[] orelse is_binary(Phone) orelse is_tuple(Phone) -> Acc2; - {token,_} when Token==[] orelse is_binary(Token) -> Acc2; - {type,_} when Type==[] orelse is_atom(Type) -> Acc2; - {sms_code,_} when Sms_code==[] orelse is_binary(Sms_code) -> Acc2; - {attempts,_} when Attempts==[] orelse is_integer(Attempts) -> Acc2; - {services,_} when is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {push,_} when Push==[] orelse is_binary(Push) -> Acc2; - {os,_} when Os==[] orelse Os=='ios' orelse Os=='android' orelse Os=='web' -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {last_online,_} when Last_online==[] orelse is_integer(Last_online) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Auth'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Roster'{id = Id, names = Names, surnames = Surnames, email = Email, nick = Nick, userlist = Userlist, roomlist = Roomlist, favorite = Favorite, tags = Tags, phone = Phone, avatar = Avatar, update = Update, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) orelse is_integer(Id) -> Acc2; - {names,_} when Names==[] orelse is_binary(Names) -> Acc2; - {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; - {email,_} when Email==[] orelse is_binary(Email) -> Acc2; - {nick,_} when Nick==[] orelse is_binary(Nick) -> Acc2; - {userlist,_} when is_list(Userlist) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Contact') orelse is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{userlist, D}|Acc3] end, Acc2, Userlist); - {roomlist,_} when is_list(Roomlist) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Room') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{roomlist, D}|Acc3] end, Acc2, Roomlist); - {favorite,_} when is_list(Favorite) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Star') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{favorite, D}|Acc3] end, Acc2, Favorite); - {tags,_} when is_list(Tags) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Tag') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{tags, D}|Acc3] end, Acc2, Tags); - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {status,_} when Status==[] orelse Status=='get' orelse Status=='create' orelse Status=='del' orelse Status=='remove' orelse Status=='nick' orelse Status=='add' orelse Status=='update' orelse Status=='list' orelse Status=='patch' orelse Status=='last_msg' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Roster'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Profile'{phone = Phone, services = Services, rosters = Rosters, settings = Settings, update = Update, balance = Balance, presence = Presence, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {services,_} when Services==[] orelse is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {rosters,_} when Rosters==[] orelse is_list(Rosters) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Roster') orelse is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{rosters, D}|Acc3] end, Acc2, Rosters); - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {update,_} when is_integer(Update) -> Acc2; - {balance,_} when is_integer(Balance) -> Acc2; - {presence,_} when Presence==[] orelse Presence=='offline' orelse Presence=='online' orelse is_binary(Presence) -> Acc2; - {status,_} when Status==[] orelse Status=='remove' orelse Status=='get' orelse Status=='patch' orelse Status=='update' orelse Status=='delete' orelse Status=='create' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Profile'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Presence'{uid = Uid, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {uid,_} when is_binary(Uid) -> Acc2; - {status,_} when Status==[] orelse Status=='offline' orelse Status=='online' orelse is_binary(Status) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Presence'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Friend'{phone_id = Phone_id, friend_id = Friend_id, settings = Settings, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone_id,_} when is_binary(Phone_id) -> Acc2; - {friend_id,_} when is_binary(Friend_id) -> Acc2; - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {status,_} when Status=='ban' orelse Status=='unban' orelse Status=='request' orelse Status=='confirm' orelse Status=='update' orelse Status=='ignore' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Friend'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'act'{name = Name, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {data,_} when is_binary(Data) orelse is_integer(Data) orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'act'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Job'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, context = Context, proc = Proc, time = Time, data = Data, events = Events, settings = Settings, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when Container=='chain' orelse Container==[] -> Acc2; - {feed_id, #'act'{}} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {context,_} when Context==[] orelse is_integer(Context) orelse is_binary(Context) -> Acc2; - {proc,_} when Proc==[] orelse is_integer(Proc) orelse is_record(Proc,'process') -> Acc2; - {time,_} when Time==[] orelse is_integer(Time) -> Acc2; - {data,_} when Data==[] orelse is_binary(Data) orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when true orelse is_record(Tmp,'Message') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {events,_} when Events==[] orelse is_list(Events) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'messageEvent') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{events, D}|Acc3] end, Acc2, Events); - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {status,_} when Status==[] orelse Status=='init' orelse Status=='update' orelse Status=='delete' orelse Status=='pending' orelse Status=='stop' orelse Status=='complete' orelse Status=='restart' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Job'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'History'{roster_id = Roster_id, feed = Feed, size = Size, entity_id = Entity_id, data = Data, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {roster_id,_} when is_binary(Roster_id) -> Acc2; - {feed,_} when is_record(Feed,'p2p') orelse is_record(Feed,'muc') orelse is_record(Feed,'act') orelse is_record(Feed,'StickerPack') orelse Feed==[] -> Acc2; - {size,_} when Size==[] orelse is_integer(Size) -> Acc2; - {entity_id,_} when Entity_id==[] orelse is_integer(Entity_id) -> Acc2; - {data,_} when Data==[] orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Message') orelse is_record(Tmp,'Job') orelse is_record(Tmp,'StickerPack') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {status,_} when Status=='updated' orelse Status=='get' orelse Status=='update' orelse Status=='last_loaded' orelse Status=='last_msg' orelse Status=='get_reply' orelse Status=='double_get' orelse Status=='delete' orelse Status=='image' orelse Status=='video' orelse Status=='file' orelse Status=='link' orelse Status=='audio' orelse Status=='contact' orelse Status=='location' orelse Status=='text' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'History'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Schedule'{id = Id, proc = Proc, data = Data, state = State}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) orelse is_tuple(Id) -> Acc2; - {proc,_} when Proc==[] orelse is_integer(Proc) orelse is_binary(Proc) -> Acc2; - {data,_} when is_binary(Data) orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {state,_} when State==[] orelse true -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Schedule'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Index'{id = Id, roster = Roster}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse true -> Acc2; - {roster,_} when is_list(Roster) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{roster, D}|Acc3] end, Acc2, Roster); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Index'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Whitelist'{phone = Phone, created = Created}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Whitelist'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'error'{code = Code}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_atom(Code) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'error'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'ok'{code = Code}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_binary(Code) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'ok'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'error2'{code = Code, src = Src}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_atom(Code) -> Acc2; - {src,_} when Src==[] orelse is_binary(Src) orelse is_integer(Src) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'error2'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'ok2'{code = Code, src = Src}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_atom(Code) -> Acc2; - {src,_} when Src==[] orelse is_tuple(Src) orelse is_binary(Src) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'ok2'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'io'{code = Code, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_record(Code,'ok') orelse is_record(Code,'error') orelse is_record(Code,'ok2') orelse is_record(Code,'error2') -> Acc2; - {data,_} when Data==[] orelse is_binary(Data) orelse is_record(Data,'Roster') orelse is_tuple(Data) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'io'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Ack'{table = Table, id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {table,_} when is_atom(Table) -> Acc2; - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Ack'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'errors'{code = Code, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_list(Code) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{code, D}|Acc3] end, Acc2, Code); - {data,_} when Data==[] orelse true -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'errors'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'PushService'{recipients = Recipients, id = Id, ttl = Ttl, module = Module, priority = Priority, payload = Payload}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {recipients,_} when is_list(Recipients) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{recipients, D}|Acc3] end, Acc2, Recipients); - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {ttl,_} when Ttl==[] orelse is_integer(Ttl) -> Acc2; - {module,_} when Module==[] orelse is_binary(Module) -> Acc2; - {priority,_} when Priority==[] orelse is_binary(Priority) -> Acc2; - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'PushService'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'PublishService'{message = Message, topic = Topic, qos = Qos}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {message,_} when Message==[] orelse is_binary(Message) -> Acc2; - {topic,_} when Topic==[] orelse is_binary(Topic) -> Acc2; - {qos,_} when Qos==[] orelse is_integer(Qos) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'PublishService'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'FakeNumbers'{phone = Phone, created = Created}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'FakeNumbers'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'handler'{name = Name, module = Module, class = Class, group = Group, config = Config, state = State, seq = Seq}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when is_atom(Name) -> Acc2; - {module,_} when is_atom(Module) -> Acc2; - {class,_} -> Acc2; - {group,_} when is_atom(Group) -> Acc2; - {config,_} -> Acc2; - {state,_} -> Acc2; - {seq,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'handler'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'pi'{name = Name, sup = Sup, module = Module, state = State}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when is_atom(Name) -> Acc2; - {sup,_} when is_atom(Sup) -> Acc2; - {module,_} when is_atom(Module) -> Acc2; - {state,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'pi'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'cx'{handlers = Handlers, actions = Actions, req = Req, module = Module, lang = Lang, path = Path, session = Session, formatter = Formatter, params = Params, node = Node, client_pid = Client_pid, state = State, from = From, vsn = Vsn}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {handlers,_} when is_list(Handlers) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'handler') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{handlers, D}|Acc3] end, Acc2, Handlers); - {actions,_} when is_list(Actions) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{actions, D}|Acc3] end, Acc2, Actions); - {req,_} when Req==[] orelse true -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {lang,_} when Lang==[] orelse is_atom(Lang) -> Acc2; - {path,_} when Path==[] orelse is_binary(Path) -> Acc2; - {session,_} when Session==[] orelse is_binary(Session) -> Acc2; - {formatter,_} when Formatter=='bert' orelse Formatter=='json' -> Acc2; - {params,_} when Params==[] orelse is_list(Params) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{params, D}|Acc3] end, Acc2, Params); - {node,_} when Node==[] orelse is_atom(Node) -> Acc2; - {client_pid,_} when Client_pid==[] orelse true -> Acc2; - {state,_} when State==[] orelse true -> Acc2; - {from,_} when From==[] orelse is_binary(From) -> Acc2; - {vsn,_} when Vsn==[] orelse is_binary(Vsn) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'cx'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'user'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, email = Email}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {email,_} when Email==[] orelse is_binary(Email) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'user'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'group'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'group'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_topic'{topic = Topic, flags = Flags}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {topic,_} when is_binary(Topic) -> Acc2; - {flags,_} when is_list(Flags) -> - lists:foldl(fun(Tmp, Acc3) when Tmp=='retained' orelse Tmp=='static' -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{flags, D}|Acc3] end, Acc2, Flags); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_topic'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_client'{client_id = Client_id, client_pid = Client_pid, username = Username, peername = Peername, clean_sess = Clean_sess, proto_ver = Proto_ver, will_topic = Will_topic, ws_initial_headers = Ws_initial_headers}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {client_id,_} when is_binary(Client_id) orelse Client_id=='undefined' -> Acc2; - - {username,_} when is_binary(Username) orelse Username=='undefined' -> Acc2; - {peername,_} when is_tuple(Peername) -> Acc2; - - {proto_ver,_} when Proto_ver==3 orelse Proto_ver==4 -> Acc2; - {will_topic,_} when Will_topic=='undefined' orelse is_binary(Will_topic) -> Acc2; - {ws_initial_headers,_} when is_list(Ws_initial_headers) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{ws_initial_headers, D}|Acc3] end, Acc2, Ws_initial_headers); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_client'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_session'{client_id = Client_id, sess_pid = Sess_pid, clean_sess = Clean_sess}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {client_id,_} when is_binary(Client_id) -> Acc2; - - - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_session'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_message'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when is_binary(Id) orelse Id=='undefined' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_message'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_delivery'{sender = Sender, message = Message}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - - {message, #'mqtt_message'{}} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_delivery'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_route'{topic = Topic, node = Node}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {topic,_} when is_binary(Topic) -> Acc2; - - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_route'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_alarm'{id = Id, severity = Severity, title = Title, summary = Summary}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when is_binary(Id) -> Acc2; - {severity,_} when Severity=='warning' orelse Severity=='error' orelse Severity=='critical' -> Acc2; - {title,_} when is_list(Title) orelse is_binary(Title) -> Acc2; - {summary,_} when is_list(Summary) orelse is_binary(Summary) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_alarm'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end. \ No newline at end of file -- GitLab From 42fcdd10b950195d91801a89fe22ee760d56b05f Mon Sep 17 00:00:00 2001 From: Namdak Tonpa Date: Thu, 4 Jul 2019 18:04:12 +0300 Subject: [PATCH 15/20] fix tests :-) --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 3d93ff5b8..51c3a6ed4 100644 --- a/rebar.config +++ b/rebar.config @@ -4,7 +4,7 @@ {deps, [ {active, ".*", {git, "git://github.com/synrc/active",{branch,"master"}}}, {esockd, ".*", {git, "https://github.com/voxoz/esockd",{ref, "a80634b961c315ffe5f020d73236473b53ae5dc9"}}}, - {bpe, ".*", {git, "git://github.com/synrc/bpe", {branch,"v4.5"}}}, + {bpe, ".*", {git, "git://github.com/synrc/bpe", {tag,"4.4"}}}, {emqttd, ".*", {git, "git://github.com/synrc/emqttd",{branch,"master"}}}, {emqttc, ".*", {git, "git://github.com/voxoz/emqttc",{branch,"master"}}}, {rest, ".*", {git, "git://github.com/synrc/rest",{tag,"5.10"}}}, -- GitLab From 8368fba3fb7703840e4cc676b0dbe000d7fdbbcd Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Wed, 10 Jul 2019 10:28:47 +0300 Subject: [PATCH 16/20] [NY-7291] dev merge --- .gitignore | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 727e3341c..1cab9cf46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +erl_crash.dump + deps/ log/ **/*.java @@ -17,39 +19,12 @@ workspace.xml .DS_Store _build -# Excessive for iOS models -apps/roster/priv/macbert/Model/PublishService.swift -apps/roster/priv/macbert/Model/Whitelist.swift -apps/roster/priv/macbert/Model/feed.swift -apps/roster/priv/macbert/Spec/PublishService_Spec.swift -apps/roster/priv/macbert/Spec/Whitelist_Spec.swift -apps/roster/priv/macbert/Spec/feed_Spec.swift - .applist 0.3 -priv/protobuf/service_friend/Contact.proto -priv/protobuf/service_friend/Friend.proto -priv/protobuf/service_friend/Roster.proto -priv/protobuf/service_friend/contactStatus.proto -priv/protobuf/service_friend/friendStatus.proto -priv/protobuf/service_friend/muc.proto -priv/protobuf/service_friend/p2p.proto -priv/protobuf/service_friend/rosterStatus.proto -priv/protobuf/service_room/History.proto -priv/protobuf/service_room/Job.proto -priv/protobuf/service_room/Message.proto -priv/protobuf/service_room/act.proto -priv/protobuf/service_room/historyType.proto -priv/protobuf/service_room/jobType.proto -priv/protobuf/service_room/messageEvent.proto -priv/protobuf/service_room/messageStatus.proto -priv/protobuf/service_room/messageType.proto -apps/roster/priv/macbert/Model/FakeNumbers.swift -apps/roster/priv/macbert/Model/Presence.swift -apps/roster/priv/macbert/Model/cx.swift -apps/roster/priv/macbert/Model/load.swift -apps/roster/priv/macbert/Spec/FakeNumbers_Spec.swift -apps/roster/priv/macbert/Spec/Presence_Spec.swift -apps/roster/priv/macbert/Spec/cx_Spec.swift -apps/roster/priv/macbert/Spec/load_Spec.swift -apps/service/priv/ +rebar.lock + +priv/protobuf/* +apps/roster/src/roster_validator.erl + +apps/roster/priv/* +apps/service/priv/* -- GitLab From 5d70e1f393cc6eee6741bbf83d29d803ff977937 Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Wed, 10 Jul 2019 15:00:38 +0300 Subject: [PATCH 17/20] [NY-7291] changed the deps remote url --- rebar.config | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rebar.config b/rebar.config index 51c3a6ed4..182379cd1 100644 --- a/rebar.config +++ b/rebar.config @@ -2,18 +2,18 @@ {lib_dirs,["apps","deps"]}. {deps_dir,"deps"}. {deps, [ - {active, ".*", {git, "git://github.com/synrc/active",{branch,"master"}}}, + {active, ".*", {git, "https://github.com/synrc/active",{branch,"master"}}}, {esockd, ".*", {git, "https://github.com/voxoz/esockd",{ref, "a80634b961c315ffe5f020d73236473b53ae5dc9"}}}, - {bpe, ".*", {git, "git://github.com/synrc/bpe", {tag,"4.4"}}}, - {emqttd, ".*", {git, "git://github.com/synrc/emqttd",{branch,"master"}}}, - {emqttc, ".*", {git, "git://github.com/voxoz/emqttc",{branch,"master"}}}, - {rest, ".*", {git, "git://github.com/synrc/rest",{tag,"5.10"}}}, - {gen_smtp, ".*", {git, "git://github.com/voxoz/gen_smtp",{branch,"master"}}}, + {bpe, ".*", {git, "https://github.com/synrc/bpe", {tag,"v4.4"}}}, + {emqttd, ".*", {git, "https://github.com/synrc/emqttd",{branch,"master"}}}, + {emqttc, ".*", {git, "https://github.com/voxoz/emqttc",{branch,"master"}}}, + {rest, ".*", {git, "https://github.com/synrc/rest",{tag,"5.10"}}}, + {gen_smtp, ".*", {git, "https://github.com/voxoz/gen_smtp",{branch,"master"}}}, {emq_dashboard, ".*", {git, "https://github.com/synrc/emq_dashboard",{branch,"master"}}}, {'opencensus-erlang', ".*", {git, "https://github.com/voxoz/opencensus-erlang",{tag, "v0.4.0"}}}, {libphonenumber_erlang, ".*", {git, "https://github.com/marinakr/libphonenumber_erlang.git",{branch,"master"}}}, {gproc, ".*", {git, "https://github.com/uwiger/gproc", {tag,"0.6.1"}}}, - {erlydtl, ".*", {git, "git://github.com/voxoz/erlydtl",{branch,"master"}}}, + {erlydtl, ".*", {git, "https://github.com/voxoz/erlydtl",{branch,"master"}}}, {mini_s3, ".*", {git, "https://github.com/chef/mini_s3.git",{branch,"master"}}}, {jwt, ".*", {git, "https://github.com/artemeff/jwt.git",{tag, "0.1.8"}}}, {jsx, ".*", {git, "https://github.com/talentdeficit/jsx.git", {tag,"v2.9.0"}}}, @@ -26,7 +26,7 @@ {locus, ".*", {git, "https://github.com/g-andrade/locus.git",{branch,"master"}}}, {json_rec, ".*", {git, "https://github.com/justinkirby/json_rec.git", {tag,"master"}}}, {prometheus, ".*", {git, "https://github.com/deadtrickster/prometheus.erl",{branch,"master"}}}, - {cowboy, ".*", {git, "git://github.com/voxoz/cowboy", {branch,"master"}}}, + {cowboy, ".*", {git, "https://github.com/voxoz/cowboy", {branch,"master"}}}, % ===> Dependency failure: source for jose-erlang does not contain a recognizable project and can not be built % {'jose-erlang', ".*", {git, "https://github.com/manifest/jose-erlang.git", {branch,"master"}}}, {'erlang-uuid', ".*", {git, "https://github.com/avtobiff/erlang-uuid.git",{branch,"master"}}}, -- GitLab From b33403ce0a64b221fa40876b8a2c547a33715d75 Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Mon, 15 Jul 2019 13:26:42 +0300 Subject: [PATCH 18/20] [NY-7291] Dialyzer type spec added; tests: failed [wip] --- apps/roster/include/roster.hrl | 49 ++++++++++++++++--------------- apps/roster/src/roster_export.erl | 37 ----------------------- 2 files changed, 25 insertions(+), 61 deletions(-) delete mode 100644 apps/roster/src/roster_export.erl diff --git a/apps/roster/include/roster.hrl b/apps/roster/include/roster.hrl index 95e23562f..1ceb04c8b 100644 --- a/apps/roster/include/roster.hrl +++ b/apps/roster/include/roster.hrl @@ -57,11 +57,12 @@ sound = [] :: [] | binary()}). -record('Search', {id = [] :: integer() | binary(), - ref = [] :: binary(), + ref = [] :: [] | binary(), field = [] :: binary(), type = [] :: '==' | '!=' | 'like', value = [] :: list(term() | binary()), - status = [] :: profile | roster | contact | member | room }). + status = [] :: contact | member | profile + | room | roster | some_atom }). -record(p2p, {from = [] :: binary(), to = [] :: binary() }). @@ -75,7 +76,7 @@ -record('Feature', {id = [] :: [] | binary(), key = [] :: binary(), - value = <<>> :: [] | binary() | true, + value = <<>> :: [] | true | binary() | integer(), group = ?DUMMY_GROUP :: [] | binary()}). -record('Service', {id = [] :: [] | binary(), @@ -87,8 +88,8 @@ status = [] :: [] | verified | added | add | remove}). -record('Member', {id = [] :: [] | integer(), - container = chain :: chain | cur | [], - feed_id = [] :: #muc{} | #p2p{} | [] , + container = chain :: [] | chain | cur , + feed_id = [] :: [] | #muc{} | #p2p{}, prev = [] :: [] | integer(), next = [] :: [] | integer(), feeds = [] :: list(), @@ -96,7 +97,7 @@ avatar = [] :: [] | binary(), names = [] :: [] | binary(), surnames = [] :: [] | binary(), - alias = [] :: [] | binary(), + alias = [] :: [] | binary() | list(), reader = 0 :: [] | integer() | #reader{}, update = 0 :: [] | integer(), settings = [] :: [] | list(#'Feature'{}), @@ -130,12 +131,12 @@ to = [] :: [] | binary(), created = [] :: [] | integer(), files = [] :: list(#'Desc'{}), - type = [] :: [sys | reply | forward | read | edited | cursor | draft ], + type = [] :: [sys | reply | forward | read | edited | cursor | draft | binary()], link = [] :: [] | integer() | #'Message'{}, seenby = [] :: [] | list(binary() | integer()), repliedby = [] :: [] | list(integer()), mentioned = [] :: [] | list(integer()), - status = [] :: [] | async | delete | clear| update | edit}). + status = [] :: [] | async | clear | delete | edit | fake | sys | update}). -record('Link', {id = [] :: [] | binary(), %% link value name = [] :: [] | binary(), %% unused atm @@ -149,10 +150,10 @@ name = [] :: [] | binary(), links = [] :: [] | list(#'Link'{}), description = [] :: [] | binary(), - settings = [] :: [] | list(#'Feature'{}), + settings = [] :: [] | list(#'Feature'{} | {test_settings, integer()}), members = [] :: [] | list(#'Member'{}), admins = [] :: [] | list(#'Member'{}), - data = [] :: [] | list(#'Desc'{}), + data = [] :: [] | {'Desc', integer()} | list(#'Desc'{}), type = [] :: [] | group | channel | call, tos = [] :: [] | binary(), tos_update = 0 :: [] | integer(), @@ -194,10 +195,10 @@ services = [] :: list(#'Service'{}), presence = [] :: [] | online | offline | binary(), status = [] :: [] | request | authorization | ignore | internal - | friend | last_msg | ban | banned | deleted | not_existence}). + | friend | last_msg | ban | banned | deleted | not_existence | draft}). --record('ExtendedStar', {star = [] :: #'Star'{} | [], - from = [] :: #'Contact'{} | #'Room'{} | []}). +-record('ExtendedStar', {star = [] :: [] | #'Star'{} | #'Message'{}, + from = [] :: [] | #'Contact'{} | #'Room'{}}). -record('Auth', {client_id = [] :: [] | binary(), dev_key = [] :: [] | binary(), @@ -206,7 +207,7 @@ token = [] :: [] | binary(), type = [] :: [] | update | clear | delete | deleted | logout | verify | verified | expired | reg | resend - | voice | push | get | {ver | reg, string()}, + | voice | push | get | ack | {ver | reg, string()}, sms_code = [] :: [] | binary(), attempts = [] :: [] | integer(), services = [] :: list(term()), @@ -218,19 +219,19 @@ -record('Roster', {id = [] :: [] | binary() | integer(), names = [] :: [] | binary(), - surnames = [] :: [] | binary(), + surnames = [] :: [] | binary() | list(), email = [] :: [] | binary(), nick = [] :: [] | binary(), - userlist = [] :: list(#'Contact'{} | integer()), - roomlist = [] :: list(#'Room'{}), - favorite = [] :: list(#'Star'{}), - tags = [] :: list(#'Tag'{}), + userlist = [] :: [] | {list(), list()} | list(#'Contact'{} | integer()), + roomlist = [] :: [] | {list(), list()} | list(#'Room'{}), + favorite = [] :: [] | {list(), list()} | list(#'Star'{} | #'ExtendedStar'{}), + tags = [] :: [] | list(#'Tag'{}), phone = [] :: [] | binary(), avatar = [] :: [] | binary(), update = 0 :: [] | integer(), - status = [] :: [] | get | create | del | remove | nick - | search | contact | add | update - | list | patch | last_msg }). + status = [] :: [] | add | contact | create | del | get + | last_msg | list | nick | patch | remove + | search | update }). -record('Profile', {phone = [] :: [] | binary(), services = [] :: [] | list(#'Service'{}), @@ -291,13 +292,13 @@ created = 0 :: [] | integer()}). -record(error, {code = [] :: [] | atom()}). --record(ok, {code = [] :: [] | sms_sent | call_in_progress | push | cleared | logout | binary()}). +-record(ok, {code = [] :: [] | added | sms_sent | call_in_progress | push | cleared | logout | binary()}). -record(error2, {code = [] :: [] | atom(), src=[] :: [] | binary() | integer() }). -record(ok2, {code = [] :: [] | atom(), src=[] :: [] | {binary(), binary()} | binary() }). -record(io, {code = [] :: [] | #ok{} | #error{} | #ok2{} | #error2{}, - data = <<>> :: [] | <<>> | binary() | #'Roster'{} | { atom(), binary() | integer() }}). + data = <<>> :: [] | <<>> | binary() | #'Roster'{} | #ok{} | { atom(), binary() | integer()}}). -record('Ack', {table = 'Message' :: atom(), id = [] :: [] | binary()}). diff --git a/apps/roster/src/roster_export.erl b/apps/roster/src/roster_export.erl deleted file mode 100644 index 926c11ec8..000000000 --- a/apps/roster/src/roster_export.erl +++ /dev/null @@ -1,37 +0,0 @@ --module(roster_export). --include("roster.hrl"). --include("micro.hrl"). - --compile(export_all). --compile({parse_transform, exprecs}). --export_records(['Profile', 'Roster', 'Service', 'Feature', - 'Contact', 'Room', 'ExtendedStar', 'Tag', - 'Desc', 'Star', 'Message', p2p, muc, 'Member', 'LinkRoster', 'LinkProfile']). - -to_file(Table, File) -> - file:write_file(File, to_json(Table)). - -json(Rec, Acc) -> Acc++[to_json(Rec)]. - -to_json(Table, Fun, Acc) when is_atom(Table) -> - iolist_to_binary(mochijson2:encode(roster_db:fold(Fun, Acc, Table))). -to_json(Table, Id) -> - case kvs:get(Table, Id) of {ok, Rec} -> to_json(Rec); Err -> Err end. -to_json(#'Roster'{surnames = [_|_] = Surname} = R) -> - to_json(R#'Roster'{surnames = iolist_to_binary(Surname)}); -to_json(#'Roster'{names = [_|_] = Name} = R) -> - to_json(R#'Roster'{names = iolist_to_binary(Name)}); -to_json(#'Roster'{nick = [_|_] = Nick} = R) -> - to_json(R#'Roster'{nick = iolist_to_binary(Nick)}); -to_json(#'Roster'{favorite = [_|_]} = R) -> - to_json(R#'Roster'{favorite = []}); -to_json(#'LinkProfile'{id = <<_:128>> = Id} = LP) -> - to_json(LP#'LinkProfile'{id = micro:norm_uuid(Id)}); -to_json(#'LinkRoster'{id = <<_:128>> = Id} = LP) -> - to_json(LP#'LinkRoster'{id = micro:norm_uuid(Id)}); -to_json(Table) when is_atom(Table) -> - to_json(Table, fun json/2, []); -to_json(Rec) when is_tuple(Rec), is_atom(element(1, Rec)) -> - json_rec:to_json(Rec, ?MODULE). - - -- GitLab From bc3f05ce434b6634052bf0a926075eeb443b837d Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Fri, 19 Jul 2019 13:03:54 +0300 Subject: [PATCH 19/20] [NY-7291] Dialyzer type spec added; func improvement; explicit define suppress for tests; [wip] --- .gitignore | 1 + apps/roster/include/roster.hrl | 33 +++++++++-------- apps/roster/src/api/google_api.erl | 2 +- apps/roster/src/processes/job_process.erl | 2 +- apps/roster/src/protocol/roster_bpe.erl | 2 +- apps/roster/src/protocol/roster_profile.erl | 2 +- apps/roster/src/rest/rest_handler.erl | 1 - apps/roster/src/roster.erl | 34 +++++++++--------- apps/roster/src/roster_db.erl | 6 ++-- apps/roster/src/test/friend_test.erl | 6 ++-- apps/roster/src/test/main_test.erl | 5 ++- apps/roster/src/test/room_test.erl | 3 +- apps/roster/src/test/roster_test.erl | 40 ++++++++++++++++++--- rebar.config.script | 2 +- 14 files changed, 84 insertions(+), 55 deletions(-) diff --git a/.gitignore b/.gitignore index 1cab9cf46..3e570128a 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ apps/roster/src/roster_validator.erl apps/roster/priv/* apps/service/priv/* +.tool-versions diff --git a/apps/roster/include/roster.hrl b/apps/roster/include/roster.hrl index 1ceb04c8b..1829df65a 100644 --- a/apps/roster/include/roster.hrl +++ b/apps/roster/include/roster.hrl @@ -61,8 +61,7 @@ field = [] :: binary(), type = [] :: '==' | '!=' | 'like', value = [] :: list(term() | binary()), - status = [] :: contact | member | profile - | room | roster | some_atom }). + status = [] :: profile | roster | contact | member | room }). -record(p2p, {from = [] :: binary(), to = [] :: binary() }). @@ -76,7 +75,7 @@ -record('Feature', {id = [] :: [] | binary(), key = [] :: binary(), - value = <<>> :: [] | true | binary() | integer(), + value = <<>> :: [] | integer() | binary() | true, group = ?DUMMY_GROUP :: [] | binary()}). -record('Service', {id = [] :: [] | binary(), @@ -88,7 +87,7 @@ status = [] :: [] | verified | added | add | remove}). -record('Member', {id = [] :: [] | integer(), - container = chain :: [] | chain | cur , + container = chain :: [] | chain | cur, feed_id = [] :: [] | #muc{} | #p2p{}, prev = [] :: [] | integer(), next = [] :: [] | integer(), @@ -131,12 +130,12 @@ to = [] :: [] | binary(), created = [] :: [] | integer(), files = [] :: list(#'Desc'{}), - type = [] :: [sys | reply | forward | read | edited | cursor | draft | binary()], + type = [] :: [sys | reply | forward | read | edited | cursor | draft ], link = [] :: [] | integer() | #'Message'{}, seenby = [] :: [] | list(binary() | integer()), repliedby = [] :: [] | list(integer()), mentioned = [] :: [] | list(integer()), - status = [] :: [] | async | clear | delete | edit | fake | sys | update}). + status = [] :: [] | async | delete | clear| update | edit}). -record('Link', {id = [] :: [] | binary(), %% link value name = [] :: [] | binary(), %% unused atm @@ -150,10 +149,10 @@ name = [] :: [] | binary(), links = [] :: [] | list(#'Link'{}), description = [] :: [] | binary(), - settings = [] :: [] | list(#'Feature'{} | {test_settings, integer()}), + settings = [] :: [] | list(#'Feature'{}), members = [] :: [] | list(#'Member'{}), admins = [] :: [] | list(#'Member'{}), - data = [] :: [] | {'Desc', integer()} | list(#'Desc'{}), + data = [] :: [] | list(#'Desc'{}), type = [] :: [] | group | channel | call, tos = [] :: [] | binary(), tos_update = 0 :: [] | integer(), @@ -198,7 +197,7 @@ | friend | last_msg | ban | banned | deleted | not_existence | draft}). -record('ExtendedStar', {star = [] :: [] | #'Star'{} | #'Message'{}, - from = [] :: [] | #'Contact'{} | #'Room'{}}). + from = [] :: [] | #'Contact'{} | #'Room'{} | []}). -record('Auth', {client_id = [] :: [] | binary(), dev_key = [] :: [] | binary(), @@ -207,7 +206,7 @@ token = [] :: [] | binary(), type = [] :: [] | update | clear | delete | deleted | logout | verify | verified | expired | reg | resend - | voice | push | get | ack | {ver | reg, string()}, + | voice | push | get | {ver | reg, string()} | login, sms_code = [] :: [] | binary(), attempts = [] :: [] | integer(), services = [] :: list(term()), @@ -219,19 +218,19 @@ -record('Roster', {id = [] :: [] | binary() | integer(), names = [] :: [] | binary(), - surnames = [] :: [] | binary() | list(), + surnames = [] :: [] | binary(), email = [] :: [] | binary(), nick = [] :: [] | binary(), userlist = [] :: [] | {list(), list()} | list(#'Contact'{} | integer()), roomlist = [] :: [] | {list(), list()} | list(#'Room'{}), - favorite = [] :: [] | {list(), list()} | list(#'Star'{} | #'ExtendedStar'{}), + favorite = [] :: [] | {list(), list()} | list(#'Star'{} | #'ExtendedStar'{} ), tags = [] :: [] | list(#'Tag'{}), phone = [] :: [] | binary(), avatar = [] :: [] | binary(), update = 0 :: [] | integer(), - status = [] :: [] | add | contact | create | del | get - | last_msg | list | nick | patch | remove - | search | update }). + status = [] :: [] | get | create | del | remove | nick + | search | contact | add | update + | list | patch | last_msg }). -record('Profile', {phone = [] :: [] | binary(), services = [] :: [] | list(#'Service'{}), @@ -292,13 +291,13 @@ created = 0 :: [] | integer()}). -record(error, {code = [] :: [] | atom()}). --record(ok, {code = [] :: [] | added | sms_sent | call_in_progress | push | cleared | logout | binary()}). +-record(ok, {code = [] :: [] | sms_sent | call_in_progress | push | cleared | logout | added | binary()}). -record(error2, {code = [] :: [] | atom(), src=[] :: [] | binary() | integer() }). -record(ok2, {code = [] :: [] | atom(), src=[] :: [] | {binary(), binary()} | binary() }). -record(io, {code = [] :: [] | #ok{} | #error{} | #ok2{} | #error2{}, - data = <<>> :: [] | <<>> | binary() | #'Roster'{} | #ok{} | { atom(), binary() | integer()}}). + data = <<>> :: [] | <<>> | binary() | #'Roster'{} | { atom(), binary() | integer()} | #error{}}). -record('Ack', {table = 'Message' :: atom(), id = [] :: [] | binary()}). diff --git a/apps/roster/src/api/google_api.erl b/apps/roster/src/api/google_api.erl index d8a43ec81..f5756937f 100644 --- a/apps/roster/src/api/google_api.erl +++ b/apps/roster/src/api/google_api.erl @@ -1,5 +1,5 @@ -module(google_api). - +-dialyzer({nowarn_function, gs_upload/3}). -compile(export_all). -include_lib("enenra/include/enenra.hrl"). diff --git a/apps/roster/src/processes/job_process.erl b/apps/roster/src/processes/job_process.erl index 4662dec78..1bd0da741 100644 --- a/apps/roster/src/processes/job_process.erl +++ b/apps/roster/src/processes/job_process.erl @@ -1,7 +1,7 @@ -module(job_process). -include("roster.hrl"). -compile(export_all). - +-dialyzer({nowarn_function, [definition/0,definition/1]}). definition() -> #process { name = 'Schedule', diff --git a/apps/roster/src/protocol/roster_bpe.erl b/apps/roster/src/protocol/roster_bpe.erl index 3dbc3aa90..e095aed7f 100644 --- a/apps/roster/src/protocol/roster_bpe.erl +++ b/apps/roster/src/protocol/roster_bpe.erl @@ -349,7 +349,7 @@ proc({clean, #'process'{id = Id} = P}, #pi{state = {C, Proc}} = H) -> bpe:complete(Id), {value, #boundaryEvent{timeout = BT}, _} = lists:keytake('*', #boundaryEvent.name, bpe:events(P)), %bpe:find_pid(Id) ! {'DOWN', <<>>, <<>>, <<>>, <<>>}, - timer:apply_after(roster:daystimeToms(BT) + 5000, bpe, cleanup, [Id]), + timer:apply_after(roster:daystime_to_ms(BT) + 5000, bpe, cleanup, [Id]), {reply, [], H}; proc({send, Msgs}, #pi{state = {C, Proc}} = H) -> diff --git a/apps/roster/src/protocol/roster_profile.erl b/apps/roster/src/protocol/roster_profile.erl index 38ac5bf3b..655cb0226 100644 --- a/apps/roster/src/protocol/roster_profile.erl +++ b/apps/roster/src/protocol/roster_profile.erl @@ -127,7 +127,7 @@ del_roster(UID,RosterId) -> roster:unsubscribe_p2p(UID, RosterId), roster:remove_member(PId), roster:unsubscribe_muc(PId), - [roster:update_writer(#muc{name=Name},{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = <<"Deleted">>}]}) + [roster:update_writer(#muc{name=Name},{#'Message'.from, PId},{#'Message'.files,[#'Desc'{payload = <<"Deleted">>}]}) || #'Room'{id=Name} <- Rooms], [roster:update_writer(roster:feed_key(p2p,PId,FId),{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = <<"Deleted">>}]}) || #'Contact'{phone_id = FId} <- Conts], diff --git a/apps/roster/src/rest/rest_handler.erl b/apps/roster/src/rest/rest_handler.erl index 59dd9b26e..e1f8e121f 100644 --- a/apps/roster/src/rest/rest_handler.erl +++ b/apps/roster/src/rest/rest_handler.erl @@ -58,7 +58,6 @@ handle_request(Req) -> _ -> case rest_auth_helper:authorized(Req) of false -> rest_response_helper:response(Req, ?HTTP_CODE_401, rest_response_helper:error_401()); {error, invalid_token} -> rest_response_helper:error_response_api(Req, ?HTTP_CODE_401, "Token is invalid."); - {error, token_expired} -> rest_response_helper:error_response_api(Req, ?HTTP_CODE_401, "Token is expired."); {true, api} -> handle_request2(Req:get(method), Req:get(path), Req); %% We hit here if authentication is Bearer (Not Basic) _ -> handle_request(Req:get(method), Req:get(path), Req) end diff --git a/apps/roster/src/roster.erl b/apps/roster/src/roster.erl index d31333019..a399b7785 100644 --- a/apps/roster/src/roster.erl +++ b/apps/roster/src/roster.erl @@ -527,7 +527,7 @@ delete_msg(PhoneId) -> update_writer(Feed,{E1,V1},{E2,V2})-> case kvs_stream:load_writer(Feed) of - #writer{cache =[_|_]= M}=W -> + #writer{cache = #'Message'{}= M}=W -> case element(E1,M)==V1 of true -> M1=erlang:setelement(E2,M,V2), kvs_stream:save(W#writer{cache = M1}); @@ -871,8 +871,7 @@ member_lastmsg2(PhoneId, Room) -> R -> R end. add_member(#'Room'{} = R, #'Member'{} = M) -> add_member(R, M, {no_muc_message, []}). -add_member(#'Room'{} = R, #'Member'{id = MId, reader = 0, feed_id = Feed, phone_id = PhoneId, alias = Alias} = M, - {MsgPayload, HL} = Args) -> +add_member(#'Room'{} = R, #'Member'{id = MId, reader = 0, feed_id = Feed, phone_id = PhoneId, alias = Alias} = M, {MsgPayload, HL} = Args) -> case kvs:get('Roster', roster_id(PhoneId)) of {ok, #'Roster'{nick = Nick, names = Names, surnames = Surnames, avatar = Avatar}} -> Alias2 = case Alias of EmptyAlias when EmptyAlias == []; EmptyAlias == <<>> -> Nick; _ -> Alias end, @@ -889,21 +888,20 @@ add_member(#'Room'{} = R, #'Member'{id = MId, reader = 0, feed_id = Feed, phone_ {M2, Msg, Room}; #error{} -> {error, roster_not_found} %% TODO add error handler end; -add_member(#'Room'{} = R, #'Member'{feed_id = #muc{name = Room} = Feed, alias = Alias, - phone_id = Roster = #'Roster'{id = RosterId, phone = Phone, - names = Name, surnames = Surname}} = M, {MsgPayload, _}) -> - PhoneId = phone_id(Phone, RosterId), - Msg = case MsgPayload of - no_muc_message -> []; - _ -> #writer{cache = LastMsg} = add_message(#'Message'{status = [], type = [sys], feed_id = Feed, from = PhoneId, to = Room, - files = [#'Desc'{payload = MsgPayload}]}), LastMsg end, - update_rooms(Roster, R), subscribe_room(M2 = M#'Member'{phone_id = PhoneId}), - subscribe_muc(PhoneId, Feed), - {M2#'Member'{alias = member_alias(Alias, Name, Surname)}, Msg, R}; -add_member(#'Room'{} = R, #'Member'{phone_id = PhoneId} = M, Args) -> +add_member(#'Room'{} = R, #'Member'{phone_id = PhoneId, alias = Alias, feed_id = #muc{name = Room} = Feed} = M, {MsgPayload, _}) -> case kvs:get('Roster', roster_id(PhoneId)) of - {ok, Roster} -> add_member(R, M#'Member'{phone_id = Roster}, Args); - #error{} = Err -> Err end. + {ok, Roster = #'Roster'{names = Name, surnames = Surname}} -> + Msg = case MsgPayload of + no_muc_message -> []; + _ -> #writer{cache = LastMsg} = add_message(#'Message'{status = [], type = [sys], + feed_id = Feed, from = PhoneId, to = Room, files = [#'Desc'{payload = MsgPayload}]}), + LastMsg + end, + update_rooms(Roster, R), subscribe_room(M2 = M#'Member'{phone_id = PhoneId}), + subscribe_muc(PhoneId, Feed), + {M2#'Member'{alias = member_alias(Alias, Name, Surname)}, Msg, R}; + #error{} = Err -> Err + end. member_alias([], [], []) -> []; member_alias([], N, []) -> N; member_alias([], [], S) -> S; member_alias([], Name, Surname) when Name /= [], Surname /= [] -> <>/binary, Surname/binary>>; @@ -978,7 +976,7 @@ contact_readmsg(LocalPhoneId, PhoneId) -> _ -> 0 end. %% TODO need refactoring. Reader may be found by feed? update_room(#'Roster'{roomlist = Rooms} = Roster, #'Room'{status = Status} = Room)-> - kvs:put(Roster#'Roster'{roomlist = lists:keyreplace(#'Room'.id, Room)}). + kvs:put(Roster#'Roster'{roomlist = lists:keyreplace(Room#'Room'.id, #'Room'.id, Rooms, Room)}). update_rooms(#'Roster'{roomlist = Rooms} = Roster, #'Room'{status = Status} = R) -> R2 = case Status of removed -> R;_ -> R#'Room'{last_msg = []} end, diff --git a/apps/roster/src/roster_db.erl b/apps/roster/src/roster_db.erl index 1e52bd2de..74d1ed44a 100644 --- a/apps/roster/src/roster_db.erl +++ b/apps/roster/src/roster_db.erl @@ -8,7 +8,7 @@ -include_lib("kvs/include/metainfo.hrl"). -include_lib("roster/include/static/main_var.hrl"). -include_lib("roster/include/static/rest_text.hrl"). - +-dialyzer({nowarn_function, fold/5}). fix_msg_container() -> RosterRes = lists:flatten([case R#'Roster'{favorite = [Msg#'Message'{container = chain} ||#'ExtendedStar'{star = Msg}<-Stars]} of R -> []; R2 -> kvs:put(R2) @@ -53,7 +53,7 @@ fix_empty_desc_ids() -> find_invalid_rooms(Id) when is_integer(Id) -> find_invalid_rooms(Id, []). find_invalid_rooms(#'Roster'{roomlist = Rooms} = Roster, N) -> lists:flatten([case catch roster:room(Roster, R2) of - {'EXIT', _} -> false = R2; + {'EXIT', _} -> throw(R2); Room -> Room end || R2 = #'Room'{} <- case N of [] -> Rooms;_ -> roster:last_rooms(Rooms, 100) end]); @@ -499,7 +499,7 @@ to_rec('LinkRoster', #{<<"id">> := Uuid, <<"phone_id">> := PhoneId}) -> import_json(Table, File) -> lists:map(fun kvs:put/1, to_rec(Table, File)). backup()-> ExcTabs= [mqtt_session,mqtt_admin], - backup(mnesia:system_info(tables)-ExcTabs). + backup(mnesia:system_info(tables)--ExcTabs). backup(Tabs) -> Date = roster:local_time_as_gmt(calendar:local_time()), diff --git a/apps/roster/src/test/friend_test.erl b/apps/roster/src/test/friend_test.erl index 232bf39b5..192023d6c 100644 --- a/apps/roster/src/test/friend_test.erl +++ b/apps/roster/src/test/friend_test.erl @@ -4,14 +4,16 @@ -export([make_friends/2]). -send_friend_request(User1PhoneId, User2PhoneId) -> +send_friend_request(_User1PhoneId, _User2PhoneId) -> ok. -confirm_friend_request(User1PhoneId, User2PhoneId) -> +confirm_friend_request(_User1PhoneId, _User2PhoneId) -> ok. make_friends(User1PhoneId, User2PhoneId) -> %% Steps %% 1 - User1 - send friend request %% 2 - User2 - confirm friend request + ok = send_friend_request(User1PhoneId, User2PhoneId), + ok = confirm_friend_request(User1PhoneId, User2PhoneId), ok. \ No newline at end of file diff --git a/apps/roster/src/test/main_test.erl b/apps/roster/src/test/main_test.erl index d9d3166d2..11451d5e6 100644 --- a/apps/roster/src/test/main_test.erl +++ b/apps/roster/src/test/main_test.erl @@ -19,7 +19,7 @@ remove_fake_users_data() -> muc_msgs() -> RoomName = Room = <<"test_room_777">>, - Phones = [{APhone = <<"73777">>, admin}, {<<"79773">>, admin}, {<<"173737">>, member}, {<<"273747">>, member}], + Phones = [{_APhone = <<"73777">>, admin}, {<<"79773">>, admin}, {<<"173737">>, member}, {<<"273747">>, member}], %% Room2 = get_room_id(APhone, RoomName), Counter = length(Phones), roster:purge_room(Room), @@ -33,7 +33,6 @@ muc_msgs() -> Member = #'Member'{presence = online, feed_id = Feed, phone_id = PhoneId, status = Aff}, {PhoneId, ClientId, Member} end || {Phone, Aff} <- Phones], - _ = [ClientId || {_, ClientId, _, _} <- PCs], {Admins, Members} = roster:split_members([M || {_, _, M} <- TPCs]), roster_client:set_filer([AClientId, CClientId], filter_friend), roster_client:send_receive(AClientId, 2, #'Friend'{phone_id = APhoneId, friend_id = CPhoneId, status = request}), @@ -76,7 +75,7 @@ muc_msgs() -> [#'Message'{id = BFid, type = [read]}, #'Room'{}] = roster_client:send_receive(DClientId, last_res), %% Edit with msg_id - #'Message'{files = F} = roster_client:send_receive(BClientId, Counter, #'Message'{id=BFid, msg_id = <>, feed_id=#muc{name = Room}, + #'Message'{files = _F} = roster_client:send_receive(BClientId, Counter, #'Message'{id=BFid, msg_id = <>, feed_id=#muc{name = Room}, from=BPhoneId, files = [#'Desc'{id= <<"7">>, payload = <<"Edited by B!">>}], status = edit}), #'Ack'{} = roster_client:send_receive(BClientId, #'Message'{id=BFid, msg_id = <>, feed_id=#muc{name = Room}, diff --git a/apps/roster/src/test/room_test.erl b/apps/roster/src/test/room_test.erl index 2f8f7315e..1b85a50f9 100644 --- a/apps/roster/src/test/room_test.erl +++ b/apps/roster/src/test/room_test.erl @@ -7,7 +7,8 @@ check_alias_increment/0, add_many_members/0, link/0, - test_joinlink/0 + test_joinlink/0, + suite/0 ]). -define(BLANK_LINK, <<"UNDEFINED">>). diff --git a/apps/roster/src/test/roster_test.erl b/apps/roster/src/test/roster_test.erl index 68580f3f3..1120f5aa2 100644 --- a/apps/roster/src/test/roster_test.erl +++ b/apps/roster/src/test/roster_test.erl @@ -5,6 +5,36 @@ -include_lib("emqttc/include/emqttc_packet.hrl"). -include("roster.hrl"). -include("roster_test.hrl"). +-dialyzer({nowarn_function, + [ + test_roster/0, + test_update_contacts/0, + misc_test_roster/1, + test_reg/0, + test_reg/1, + test_reg_jwt/0, + test_friend_multi/0, + test_muc/0, + test_muc_msgs/0, + test_descs/0, + test_multi_muc/0, + test_room/0, + clear_room_msg_test/0, + myself_chat_test/0, + delete_p2p_history_test/0, + patch_nick_test/0, + transcribe_test/0, + p2p_reader_test/0, + clear_test_only_admin/0, + reply_history_test/0, + history_update_test/0, + muc_remove_test/0, + test_call_room/0, + pagination_test/0, + event_securty_test/0, + test_search/0 + ] +}). -define(MAX_ATTEMPTS, 3). @@ -425,8 +455,8 @@ test_roster() -> % roster:info("Term value: ~p", [Rosters]). ok. -test_huge_messages2(M, N) -> - spawn(fun() -> [roster_client:test_huge_messages(N) || _ <- lists:seq(1, M)] end). +% test_huge_messages2(M, N) -> + % spawn(fun() -> [roster_client:test_huge_messages(N) || _ <- lists:seq(1, M)] end). test_huge_messages(N) -> Phones = [PhoneA, PhoneB] = [integer_to_binary(rand:uniform(99999999)) || _ <- [1, 2]], Counter = length(Phones), @@ -446,12 +476,12 @@ test_huge_messages(N) -> roster_client:receive_drop(), Created = roster:now_msec(), FeedId = roster:feed_key(p2p, From, To), - Msg = kvs:add(#'Message'{feed_id = FeedId, created = Created, status = []}), + {ok, Msg} = kvs:add(#'Message'{feed_id = FeedId, created = Created, status = []}), [begin - kvs:add(Msg#'Message'{id = kvs:next_id('Message', 1), + kvs:add(Msg#'Message'{id = kvs:next_id('Message', 1), from = From, to = To, files = [#'Desc'{id = <<"7">>, payload = <<"TestA!">>}], status = []}), timer:sleep(1), - kvs:add(Msg#'Message'{id = kvs:next_id('Message', 1), + kvs:add(Msg#'Message'{id = kvs:next_id('Message', 1), from = To, to = From, files = [#'Desc'{id = <<"7">>, payload = <<"TestB!">>}], status = []}) end || _ <- lists:seq(1, N)], roster_client:stop_client(AClientId), roster_client:stop_client(BClientId). diff --git a/rebar.config.script b/rebar.config.script index e1e5c7da4..bd3898f78 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -2,7 +2,7 @@ OSENV = os:getenv("REBAR_DEPS"). SetAppEnv = fun(App,Config)-> [ application:set_env(App,Key,Value) || {Key,Value} <- proplists:get_value(App,Config)] end. {ok,[SysConf]}=file:consult('sys.config'). SetAppEnv(bert,SysConf). -io:format("Disallowed: ~p~n",[application:get_env(bert,disallowed,[])]). +%% io:format("Disallowed: ~p~n",[application:get_env(bert,disallowed,[])]). case OSENV of false -> CONFIG; % env var not defined [] -> CONFIG; % env var set to empty string -- GitLab From 2143fcc1e18519bff8f83d1bc313f9141d24490d Mon Sep 17 00:00:00 2001 From: "radostin.dimitrov" Date: Tue, 23 Jul 2019 21:31:33 +0300 Subject: [PATCH 20/20] [NY-7291] dev merge devlyzer --- .gitignore | 44 +- apps/rebar.config | 2 +- apps/roster/include/rest_static.hrl | 2 +- apps/roster/include/roster.hrl | 65 +- apps/roster/priv/macbert/Model/Ack.swift | 5 - apps/roster/priv/macbert/Model/Auth.swift | 17 - apps/roster/priv/macbert/Model/CDR.swift | 16 - apps/roster/priv/macbert/Model/Call.swift | 10 - .../priv/macbert/Model/CallMember.swift | 16 - apps/roster/priv/macbert/Model/Contact.swift | 17 - apps/roster/priv/macbert/Model/Cursor.swift | 6 - apps/roster/priv/macbert/Model/Desc.swift | 8 - .../priv/macbert/Model/ExtendedStar.swift | 5 - apps/roster/priv/macbert/Model/Feature.swift | 7 - apps/roster/priv/macbert/Model/Friend.swift | 7 - apps/roster/priv/macbert/Model/History.swift | 9 - apps/roster/priv/macbert/Model/Index.swift | 5 - apps/roster/priv/macbert/Model/Job.swift | 15 - apps/roster/priv/macbert/Model/Link.swift | 9 - apps/roster/priv/macbert/Model/Loc.swift | 6 - apps/roster/priv/macbert/Model/Member.swift | 20 - apps/roster/priv/macbert/Model/Message.swift | 19 - apps/roster/priv/macbert/Model/Person.swift | 14 - apps/roster/priv/macbert/Model/Profile.swift | 11 - .../priv/macbert/Model/PushService.swift | 9 - apps/roster/priv/macbert/Model/Room.swift | 21 - apps/roster/priv/macbert/Model/Roster.swift | 16 - apps/roster/priv/macbert/Model/Schedule.swift | 7 - apps/roster/priv/macbert/Model/Search.swift | 9 - apps/roster/priv/macbert/Model/Service.swift | 10 - apps/roster/priv/macbert/Model/Star.swift | 9 - .../priv/macbert/Model/StickerPack.swift | 12 - apps/roster/priv/macbert/Model/Tag.swift | 7 - apps/roster/priv/macbert/Model/Test.swift | 5 - apps/roster/priv/macbert/Model/Typing.swift | 5 - apps/roster/priv/macbert/Model/Vox.swift | 6 - apps/roster/priv/macbert/Model/act.swift | 5 - apps/roster/priv/macbert/Model/amend.swift | 5 - .../priv/macbert/Model/beginEvent.swift | 6 - .../priv/macbert/Model/boundaryEvent.swift | 11 - apps/roster/priv/macbert/Model/chain.swift | 7 - apps/roster/priv/macbert/Model/complete.swift | 4 - .../roster/priv/macbert/Model/container.swift | 7 - apps/roster/priv/macbert/Model/create.swift | 5 - apps/roster/priv/macbert/Model/cur.swift | 10 - apps/roster/priv/macbert/Model/endEvent.swift | 6 - apps/roster/priv/macbert/Model/error.swift | 4 - apps/roster/priv/macbert/Model/error2.swift | 5 - apps/roster/priv/macbert/Model/errors.swift | 5 - apps/roster/priv/macbert/Model/hist.swift | 13 - apps/roster/priv/macbert/Model/histo.swift | 4 - apps/roster/priv/macbert/Model/io.swift | 5 - apps/roster/priv/macbert/Model/iter.swift | 8 - apps/roster/priv/macbert/Model/iterator.swift | 9 - .../priv/macbert/Model/join_application.swift | 6 - apps/roster/priv/macbert/Model/log.swift | 7 - apps/roster/priv/macbert/Model/max_tour.swift | 5 - .../priv/macbert/Model/messageEvent.swift | 8 - apps/roster/priv/macbert/Model/mqi.swift | 6 - apps/roster/priv/macbert/Model/muc.swift | 4 - apps/roster/priv/macbert/Model/ok.swift | 4 - apps/roster/priv/macbert/Model/ok2.swift | 5 - .../roster/priv/macbert/Model/operation.swift | 9 - apps/roster/priv/macbert/Model/p2p.swift | 5 - apps/roster/priv/macbert/Model/proc.swift | 4 - apps/roster/priv/macbert/Model/process.swift | 25 - apps/roster/priv/macbert/Model/push.swift | 9 - apps/roster/priv/macbert/Model/reader.swift | 9 - .../priv/macbert/Model/receiveTask.swift | 7 - .../priv/macbert/Model/sequenceFlow.swift | 5 - .../priv/macbert/Model/serviceTask.swift | 7 - apps/roster/priv/macbert/Model/task.swift | 7 - .../priv/macbert/Model/timeoutEvent.swift | 11 - .../roster/priv/macbert/Model/tour_list.swift | 4 - apps/roster/priv/macbert/Model/userTask.swift | 7 - apps/roster/priv/macbert/Model/writer.swift | 8 - apps/roster/priv/macbert/Source/Bert.swift | 693 ------------ apps/roster/priv/macbert/Source/Decoder.swift | 364 ------- apps/roster/priv/macbert/Source/Encoder.swift | 382 ------- .../priv/macbert/Source/StringAtom.swift | 16 - .../roster/priv/macbert/Source/TypeSpec.swift | 376 ------- apps/roster/priv/macbert/Spec/Ack_Spec.swift | 6 - apps/roster/priv/macbert/Spec/Auth_Spec.swift | 47 - apps/roster/priv/macbert/Spec/CDR_Spec.swift | 38 - .../priv/macbert/Spec/CallMember_Spec.swift | 48 - apps/roster/priv/macbert/Spec/Call_Spec.swift | 24 - .../priv/macbert/Spec/Contact_Spec.swift | 51 - .../priv/macbert/Spec/Cursor_Spec.swift | 9 - apps/roster/priv/macbert/Spec/Desc_Spec.swift | 13 - .../priv/macbert/Spec/ExtendedStar_Spec.swift | 9 - .../priv/macbert/Spec/Feature_Spec.swift | 8 - .../priv/macbert/Spec/Friend_Spec.swift | 14 - .../priv/macbert/Spec/History_Spec.swift | 38 - .../roster/priv/macbert/Spec/Index_Spec.swift | 6 - apps/roster/priv/macbert/Spec/Job_Spec.swift | 45 - apps/roster/priv/macbert/Spec/Link_Spec.swift | 27 - apps/roster/priv/macbert/Spec/Loc_Spec.swift | 11 - .../priv/macbert/Spec/Member_Spec.swift | 58 -- .../priv/macbert/Spec/Message_Spec.swift | 60 -- .../priv/macbert/Spec/Person_Spec.swift | 15 - .../priv/macbert/Spec/Profile_Spec.swift | 31 - .../priv/macbert/Spec/PushService_Spec.swift | 18 - apps/roster/priv/macbert/Spec/Room_Spec.swift | 60 -- .../priv/macbert/Spec/Roster_Spec.swift | 45 - .../priv/macbert/Spec/Schedule_Spec.swift | 12 - .../priv/macbert/Spec/Search_Spec.swift | 16 - .../priv/macbert/Spec/Service_Spec.swift | 26 - apps/roster/priv/macbert/Spec/Star_Spec.swift | 17 - .../priv/macbert/Spec/StickerPack_Spec.swift | 19 - apps/roster/priv/macbert/Spec/Tag_Spec.swift | 12 - apps/roster/priv/macbert/Spec/Test_Spec.swift | 9 - .../priv/macbert/Spec/Typing_Spec.swift | 4 - apps/roster/priv/macbert/Spec/Vox_Spec.swift | 11 - apps/roster/priv/macbert/Spec/act_Spec.swift | 9 - .../roster/priv/macbert/Spec/amend_Spec.swift | 8 - .../priv/macbert/Spec/beginEvent_Spec.swift | 9 - .../macbert/Spec/boundaryEvent_Spec.swift | 19 - .../roster/priv/macbert/Spec/chain_Spec.swift | 12 - .../priv/macbert/Spec/complete_Spec.swift | 5 - .../priv/macbert/Spec/container_Spec.swift | 12 - .../priv/macbert/Spec/create_Spec.swift | 9 - apps/roster/priv/macbert/Spec/cur_Spec.swift | 21 - .../priv/macbert/Spec/endEvent_Spec.swift | 9 - .../priv/macbert/Spec/error2_Spec.swift | 9 - .../roster/priv/macbert/Spec/error_Spec.swift | 5 - .../priv/macbert/Spec/errors_Spec.swift | 8 - apps/roster/priv/macbert/Spec/hist_Spec.swift | 20 - .../roster/priv/macbert/Spec/histo_Spec.swift | 5 - apps/roster/priv/macbert/Spec/io_Spec.swift | 17 - apps/roster/priv/macbert/Spec/iter_Spec.swift | 13 - .../priv/macbert/Spec/iterator_Spec.swift | 14 - .../macbert/Spec/join_application_Spec.swift | 5 - apps/roster/priv/macbert/Spec/log_Spec.swift | 12 - .../priv/macbert/Spec/max_tour_Spec.swift | 4 - .../priv/macbert/Spec/messageEvent_Spec.swift | 16 - apps/roster/priv/macbert/Spec/mqi_Spec.swift | 11 - apps/roster/priv/macbert/Spec/muc_Spec.swift | 3 - apps/roster/priv/macbert/Spec/ok2_Spec.swift | 11 - apps/roster/priv/macbert/Spec/ok_Spec.swift | 5 - .../priv/macbert/Spec/operation_Spec.swift | 14 - apps/roster/priv/macbert/Spec/p2p_Spec.swift | 4 - apps/roster/priv/macbert/Spec/proc_Spec.swift | 5 - .../priv/macbert/Spec/process_Spec.swift | 56 - apps/roster/priv/macbert/Spec/push_Spec.swift | 20 - .../priv/macbert/Spec/reader_Spec.swift | 14 - .../priv/macbert/Spec/receiveTask_Spec.swift | 10 - .../priv/macbert/Spec/sequenceFlow_Spec.swift | 9 - .../priv/macbert/Spec/serviceTask_Spec.swift | 10 - apps/roster/priv/macbert/Spec/task_Spec.swift | 10 - .../priv/macbert/Spec/timeoutEvent_Spec.swift | 29 - .../priv/macbert/Spec/tour_list_Spec.swift | 3 - .../priv/macbert/Spec/userTask_Spec.swift | 10 - .../priv/macbert/Spec/writer_Spec.swift | 11 - apps/roster/priv/macbert/json-bert.js | 156 +-- apps/roster/priv/macbert/main.swift | 43 - apps/roster/src/api/google_api.erl | 15 +- apps/roster/src/micro.erl | 4 +- apps/roster/src/processes/job.erl | 37 +- apps/roster/src/processes/job_process.erl | 2 +- apps/roster/src/protocol/micro_auth.erl | 32 +- apps/roster/src/protocol/micro_roster.erl | 2 +- apps/roster/src/protocol/roster_acl.erl | 5 +- apps/roster/src/protocol/roster_auth.erl | 37 +- apps/roster/src/protocol/roster_bpe.erl | 68 +- apps/roster/src/protocol/roster_friend.erl | 18 +- apps/roster/src/protocol/roster_ftp.erl | 42 +- apps/roster/src/protocol/roster_history.erl | 17 +- apps/roster/src/protocol/roster_link.erl | 27 +- apps/roster/src/protocol/roster_message.erl | 33 +- apps/roster/src/protocol/roster_presence.erl | 2 +- apps/roster/src/protocol/roster_profile.erl | 16 +- apps/roster/src/protocol/roster_push.erl | 6 +- apps/roster/src/protocol/roster_room.erl | 42 +- apps/roster/src/protocol/roster_roster.erl | 31 +- apps/roster/src/protocol/roster_search.erl | 12 +- apps/roster/src/rest/rest_chat_csv.erl | 27 +- apps/roster/src/rest/rest_cri.erl | 1 + apps/roster/src/rest/rest_handler.erl | 2 - apps/roster/src/rest/rest_message.erl | 2 +- apps/roster/src/rest/rest_push.erl | 2 +- apps/roster/src/rest/rest_transcribe.erl | 8 +- apps/roster/src/roster.app.src | 34 +- apps/roster/src/roster.erl | 113 +- apps/roster/src/roster_channel_helper.erl | 10 +- apps/roster/src/roster_client.erl | 46 +- apps/roster/src/roster_data.erl | 6 +- apps/roster/src/roster_db.erl | 13 +- apps/roster/src/roster_export.erl | 37 - apps/roster/src/roster_validator.erl | 982 ------------------ apps/roster/src/test/friend_test.erl | 6 +- apps/roster/src/test/main_test.erl | 5 +- apps/roster/src/test/room_test.erl | 3 +- apps/roster/src/test/roster_test.erl | 56 +- apps/service/rebar.config | 2 +- priv/protobuf/service_auth/Auth.proto | 30 - priv/protobuf/service_auth/Desc.proto | 19 - priv/protobuf/service_auth/Service.proto | 22 - priv/protobuf/service_auth/Tag.proto | 18 - priv/protobuf/service_auth/authOs.proto | 17 - priv/protobuf/service_auth/presence.proto | 16 - priv/protobuf/service_auth/serverType.proto | 19 - priv/protobuf/service_friend/Desc.proto | 19 - priv/protobuf/service_friend/Feature.proto | 17 - priv/protobuf/service_message/Feature.proto | 17 - priv/protobuf/service_message/Service.proto | 22 - priv/protobuf/service_message/Tag.proto | 18 - priv/protobuf/service_message/p2p.proto | 15 - priv/protobuf/service_profile/Desc.proto | 19 - priv/protobuf/service_profile/Tag.proto | 18 - priv/protobuf/service_roster/Desc.proto | 19 - priv/protobuf/service_roster/Service.proto | 22 - priv/protobuf/service_roster/serverType.proto | 19 - priv/protobuf/service_roster/tagType.proto | 17 - rebar.config | 51 +- rebar.config.script | 10 + rebar.lock | 164 --- sys.config | 7 +- 217 files changed, 610 insertions(+), 5833 deletions(-) delete mode 100644 apps/roster/priv/macbert/Model/Ack.swift delete mode 100644 apps/roster/priv/macbert/Model/Auth.swift delete mode 100644 apps/roster/priv/macbert/Model/CDR.swift delete mode 100644 apps/roster/priv/macbert/Model/Call.swift delete mode 100644 apps/roster/priv/macbert/Model/CallMember.swift delete mode 100644 apps/roster/priv/macbert/Model/Contact.swift delete mode 100644 apps/roster/priv/macbert/Model/Cursor.swift delete mode 100644 apps/roster/priv/macbert/Model/Desc.swift delete mode 100644 apps/roster/priv/macbert/Model/ExtendedStar.swift delete mode 100644 apps/roster/priv/macbert/Model/Feature.swift delete mode 100644 apps/roster/priv/macbert/Model/Friend.swift delete mode 100644 apps/roster/priv/macbert/Model/History.swift delete mode 100644 apps/roster/priv/macbert/Model/Index.swift delete mode 100644 apps/roster/priv/macbert/Model/Job.swift delete mode 100644 apps/roster/priv/macbert/Model/Link.swift delete mode 100644 apps/roster/priv/macbert/Model/Loc.swift delete mode 100644 apps/roster/priv/macbert/Model/Member.swift delete mode 100644 apps/roster/priv/macbert/Model/Message.swift delete mode 100644 apps/roster/priv/macbert/Model/Person.swift delete mode 100644 apps/roster/priv/macbert/Model/Profile.swift delete mode 100644 apps/roster/priv/macbert/Model/PushService.swift delete mode 100644 apps/roster/priv/macbert/Model/Room.swift delete mode 100644 apps/roster/priv/macbert/Model/Roster.swift delete mode 100644 apps/roster/priv/macbert/Model/Schedule.swift delete mode 100644 apps/roster/priv/macbert/Model/Search.swift delete mode 100644 apps/roster/priv/macbert/Model/Service.swift delete mode 100644 apps/roster/priv/macbert/Model/Star.swift delete mode 100644 apps/roster/priv/macbert/Model/StickerPack.swift delete mode 100644 apps/roster/priv/macbert/Model/Tag.swift delete mode 100644 apps/roster/priv/macbert/Model/Test.swift delete mode 100644 apps/roster/priv/macbert/Model/Typing.swift delete mode 100644 apps/roster/priv/macbert/Model/Vox.swift delete mode 100644 apps/roster/priv/macbert/Model/act.swift delete mode 100644 apps/roster/priv/macbert/Model/amend.swift delete mode 100644 apps/roster/priv/macbert/Model/beginEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/boundaryEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/chain.swift delete mode 100644 apps/roster/priv/macbert/Model/complete.swift delete mode 100644 apps/roster/priv/macbert/Model/container.swift delete mode 100644 apps/roster/priv/macbert/Model/create.swift delete mode 100644 apps/roster/priv/macbert/Model/cur.swift delete mode 100644 apps/roster/priv/macbert/Model/endEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/error.swift delete mode 100644 apps/roster/priv/macbert/Model/error2.swift delete mode 100644 apps/roster/priv/macbert/Model/errors.swift delete mode 100644 apps/roster/priv/macbert/Model/hist.swift delete mode 100644 apps/roster/priv/macbert/Model/histo.swift delete mode 100644 apps/roster/priv/macbert/Model/io.swift delete mode 100644 apps/roster/priv/macbert/Model/iter.swift delete mode 100644 apps/roster/priv/macbert/Model/iterator.swift delete mode 100644 apps/roster/priv/macbert/Model/join_application.swift delete mode 100644 apps/roster/priv/macbert/Model/log.swift delete mode 100644 apps/roster/priv/macbert/Model/max_tour.swift delete mode 100644 apps/roster/priv/macbert/Model/messageEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/mqi.swift delete mode 100644 apps/roster/priv/macbert/Model/muc.swift delete mode 100644 apps/roster/priv/macbert/Model/ok.swift delete mode 100644 apps/roster/priv/macbert/Model/ok2.swift delete mode 100644 apps/roster/priv/macbert/Model/operation.swift delete mode 100644 apps/roster/priv/macbert/Model/p2p.swift delete mode 100644 apps/roster/priv/macbert/Model/proc.swift delete mode 100644 apps/roster/priv/macbert/Model/process.swift delete mode 100644 apps/roster/priv/macbert/Model/push.swift delete mode 100644 apps/roster/priv/macbert/Model/reader.swift delete mode 100644 apps/roster/priv/macbert/Model/receiveTask.swift delete mode 100644 apps/roster/priv/macbert/Model/sequenceFlow.swift delete mode 100644 apps/roster/priv/macbert/Model/serviceTask.swift delete mode 100644 apps/roster/priv/macbert/Model/task.swift delete mode 100644 apps/roster/priv/macbert/Model/timeoutEvent.swift delete mode 100644 apps/roster/priv/macbert/Model/tour_list.swift delete mode 100644 apps/roster/priv/macbert/Model/userTask.swift delete mode 100644 apps/roster/priv/macbert/Model/writer.swift delete mode 100644 apps/roster/priv/macbert/Source/Bert.swift delete mode 100644 apps/roster/priv/macbert/Source/Decoder.swift delete mode 100644 apps/roster/priv/macbert/Source/Encoder.swift delete mode 100644 apps/roster/priv/macbert/Source/StringAtom.swift delete mode 100644 apps/roster/priv/macbert/Source/TypeSpec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Ack_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Auth_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/CDR_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/CallMember_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Call_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Contact_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Cursor_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Desc_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/ExtendedStar_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Feature_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Friend_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/History_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Index_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Job_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Link_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Loc_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Member_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Message_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Person_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Profile_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/PushService_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Room_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Roster_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Schedule_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Search_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Service_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Star_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/StickerPack_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Tag_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Test_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Typing_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/Vox_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/act_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/amend_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/beginEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/boundaryEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/chain_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/complete_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/container_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/create_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/cur_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/endEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/error2_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/error_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/errors_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/hist_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/histo_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/io_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/iter_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/iterator_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/join_application_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/log_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/max_tour_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/messageEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/mqi_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/muc_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/ok2_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/ok_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/operation_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/p2p_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/proc_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/process_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/push_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/reader_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/receiveTask_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/sequenceFlow_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/serviceTask_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/task_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/timeoutEvent_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/tour_list_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/userTask_Spec.swift delete mode 100644 apps/roster/priv/macbert/Spec/writer_Spec.swift delete mode 100644 apps/roster/priv/macbert/main.swift delete mode 100644 apps/roster/src/roster_export.erl delete mode 100644 apps/roster/src/roster_validator.erl delete mode 100644 priv/protobuf/service_auth/Auth.proto delete mode 100644 priv/protobuf/service_auth/Desc.proto delete mode 100644 priv/protobuf/service_auth/Service.proto delete mode 100644 priv/protobuf/service_auth/Tag.proto delete mode 100644 priv/protobuf/service_auth/authOs.proto delete mode 100644 priv/protobuf/service_auth/presence.proto delete mode 100644 priv/protobuf/service_auth/serverType.proto delete mode 100644 priv/protobuf/service_friend/Desc.proto delete mode 100644 priv/protobuf/service_friend/Feature.proto delete mode 100644 priv/protobuf/service_message/Feature.proto delete mode 100644 priv/protobuf/service_message/Service.proto delete mode 100644 priv/protobuf/service_message/Tag.proto delete mode 100644 priv/protobuf/service_message/p2p.proto delete mode 100644 priv/protobuf/service_profile/Desc.proto delete mode 100644 priv/protobuf/service_profile/Tag.proto delete mode 100644 priv/protobuf/service_roster/Desc.proto delete mode 100644 priv/protobuf/service_roster/Service.proto delete mode 100644 priv/protobuf/service_roster/serverType.proto delete mode 100644 priv/protobuf/service_roster/tagType.proto create mode 100644 rebar.config.script delete mode 100644 rebar.lock diff --git a/.gitignore b/.gitignore index 727e3341c..3e570128a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +erl_crash.dump + deps/ log/ **/*.java @@ -17,39 +19,13 @@ workspace.xml .DS_Store _build -# Excessive for iOS models -apps/roster/priv/macbert/Model/PublishService.swift -apps/roster/priv/macbert/Model/Whitelist.swift -apps/roster/priv/macbert/Model/feed.swift -apps/roster/priv/macbert/Spec/PublishService_Spec.swift -apps/roster/priv/macbert/Spec/Whitelist_Spec.swift -apps/roster/priv/macbert/Spec/feed_Spec.swift - .applist 0.3 -priv/protobuf/service_friend/Contact.proto -priv/protobuf/service_friend/Friend.proto -priv/protobuf/service_friend/Roster.proto -priv/protobuf/service_friend/contactStatus.proto -priv/protobuf/service_friend/friendStatus.proto -priv/protobuf/service_friend/muc.proto -priv/protobuf/service_friend/p2p.proto -priv/protobuf/service_friend/rosterStatus.proto -priv/protobuf/service_room/History.proto -priv/protobuf/service_room/Job.proto -priv/protobuf/service_room/Message.proto -priv/protobuf/service_room/act.proto -priv/protobuf/service_room/historyType.proto -priv/protobuf/service_room/jobType.proto -priv/protobuf/service_room/messageEvent.proto -priv/protobuf/service_room/messageStatus.proto -priv/protobuf/service_room/messageType.proto -apps/roster/priv/macbert/Model/FakeNumbers.swift -apps/roster/priv/macbert/Model/Presence.swift -apps/roster/priv/macbert/Model/cx.swift -apps/roster/priv/macbert/Model/load.swift -apps/roster/priv/macbert/Spec/FakeNumbers_Spec.swift -apps/roster/priv/macbert/Spec/Presence_Spec.swift -apps/roster/priv/macbert/Spec/cx_Spec.swift -apps/roster/priv/macbert/Spec/load_Spec.swift -apps/service/priv/ +rebar.lock + +priv/protobuf/* +apps/roster/src/roster_validator.erl + +apps/roster/priv/* +apps/service/priv/* +.tool-versions diff --git a/apps/rebar.config b/apps/rebar.config index c337a9c61..0993ff015 100644 --- a/apps/rebar.config +++ b/apps/rebar.config @@ -1,2 +1,2 @@ -{sub_dirs, [ "roster", "service" ]}. +{sub_dirs, [ "roster" ]}. {deps_dir, ["../deps"]}. diff --git a/apps/roster/include/rest_static.hrl b/apps/roster/include/rest_static.hrl index dcc94d45d..537e16c2b 100644 --- a/apps/roster/include/rest_static.hrl +++ b/apps/roster/include/rest_static.hrl @@ -24,7 +24,7 @@ feed_id = [] :: [] | binary(), call_id = [] :: [] | binary(), type = [] :: [] | binary(), - recipients = [] :: [] | binary(), + recipients = [] :: [] | list(), duration = 0 :: [] | integer(), start_time = 0 :: [] | integer(), status = [] :: [] | binary(), diff --git a/apps/roster/include/roster.hrl b/apps/roster/include/roster.hrl index 4d5755c57..19385eb44 100644 --- a/apps/roster/include/roster.hrl +++ b/apps/roster/include/roster.hrl @@ -57,7 +57,7 @@ sound = [] :: [] | binary()}). -record('Search', {id = [] :: integer() | binary(), - ref = [] :: binary(), + ref = [] :: [] | binary(), field = [] :: binary(), type = [] :: '==' | '!=' | 'like', value = [] :: list(term() | binary()), @@ -75,8 +75,8 @@ -record('Feature', {id = [] :: [] | binary(), key = [] :: binary(), - value = <<>> :: binary(), - group = ?DUMMY_GROUP :: binary()}). + value = <<>> :: [] | integer() | binary() | true, + group = ?DUMMY_GROUP :: [] | binary()}). -record('Service', {id = [] :: [] | binary(), type = [] :: email | vox | aws | wallet, @@ -87,8 +87,8 @@ status = [] :: [] | verified | added | add | remove}). -record('Member', {id = [] :: [] | integer(), - container = chain :: chain | cur | [], - feed_id = [] :: #muc{} | #p2p{} | [] , + container = chain :: [] | chain | cur, + feed_id = [] :: [] | #muc{} | #p2p{}, prev = [] :: [] | integer(), next = [] :: [] | integer(), feeds = [] :: list(), @@ -96,8 +96,8 @@ avatar = [] :: [] | binary(), names = [] :: [] | binary(), surnames = [] :: [] | binary(), - alias = [] :: [] | binary(), - reader = 0 :: [] | integer(), + alias = [] :: [] | binary() | list(), + reader = 0 :: [] | integer() | #reader{}, update = 0 :: [] | integer(), settings = [] :: [] | list(#'Feature'{}), services = [] :: [] | list(#'Service'{}), @@ -122,7 +122,7 @@ -record('Message', {id = [] :: [] | integer(), container = chain :: chain | cur | [], - feed_id = [] :: #muc{} | #p2p{}, + feed_id = [] :: [] | #muc{} | #p2p{}, prev = [] :: [] | integer(), next = [] :: [] | integer(), msg_id = [] :: [] | binary(), @@ -149,10 +149,10 @@ name = [] :: [] | binary(), links = [] :: [] | list(#'Link'{}), description = [] :: [] | binary(), - settings = [] :: list(#'Feature'{}), - members = [] :: list(#'Member'{}), - admins = [] :: list(#'Member'{}), - data = [] :: list(#'Desc'{}), + settings = [] :: [] | list(#'Feature'{}), + members = [] :: [] | list(#'Member'{}), + admins = [] :: [] | list(#'Member'{}), + data = [] :: [] | list(#'Desc'{}), type = [] :: [] | group | channel | call, tos = [] :: [] | binary(), tos_update = 0 :: [] | integer(), @@ -192,23 +192,25 @@ created = 0 :: [] | integer(), settings = [] :: list(#'Feature'{}), services = [] :: list(#'Service'{}), - presence = [] :: [] | online | offline | binary(), + presence = [] :: [] | online | offline | binary(), status = [] :: [] | request | authorization | ignore | internal - | friend | last_msg | ban | banned | deleted }). + | friend | last_msg | ban | banned | deleted | not_existence | draft}). --record('ExtendedStar', {star = [] :: #'Star'{} | [], - from = [] :: #'Contact'{} | #'Room'{} | []}). +-record('ExtendedStar', {star = [] :: [] | #'Star'{} | #'Message'{}, + from = [] :: [] | #'Contact'{} | #'Room'{} | []}). -record('Auth', {client_id = [] :: [] | binary(), dev_key = [] :: [] | binary(), user_id = [] :: [] | binary(), phone = [] :: [] | binary() | {fake, binary()}, token = [] :: [] | binary(), - type = [] :: [] | atom(), + type = [] :: [] | update | clear | delete | deleted | logout + | verify | verified | expired | reg | resend + | voice | push | get | {ver | reg, string()} | login, sms_code = [] :: [] | binary(), attempts = [] :: [] | integer(), services = [] :: list(term()), - settings = [] :: [] | list(#'Feature'{}), + settings = [] :: [] | binary() | list(#'Feature'{}), push = [] :: [] | binary(), os = [] :: [] | ios | android | web, created = [] :: [] | integer(), @@ -219,24 +221,25 @@ surnames = [] :: [] | binary(), email = [] :: [] | binary(), nick = [] :: [] | binary(), - userlist = [] :: list(#'Contact'{} | integer()), - roomlist = [] :: list(#'Room'{}), - favorite = [] :: list(#'Star'{}), - tags = [] :: list(#'Tag'{}), + userlist = [] :: [] | {list(), list()} | list(#'Contact'{} | integer()), + roomlist = [] :: [] | {list(), list()} | list(#'Room'{}), + favorite = [] :: [] | {list(), list()} | list(#'Star'{} | #'ExtendedStar'{} ), + tags = [] :: [] | list(#'Tag'{}), phone = [] :: [] | binary(), avatar = [] :: [] | binary(), update = 0 :: [] | integer(), status = [] :: [] | get | create | del | remove | nick - | add | update | list | patch | last_msg }). + | search | contact | add | update + | list | patch | last_msg }). -record('Profile', {phone = [] :: [] | binary(), services = [] :: [] | list(#'Service'{}), - rosters = [] :: [] | list(#'Roster'{} | binary()), + rosters = [] :: [] | list(#'Roster'{} | binary() | integer()), settings = [] :: [] | list(#'Feature'{}), update = 0 :: integer(), balance = 0 :: integer(), presence = [] :: [] | offline | online | binary(), - status = [] :: [] | remove | get | patch | update| delete | create }). + status = [] :: [] | remove | get | patch | update| delete | create | init}). -record('Presence', {uid = <<>> :: binary(), status = [] :: [] | offline | online | binary()}). @@ -285,17 +288,17 @@ -record('Index', {id = [] :: [] | term(), roster = [] :: list(term())}). --record('Whitelist', {phone = [] :: [] | binary(), +-record('Whitelist', {phone = [] :: [] | integer() | binary(), created = 0 :: [] | integer()}). -record(error, {code = [] :: [] | atom()}). --record(ok, {code = [] :: [] | binary()}). +-record(ok, {code = [] :: [] | transcribe | sms_sent | call_in_progress | push | cleared | logout | added | binary()}). -record(error2, {code = [] :: [] | atom(), src=[] :: [] | binary() | integer() }). -record(ok2, {code = [] :: [] | atom(), src=[] :: [] | {binary(), binary()} | binary() }). --record(io, {code = [] :: [] | #ok{} | #error{} | #ok2{} | #error2{} | transcribe, - data = <<>> :: [] | <<>> | #'Roster'{} | { atom(), binary() | integer() }}). +-record(io, {code = [] :: [] | atom() | #ok{} | #error{} | #ok2{} | #error2{}, + data = <<>> :: [] | integer() | #'Message'{} | <<>> | binary() | #'Roster'{} | { atom(), binary() | integer()} | #error{}}). -record('Ack', {table = 'Message' :: atom(), id = [] :: [] | binary()}). @@ -320,8 +323,8 @@ topic = [] :: [] | binary(), qos = 0 :: [] | integer()}). --record('FakeNumbers', {phone = [] :: [] | binary(), - created = 0 :: [] | integer()}). +-record('FakeNumbers', {phone = [] :: [] | integer() | binary(), + created = 0 :: [] | integer() | list()}). -record('Draft', {data=[] :: list(term()), status = update :: update | get | delete }). diff --git a/apps/roster/priv/macbert/Model/Ack.swift b/apps/roster/priv/macbert/Model/Ack.swift deleted file mode 100644 index d5706c4af..000000000 --- a/apps/roster/priv/macbert/Model/Ack.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class Ack { - var table: StringAtom? - var id: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Auth.swift b/apps/roster/priv/macbert/Model/Auth.swift deleted file mode 100644 index 2352012a1..000000000 --- a/apps/roster/priv/macbert/Model/Auth.swift +++ /dev/null @@ -1,17 +0,0 @@ - -class Auth { - var client_id: String? - var dev_key: String? - var user_id: String? - var phone: AnyObject? - var token: String? - var type: StringAtom? - var sms_code: String? - var attempts: Int64? - var services: [AnyObject]? - var settings: [Feature]? - var push: String? - var os: AnyObject? - var created: Int64? - var last_online: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/CDR.swift b/apps/roster/priv/macbert/Model/CDR.swift deleted file mode 100644 index 1c4fc833a..000000000 --- a/apps/roster/priv/macbert/Model/CDR.swift +++ /dev/null @@ -1,16 +0,0 @@ - -class CDR { - var id: Int64? - var container: StringAtom? - var feed: AnyObject? - var next: Int64? - var prev: Int64? - var from: String? - var to: String? - var start: Int64? - var stop: Int64? - var type: AnyObject? - var desc: String? - var bill: Int64? - var tariff: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Call.swift b/apps/roster/priv/macbert/Model/Call.swift deleted file mode 100644 index b811320fd..000000000 --- a/apps/roster/priv/macbert/Model/Call.swift +++ /dev/null @@ -1,10 +0,0 @@ - -class Call { - var id: String? - var from: String? - var members: [CallMember]? - var start: Int64? - var stop: Int64? - var vox_url: String? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/CallMember.swift b/apps/roster/priv/macbert/Model/CallMember.swift deleted file mode 100644 index 543a635fa..000000000 --- a/apps/roster/priv/macbert/Model/CallMember.swift +++ /dev/null @@ -1,16 +0,0 @@ - -class CallMember { - var id: Int64? - var feed_id: String? - var prev: Int64? - var next: Int64? - var contact: AnyObject? - var start: Int64? - var stop: Int64? - var type: AnyObject? - var desc: String? - var tariff: String? - var bill: Int64? - var duration: Int64? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Contact.swift b/apps/roster/priv/macbert/Model/Contact.swift deleted file mode 100644 index 89af7d9d3..000000000 --- a/apps/roster/priv/macbert/Model/Contact.swift +++ /dev/null @@ -1,17 +0,0 @@ - -class Contact { - var phone_id: String? - var avatar: String? - var names: String? - var surnames: String? - var nick: String? - var reader: AnyObject? - var unread: Int64? - var last_msg: Message? - var update: Int64? - var created: Int64? - var settings: [Feature]? - var services: [Service]? - var presence: AnyObject? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Cursor.swift b/apps/roster/priv/macbert/Model/Cursor.swift deleted file mode 100644 index 715433bc2..000000000 --- a/apps/roster/priv/macbert/Model/Cursor.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class Cursor { - var feed: AnyObject? - var roster_id: String? - var position: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Desc.swift b/apps/roster/priv/macbert/Model/Desc.swift deleted file mode 100644 index 05ae37264..000000000 --- a/apps/roster/priv/macbert/Model/Desc.swift +++ /dev/null @@ -1,8 +0,0 @@ - -class Desc { - var id: String? - var mime: String? - var payload: String? - var parentid: String? - var data: [Feature]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/ExtendedStar.swift b/apps/roster/priv/macbert/Model/ExtendedStar.swift deleted file mode 100644 index 773d5ccd2..000000000 --- a/apps/roster/priv/macbert/Model/ExtendedStar.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class ExtendedStar { - var star: Star? - var from: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Feature.swift b/apps/roster/priv/macbert/Model/Feature.swift deleted file mode 100644 index 06325ae6e..000000000 --- a/apps/roster/priv/macbert/Model/Feature.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class Feature { - var id: String? - var key: String? - var value: String? - var group: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Friend.swift b/apps/roster/priv/macbert/Model/Friend.swift deleted file mode 100644 index 098158c1a..000000000 --- a/apps/roster/priv/macbert/Model/Friend.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class Friend { - var phone_id: String? - var friend_id: String? - var settings: [Feature]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/History.swift b/apps/roster/priv/macbert/Model/History.swift deleted file mode 100644 index ab4f1d13c..000000000 --- a/apps/roster/priv/macbert/Model/History.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class History { - var roster_id: String? - var feed: AnyObject? - var size: Int64? - var entity_id: Int64? - var data: [AnyObject]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Index.swift b/apps/roster/priv/macbert/Model/Index.swift deleted file mode 100644 index 4752fe439..000000000 --- a/apps/roster/priv/macbert/Model/Index.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class Index { - var id: AnyObject? - var roster: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Job.swift b/apps/roster/priv/macbert/Model/Job.swift deleted file mode 100644 index 224046c0a..000000000 --- a/apps/roster/priv/macbert/Model/Job.swift +++ /dev/null @@ -1,15 +0,0 @@ - -class Job { - var id: Int64? - var container: AnyObject? - var feed_id: act? - var prev: Int64? - var next: Int64? - var context: AnyObject? - var proc: AnyObject? - var time: Int64? - var data: AnyObject? - var events: [messageEvent]? - var settings: [Feature]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Link.swift b/apps/roster/priv/macbert/Model/Link.swift deleted file mode 100644 index 1b763993d..000000000 --- a/apps/roster/priv/macbert/Model/Link.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class Link { - var id: String? - var name: String? - var room_id: String? - var created: Int64? - var type: AnyObject? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Loc.swift b/apps/roster/priv/macbert/Model/Loc.swift deleted file mode 100644 index 90a23dec7..000000000 --- a/apps/roster/priv/macbert/Model/Loc.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class Loc { - var x: String? - var y: String? - var place_id: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Member.swift b/apps/roster/priv/macbert/Model/Member.swift deleted file mode 100644 index 748d88eca..000000000 --- a/apps/roster/priv/macbert/Model/Member.swift +++ /dev/null @@ -1,20 +0,0 @@ - -class Member { - var id: Int64? - var container: AnyObject? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? - var phone_id: String? - var avatar: String? - var names: String? - var surnames: String? - var alias: String? - var reader: Int64? - var update: Int64? - var settings: [Feature]? - var services: [Service]? - var presence: AnyObject? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Message.swift b/apps/roster/priv/macbert/Model/Message.swift deleted file mode 100644 index 03e9429d3..000000000 --- a/apps/roster/priv/macbert/Model/Message.swift +++ /dev/null @@ -1,19 +0,0 @@ - -class Message { - var id: Int64? - var container: AnyObject? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var msg_id: String? - var from: String? - var to: String? - var created: Int64? - var files: [Desc]? - var type: [AnyObject]? - var link: AnyObject? - var seenby: [AnyObject]? - var repliedby: [AnyObject]? - var mentioned: [AnyObject]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Person.swift b/apps/roster/priv/macbert/Model/Person.swift deleted file mode 100644 index abba5ccf3..000000000 --- a/apps/roster/priv/macbert/Model/Person.swift +++ /dev/null @@ -1,14 +0,0 @@ - -class Person { - var id: String? - var phonelist: [AnyObject]? - var alias: [AnyObject]? - var localize: [AnyObject]? - var NotificationSettings: [AnyObject]? - var SoundSettings: [AnyObject]? - var ThemeID: String? - var BlockUsers: [AnyObject]? - var balance: Int64? - var isParticipants: [String]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Profile.swift b/apps/roster/priv/macbert/Model/Profile.swift deleted file mode 100644 index f32b4e552..000000000 --- a/apps/roster/priv/macbert/Model/Profile.swift +++ /dev/null @@ -1,11 +0,0 @@ - -class Profile { - var phone: String? - var services: [Service]? - var rosters: [AnyObject]? - var settings: [Feature]? - var update: Int64? - var balance: Int64? - var presence: AnyObject? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/PushService.swift b/apps/roster/priv/macbert/Model/PushService.swift deleted file mode 100644 index b51d8ef0e..000000000 --- a/apps/roster/priv/macbert/Model/PushService.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class PushService { - var recipients: [AnyObject]? - var id: String? - var ttl: Int64? - var module: String? - var priority: String? - var payload: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Room.swift b/apps/roster/priv/macbert/Model/Room.swift deleted file mode 100644 index 5ecb7eed3..000000000 --- a/apps/roster/priv/macbert/Model/Room.swift +++ /dev/null @@ -1,21 +0,0 @@ - -class Room { - var id: String? - var name: String? - var links: [Link]? - var description: String? - var settings: [Feature]? - var members: [Member]? - var admins: [Member]? - var data: [Desc]? - var type: AnyObject? - var tos: String? - var tos_update: Int64? - var unread: Int64? - var mentions: [AnyObject]? - var readers: [AnyObject]? - var last_msg: AnyObject? - var update: Int64? - var created: Int64? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Roster.swift b/apps/roster/priv/macbert/Model/Roster.swift deleted file mode 100644 index d9ff48490..000000000 --- a/apps/roster/priv/macbert/Model/Roster.swift +++ /dev/null @@ -1,16 +0,0 @@ - -class Roster { - var id: AnyObject? - var names: String? - var surnames: String? - var email: String? - var nick: String? - var userlist: [AnyObject]? - var roomlist: [Room]? - var favorite: [Star]? - var tags: [Tag]? - var phone: String? - var avatar: String? - var update: Int64? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Schedule.swift b/apps/roster/priv/macbert/Model/Schedule.swift deleted file mode 100644 index 465c77196..000000000 --- a/apps/roster/priv/macbert/Model/Schedule.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class Schedule { - var id: Int64? - var proc: Int64? - var data: [AnyObject]? - var state: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Search.swift b/apps/roster/priv/macbert/Model/Search.swift deleted file mode 100644 index daeafd5c6..000000000 --- a/apps/roster/priv/macbert/Model/Search.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class Search { - var id: Int64? - var ref: String? - var field: String? - var type: AnyObject? - var value: [AnyObject]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Service.swift b/apps/roster/priv/macbert/Model/Service.swift deleted file mode 100644 index 40de56080..000000000 --- a/apps/roster/priv/macbert/Model/Service.swift +++ /dev/null @@ -1,10 +0,0 @@ - -class Service { - var id: String? - var type: AnyObject? - var data: AnyObject? - var login: String? - var password: String? - var expiration: Int64? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Star.swift b/apps/roster/priv/macbert/Model/Star.swift deleted file mode 100644 index bd39a44ca..000000000 --- a/apps/roster/priv/macbert/Model/Star.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class Star { - var id: Int64? - var client_id: String? - var roster_id: Int64? - var message: Message? - var tags: [Tag]? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/StickerPack.swift b/apps/roster/priv/macbert/Model/StickerPack.swift deleted file mode 100644 index fe47f7ecf..000000000 --- a/apps/roster/priv/macbert/Model/StickerPack.swift +++ /dev/null @@ -1,12 +0,0 @@ - -class StickerPack { - var id: Int64? - var name: String? - var keywords: [AnyObject]? - var description: String? - var author: String? - var stickers: [Desc]? - var created: Int64? - var updated: Int64? - var downloaded: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Tag.swift b/apps/roster/priv/macbert/Model/Tag.swift deleted file mode 100644 index 207ca2095..000000000 --- a/apps/roster/priv/macbert/Model/Tag.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class Tag { - var roster_id: String? - var name: String? - var color: String? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Test.swift b/apps/roster/priv/macbert/Model/Test.swift deleted file mode 100644 index 5fc1cf03d..000000000 --- a/apps/roster/priv/macbert/Model/Test.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class Test { - var type: AnyObject? - var count: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Typing.swift b/apps/roster/priv/macbert/Model/Typing.swift deleted file mode 100644 index f37b18267..000000000 --- a/apps/roster/priv/macbert/Model/Typing.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class Typing { - var phone_id: String? - var comments: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/Vox.swift b/apps/roster/priv/macbert/Model/Vox.swift deleted file mode 100644 index 613a7ec15..000000000 --- a/apps/roster/priv/macbert/Model/Vox.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class Vox { - var id: String? - var login: String? - var password: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/act.swift b/apps/roster/priv/macbert/Model/act.swift deleted file mode 100644 index aeaa79c8d..000000000 --- a/apps/roster/priv/macbert/Model/act.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class act { - var name: String? - var data: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/amend.swift b/apps/roster/priv/macbert/Model/amend.swift deleted file mode 100644 index 0d08c444e..000000000 --- a/apps/roster/priv/macbert/Model/amend.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class amend { - var id: Int64? - var docs: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/beginEvent.swift b/apps/roster/priv/macbert/Model/beginEvent.swift deleted file mode 100644 index af7d4531b..000000000 --- a/apps/roster/priv/macbert/Model/beginEvent.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class beginEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/boundaryEvent.swift b/apps/roster/priv/macbert/Model/boundaryEvent.swift deleted file mode 100644 index 006afe0fb..000000000 --- a/apps/roster/priv/macbert/Model/boundaryEvent.swift +++ /dev/null @@ -1,11 +0,0 @@ - -class boundaryEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var payload: String? - var timeout: [AnyObject]? - var timeDate: String? - var timeDuration: String? - var timeCycle: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/chain.swift b/apps/roster/priv/macbert/Model/chain.swift deleted file mode 100644 index 14aea4f57..000000000 --- a/apps/roster/priv/macbert/Model/chain.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class chain { - var id: Int64? - var top: Int64? - var rear: Int64? - var count: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/complete.swift b/apps/roster/priv/macbert/Model/complete.swift deleted file mode 100644 index 80eb9dce6..000000000 --- a/apps/roster/priv/macbert/Model/complete.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class complete { - var id: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/container.swift b/apps/roster/priv/macbert/Model/container.swift deleted file mode 100644 index 1ef7e8601..000000000 --- a/apps/roster/priv/macbert/Model/container.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class container { - var id: Int64? - var top: Int64? - var rear: Int64? - var count: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/create.swift b/apps/roster/priv/macbert/Model/create.swift deleted file mode 100644 index a55abc4af..000000000 --- a/apps/roster/priv/macbert/Model/create.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class create { - var proc: AnyObject? - var docs: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/cur.swift b/apps/roster/priv/macbert/Model/cur.swift deleted file mode 100644 index 0ada6dd4d..000000000 --- a/apps/roster/priv/macbert/Model/cur.swift +++ /dev/null @@ -1,10 +0,0 @@ - -class cur { - var id: AnyObject? - var top: Int64? - var bot: Int64? - var dir: AnyObject? - var reader: [AnyObject]? - var writer: [AnyObject]? - var args: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/endEvent.swift b/apps/roster/priv/macbert/Model/endEvent.swift deleted file mode 100644 index 7e0f2b03e..000000000 --- a/apps/roster/priv/macbert/Model/endEvent.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class endEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/error.swift b/apps/roster/priv/macbert/Model/error.swift deleted file mode 100644 index 0bed53727..000000000 --- a/apps/roster/priv/macbert/Model/error.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class error { - var code: StringAtom? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/error2.swift b/apps/roster/priv/macbert/Model/error2.swift deleted file mode 100644 index 12818a9ed..000000000 --- a/apps/roster/priv/macbert/Model/error2.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class error2 { - var code: StringAtom? - var src: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/errors.swift b/apps/roster/priv/macbert/Model/errors.swift deleted file mode 100644 index 690f3d3ef..000000000 --- a/apps/roster/priv/macbert/Model/errors.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class errors { - var code: [AnyObject]? - var data: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/hist.swift b/apps/roster/priv/macbert/Model/hist.swift deleted file mode 100644 index f46c4d04d..000000000 --- a/apps/roster/priv/macbert/Model/hist.swift +++ /dev/null @@ -1,13 +0,0 @@ - -class hist { - var id: Int64? - var container: StringAtom? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? - var name: String? - var task: StringAtom? - var docs: [AnyObject]? - var time: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/histo.swift b/apps/roster/priv/macbert/Model/histo.swift deleted file mode 100644 index 8e47f43d7..000000000 --- a/apps/roster/priv/macbert/Model/histo.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class histo { - var id: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/io.swift b/apps/roster/priv/macbert/Model/io.swift deleted file mode 100644 index 942786a26..000000000 --- a/apps/roster/priv/macbert/Model/io.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class io { - var code: AnyObject? - var data: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/iter.swift b/apps/roster/priv/macbert/Model/iter.swift deleted file mode 100644 index 9dc2533f7..000000000 --- a/apps/roster/priv/macbert/Model/iter.swift +++ /dev/null @@ -1,8 +0,0 @@ - -class iter { - var id: Int64? - var container: StringAtom? - var feed: AnyObject? - var next: Int64? - var prev: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/iterator.swift b/apps/roster/priv/macbert/Model/iterator.swift deleted file mode 100644 index 81dfcdfdd..000000000 --- a/apps/roster/priv/macbert/Model/iterator.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class iterator { - var id: Int64? - var container: StringAtom? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/join_application.swift b/apps/roster/priv/macbert/Model/join_application.swift deleted file mode 100644 index 1f859baba..000000000 --- a/apps/roster/priv/macbert/Model/join_application.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class join_application { - var id: Int64? - var name: String? - var data: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/log.swift b/apps/roster/priv/macbert/Model/log.swift deleted file mode 100644 index 5edb7154a..000000000 --- a/apps/roster/priv/macbert/Model/log.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class log { - var id: Int64? - var top: Int64? - var rear: Int64? - var count: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/max_tour.swift b/apps/roster/priv/macbert/Model/max_tour.swift deleted file mode 100644 index e34af7549..000000000 --- a/apps/roster/priv/macbert/Model/max_tour.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class max_tour { - var count: Int64? - var joined: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/messageEvent.swift b/apps/roster/priv/macbert/Model/messageEvent.swift deleted file mode 100644 index 6dc379344..000000000 --- a/apps/roster/priv/macbert/Model/messageEvent.swift +++ /dev/null @@ -1,8 +0,0 @@ - -class messageEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var payload: String? - var timeout: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/mqi.swift b/apps/roster/priv/macbert/Model/mqi.swift deleted file mode 100644 index 66aebc732..000000000 --- a/apps/roster/priv/macbert/Model/mqi.swift +++ /dev/null @@ -1,6 +0,0 @@ - -class mqi { - var feed_id: muc? - var query: String? - var status: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/muc.swift b/apps/roster/priv/macbert/Model/muc.swift deleted file mode 100644 index 231649474..000000000 --- a/apps/roster/priv/macbert/Model/muc.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class muc { - var name: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/ok.swift b/apps/roster/priv/macbert/Model/ok.swift deleted file mode 100644 index 935a071b5..000000000 --- a/apps/roster/priv/macbert/Model/ok.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class ok { - var code: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/ok2.swift b/apps/roster/priv/macbert/Model/ok2.swift deleted file mode 100644 index 2f2c76cbd..000000000 --- a/apps/roster/priv/macbert/Model/ok2.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class ok2 { - var code: StringAtom? - var src: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/operation.swift b/apps/roster/priv/macbert/Model/operation.swift deleted file mode 100644 index 5525550ed..000000000 --- a/apps/roster/priv/macbert/Model/operation.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class operation { - var id: Int64? - var container: StringAtom? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/p2p.swift b/apps/roster/priv/macbert/Model/p2p.swift deleted file mode 100644 index 326162f9e..000000000 --- a/apps/roster/priv/macbert/Model/p2p.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class p2p { - var from: String? - var to: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/proc.swift b/apps/roster/priv/macbert/Model/proc.swift deleted file mode 100644 index 91b8f6462..000000000 --- a/apps/roster/priv/macbert/Model/proc.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class proc { - var id: Int64? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/process.swift b/apps/roster/priv/macbert/Model/process.swift deleted file mode 100644 index 0069d0df1..000000000 --- a/apps/roster/priv/macbert/Model/process.swift +++ /dev/null @@ -1,25 +0,0 @@ - -class process { - var id: Int64? - var container: StringAtom? - var feed_id: AnyObject? - var prev: Int64? - var next: Int64? - var feeds: [AnyObject]? - var name: String? - var roles: [AnyObject]? - var tasks: [AnyObject]? - var events: [AnyObject]? - var hist: AnyObject? - var flows: [sequenceFlow]? - var rules: AnyObject? - var docs: [AnyObject]? - var options: AnyObject? - var task: StringAtom? - var timer: String? - var notifications: AnyObject? - var result: String? - var started: [AnyObject]? - var beginEvent: StringAtom? - var endEvent: StringAtom? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/push.swift b/apps/roster/priv/macbert/Model/push.swift deleted file mode 100644 index 15ffd0257..000000000 --- a/apps/roster/priv/macbert/Model/push.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class push { - var model: AnyObject? - var type: String? - var title: String? - var alert: String? - var badge: Int64? - var sound: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/reader.swift b/apps/roster/priv/macbert/Model/reader.swift deleted file mode 100644 index b1e34c1db..000000000 --- a/apps/roster/priv/macbert/Model/reader.swift +++ /dev/null @@ -1,9 +0,0 @@ - -class reader { - var id: AnyObject? - var pos: Int64? - var cache: Int64? - var args: AnyObject? - var feed: AnyObject? - var dir: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/receiveTask.swift b/apps/roster/priv/macbert/Model/receiveTask.swift deleted file mode 100644 index bdb436a8e..000000000 --- a/apps/roster/priv/macbert/Model/receiveTask.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class receiveTask { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var roles: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/sequenceFlow.swift b/apps/roster/priv/macbert/Model/sequenceFlow.swift deleted file mode 100644 index 2a0e73d3b..000000000 --- a/apps/roster/priv/macbert/Model/sequenceFlow.swift +++ /dev/null @@ -1,5 +0,0 @@ - -class sequenceFlow { - var source: StringAtom? - var target: AnyObject? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/serviceTask.swift b/apps/roster/priv/macbert/Model/serviceTask.swift deleted file mode 100644 index 6927e6da4..000000000 --- a/apps/roster/priv/macbert/Model/serviceTask.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class serviceTask { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var roles: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/task.swift b/apps/roster/priv/macbert/Model/task.swift deleted file mode 100644 index b14868fa7..000000000 --- a/apps/roster/priv/macbert/Model/task.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class task { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var roles: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/timeoutEvent.swift b/apps/roster/priv/macbert/Model/timeoutEvent.swift deleted file mode 100644 index 422e1c9bd..000000000 --- a/apps/roster/priv/macbert/Model/timeoutEvent.swift +++ /dev/null @@ -1,11 +0,0 @@ - -class timeoutEvent { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var payload: String? - var timeout: [AnyObject]? - var timeDate: String? - var timeDuration: String? - var timeCycle: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/tour_list.swift b/apps/roster/priv/macbert/Model/tour_list.swift deleted file mode 100644 index a1d556b22..000000000 --- a/apps/roster/priv/macbert/Model/tour_list.swift +++ /dev/null @@ -1,4 +0,0 @@ - -class tour_list { - var users: [join_application]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/userTask.swift b/apps/roster/priv/macbert/Model/userTask.swift deleted file mode 100644 index ba5eb207e..000000000 --- a/apps/roster/priv/macbert/Model/userTask.swift +++ /dev/null @@ -1,7 +0,0 @@ - -class userTask { - var name: StringAtom? - var module: StringAtom? - var prompt: [AnyObject]? - var roles: String? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Model/writer.swift b/apps/roster/priv/macbert/Model/writer.swift deleted file mode 100644 index 2aece090e..000000000 --- a/apps/roster/priv/macbert/Model/writer.swift +++ /dev/null @@ -1,8 +0,0 @@ - -class writer { - var id: AnyObject? - var count: Int64? - var cache: [AnyObject]? - var args: AnyObject? - var first: [AnyObject]? -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Source/Bert.swift b/apps/roster/priv/macbert/Source/Bert.swift deleted file mode 100644 index f83117752..000000000 --- a/apps/roster/priv/macbert/Source/Bert.swift +++ /dev/null @@ -1,693 +0,0 @@ -// -// AppDelegate.swift -// Nynja -// -// Created by Anton Makarov on 15.05.17. -// Copyright © 2017 TecSynt Solutions. All rights reserved. -// - -import Foundation - -enum BertError: Error { - case NotValidBertObject - case NotValidErlangTerm - case UnexpectedErlangType - case IntegerValueToLarge - case AtomLengthToLarge -} - -enum BertType: UInt8 { - case Version = 131 - case SmallAtom = 115 - case Atom = 100 - case Binary = 109 - case SmallInteger = 97 - case Integer = 98 - case SmallBig = 110 - // case LargetBig = 111 - // case Float = 99 - case NewFloat = 70 - case String = 107 - // case Port = 102 - // case Pid = 103 - case SmallTuple = 104 - case LargeTuple = 105 - case List = 108 - // case Reference = 101 - // case NewReference = 114 - case Nil = 106 -} - -class BertObject{ - var type: UInt8 = 0 - - var description : String { - get { - return "BertObject" - } - } -} - -class BertAtom: BertObject { - var value = "" - - init (fromString string: String) { - value = string - } - - override var description : String { - get { - if value == "" { - return "[]" - } - return value - } - } -} - -class BertBool: BertObject { - var value: Bool - - init (fromBool b: Bool) { - value = b - } - override var description : String { - get { - if value.description == "" { - return "[]" - } - return value.description - } - } -} - -class BertUndefined: BertAtom { - init () { - super.init(fromString: "undefined") - } - - override var description : String { - get { - if value.description == "" { - return "[]" - } - return value.description - } - } -} - -class BertBinary: BertObject { - var value: NSData - - init (fromNSData d: NSData) { - value = d - } - - override var description : String { - get { - let d = String(data: value as Data, encoding: String.Encoding.utf8) - return d ?? "__Can't GET data__" - } - } -} - -class BertNumber: BertObject { - var value: Int64 - - init (fromUInt8 i: UInt8) { - value = Int64(i) - } - - init (fromInt32 i: Int32) { - value = Int64(i) - } - - init (fromInt64 i: Int64) { - value = i - } - - override var description : String { - get { - return value.description - } - } -} - -class BertFloat: BertObject { - var value: Double - - init (fromDouble d: Double) { - value = d - } - override var description : String { - get { - return value.description - } - } -} - -class BertNil: BertObject { - - override var description : String { - get { - return "NIL" - } - } -} - -class BertString: BertObject { - var value: String - - init (fromString s: String) { - value = s - } - - override var description : String { - get { - return value - } - } -} - -class BertTuple: BertObject { - var elements: [BertObject] - - override var description : String { - get { - var res = "{" - for i in 0.. NSData { - let length = try getEncodeSize(object: object) - var offset: Int = 0 - var data = [UInt8](repeating: 0, count: length + 1) - - data[offset] = BertType.Version.rawValue - offset += 1 - try encodeInner(object: object, data: &data, offset: &offset) - - return NSData(bytes: data, length: length + 1) - } - - class func getObjectClassName(object: BertObject) -> String { - let className = NSStringFromClass(object_getClass(object)!) - let classNameArr = className.components(separatedBy: ".") - - return classNameArr.last! - } - - class func getEncodeSize (object: BertObject) throws -> Int { - switch getObjectClassName(object: object) { - case "BertBool": - let bool = (object as! BertBool) - return 1 + 2 + (bool.value ? 4 : 5) - case "BertUndefined": - return 1 + 2 + 9 - case "BertAtom": - let atom = (object as! BertAtom) - return 1 + 2 + atom.value.characters.count - case "BertBinary": - let binary = (object as! BertBinary) - return 1 + 4 + binary.value.length - case "BertNil": - return 1 - case "BertNumber": - let number = (object as! BertNumber) - if number.value >= 0 && number.value <= 255 { - return 1 + 1 - } - if number.value >= -2147483648 && number.value <= 2147483647 { - return 1 + 4 - } - return 1 + 1 + 8 - case "BertFloat": - return 1 + 8 - case "BertString": - // TODO: implement encoding for length > 0xFF - let string = (object as! BertString) - return 1 + 2 + string.value.characters.count - case "BertTuple": - let tuple = (object as! BertTuple) - var n = 0 - for element in tuple.elements { - n += try getEncodeSize(object: element) - } - return 1 + (tuple.elements.count <= 255 ? 1 : 4) + n - case "BertList": - let list = (object as! BertList) - var n = 0 - for element in list.elements { - n += try getEncodeSize(object: element) - } - return 1 + 4 + 1 + n - default: - throw BertError.UnexpectedErlangType - } - } - - class func encodeInner(object: BertObject, data: inout [UInt8], offset: inout Int) throws { - switch getObjectClassName(object: object) { - case "BertAtom": encodeAtom(atom: object as! BertAtom, data: &data, offset: &offset) - case "BertBool": encodeBool(bool: object as! BertBool, data: &data, offset: &offset) - case "BertUndefined": encodeAtom(atom: object as! BertUndefined, data: &data, offset: &offset) - case "BertBinary": encodeBinary(binary: object as! BertBinary, data: &data, offset: &offset) - case "BertNumber": encodeNumber(number: object as! BertNumber, data: &data, offset: &offset) - case "BertFloat": encodeFloat(float: object as! BertFloat, data: &data, offset: &offset) - case "BertString": encodeString(string: object as! BertString, data: &data, offset: &offset) - case "BertTuple": try encodeTuple(tuple: object as! BertTuple, data: &data, offset: &offset) - case "BertList": try encodeList(list: object as! BertList, data: &data, offset: &offset) - case "BertNil": encodeNil(data: &data, offset: &offset) - default: - throw BertError.UnexpectedErlangType - } - } - - class func encodeAtom(atom: BertAtom, data: inout [UInt8], offset: inout Int) { - let length = UInt16(atom.value.characters.count) - data[offset] = BertType.Atom.rawValue - offset += 1 - writeUInt16(i: length, data: &data, offset: &offset) - - memcpy(&data[offset], (atom.value as NSString).utf8String, Int(length)) - offset += Int(length) - } - - class func encodeBool(bool: BertBool, data: inout [UInt8], offset: inout Int) { - let atom = BertAtom(fromString: (bool.value ? "true" : "false")) - encodeAtom(atom: atom, data: &data, offset: &offset) - } - - class func encodeNil(data: inout [UInt8], offset: inout Int) { - data[offset] = BertType.Nil.rawValue - offset += 1 - // writeUInt16(i: 2, data: &data, offset: &offset) - - //memcpy(&data[offset], (atom.value as NSString).utf8String, 1) - //offset += 1 - } - - class func encodeBinary(binary: BertBinary, data: inout [UInt8], offset: inout Int) { - data[offset] = BertType.Binary.rawValue - offset += 1 - let length = UInt32(binary.value.length) - - writeUInt32(i: length, data: &data, offset: &offset) - - memcpy(&data[offset], binary.value.bytes, Int(length)) - offset += Int(length) - } - - class func encodeNumber(number: BertNumber, data: inout [UInt8], offset: inout Int) { - if number.value >= 0 && number.value <= 255 { - data[offset] = BertType.SmallInteger.rawValue - offset += 1 - data[offset] = UInt8(number.value) - offset += 1 - } else if number.value >= -2147483648 && number.value <= 2147483647 { - data[offset] = BertType.Integer.rawValue - offset += 1 - writeUInt32(i: UInt32(number.value), data: &data, offset: &offset) - } else { - data[offset] = BertType.SmallBig.rawValue - offset += 1 - var i: UInt64 = UInt64(number.value < 0 ? -number.value : number.value) - var n = 0 - var pos = offset + 2 //arity, sign - - while (i > 0) { - data[pos] = UInt8(i % 256) - pos += 1 - i = UInt64(floor(Double(i / 256))) - n += 1 - } - data[offset] = UInt8(n) - offset += 1 - data[offset] = UInt8(Int(number.value < 0 ? 1:0)) - offset += n - } - } - - class func encodeFloat(float: BertFloat, data: inout [UInt8], offset: inout Int) { - data[offset] = BertType.NewFloat.rawValue - offset += 1 - let bytes = withUnsafePointer(to: &float.value) { - $0.withMemoryRebound(to: UInt8.self, capacity: 1, { - Array(UnsafeBufferPointer(start: $0, count: MemoryLayout.size)) - }) - } - var i = UnsafePointer(bytes).withMemoryRebound(to: UInt64.self, capacity: 1) { - $0.pointee - }.bigEndian - - memcpy(&data[offset],&i,MemoryLayout.size) - - offset += 8 - } - - class func encodeString(string: BertString, data: inout [UInt8], offset: inout Int) { - data[offset] = BertType.String.rawValue - offset += 1 - writeUInt16(i: UInt16(string.value.characters.count), data: &data, offset: &offset) - - memcpy(&data[offset], (string.value as NSString).utf8String, string.value.characters.count) - offset += string.value.characters.count - } - - class func encodeTuple(tuple: BertTuple, data: inout [UInt8], offset: inout Int) throws { - if tuple.elements.count <= 255 { - data[offset] = BertType.SmallTuple.rawValue - offset += 1 - data[offset] = UInt8(tuple.elements.count) - offset += 1 - } else { - data[offset] = BertType.LargeTuple.rawValue - offset += 1 - writeUInt32(i: UInt32(tuple.elements.count), data: &data, offset: &offset) - } - - for element in tuple.elements { - try encodeInner(object: element, data: &data, offset: &offset) - } - } - - class func encodeList(list: BertList, data: inout [UInt8], offset: inout Int) throws { - data[offset] = BertType.List.rawValue - offset += 1 - writeUInt32(i: UInt32(list.elements.count), data: &data, offset: &offset) - - for element in list.elements { - try encodeInner(object: element, data: &data, offset: &offset) - } - data[offset] = BertType.Nil.rawValue - offset += 1 - } - - class func writeUInt16(i: UInt16, data: inout [UInt8], offset: inout Int) { - data[offset] = UInt8((i & 0xFF00) >> 8) - offset += 1 - data[offset] = UInt8(i & 0xFF) - offset += 1 - } - - class func writeUInt32(i: UInt32, data: inout [UInt8], offset: inout Int) { - data[offset] = UInt8((i & 0xFF000000) >> 24) - offset += 1 - data[offset] = UInt8((i & 0xFF0000) >> 16) - offset += 1 - data[offset] = UInt8((i & 0xFF00) >> 8) - offset += 1 - data[offset] = UInt8(i & 0xFF) - offset += 1 - } - - class func decode (data: NSData) throws -> BertObject { - if data.length == 0 { - return BertUndefined() - } - - var offset = 0 - var buffer = [UInt8](repeating: 0, count: 1) - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let header = buffer[0] - - if header != BertType.Version.rawValue { - throw BertError.NotValidErlangTerm - } - - var printBuffer = [UInt8](repeating: 0, count: data.length) - data.getBytes(&printBuffer, length: data.length) - - return try decodeInner(data: data, offset: &offset) - } - - class func decodeInner (data: NSData, offset: inout Int) throws -> BertObject { - var buffer = [UInt8](repeating: 0, count: 1) - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - let type = buffer[0] - - switch type { - case BertType.Atom.rawValue: return try decodeAtom(data: data, offset: &offset) - case BertType.SmallAtom.rawValue: return try decodeAtom(data: data, offset: &offset) - case BertType.Binary.rawValue: return decodeBinary(data: data, offset: &offset) - case BertType.SmallInteger.rawValue: return try decodeNumber(data: data, offset: &offset) - case BertType.Integer.rawValue: return try decodeNumber(data: data, offset: &offset) - case BertType.SmallBig.rawValue: return try decodeNumber(data: data, offset: &offset) - case BertType.NewFloat.rawValue: return decodeDouble(data: data, offset: &offset) - case BertType.String.rawValue: return decodeString(data: data, offset: &offset) - case BertType.SmallTuple.rawValue: return try decodeTuple(data: data, offset: &offset) - case BertType.LargeTuple.rawValue: return try decodeTuple(data: data, offset: &offset) - case BertType.List.rawValue: return try decodeList(data: data, offset: &offset) - case BertType.Nil.rawValue: return decodeNil(data: data, offset: &offset) - default: - throw BertError.UnexpectedErlangType - } - } - - class func decodeAtom(data: NSData, offset: inout Int) throws -> BertObject { - var buffer = [UInt8](repeating: 0, count: 2) - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let type = buffer[0] - var n: Int - - switch type { - case BertType.Atom.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 2)) - offset += 2 - let u16 = UnsafePointer(buffer).withMemoryRebound(to: UInt16.self, capacity: 1) { - $0.pointee - } - n = Int(u16.bigEndian) - case BertType.SmallAtom.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - n = Int(buffer[0]) - default: - throw BertError.UnexpectedErlangType - } - - var buffer1 = [UInt8](repeating: 0, count: n) - data.getBytes(&buffer1, range: NSMakeRange(offset, n)) - offset += n - - let value = NSString(bytes: buffer1, length: n, encoding: String.Encoding.utf8.rawValue)! as String - - switch value { - case "true": return BertBool(fromBool: true) - case "false": return BertBool(fromBool: false) - case "undefined": return BertUndefined() - default: return BertAtom(fromString: value) - } - } - - class func decodeBinary(data: NSData, offset: inout Int) -> BertObject { - offset += 1 - - var buffer = [UInt8](repeating: 0, count: 4) - - data.getBytes(&buffer, range: NSMakeRange(offset, 4)) - offset += 4 - let u16 = UnsafePointer(buffer).withMemoryRebound(to: UInt32.self, capacity: 1) { - $0.pointee - } - let length = Int(u16.bigEndian) - var dataBuffer = [UInt8](repeating: 0, count: length) - data.getBytes(&dataBuffer, range: NSMakeRange(offset, length)) - offset += length - - return BertBinary(fromNSData: NSData(bytes: dataBuffer, length: length)) - } - - class func decodeNumber(data: NSData, offset: inout Int) throws -> BertObject { - var buffer = [UInt8](repeating: 0, count: 10) - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let type = buffer[0] - - switch type { - case BertType.SmallInteger.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let value = buffer[0] - return BertNumber(fromUInt8: value) - case BertType.Integer.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 4)) - offset += 4 - let u16 = UnsafePointer(buffer).withMemoryRebound(to: UInt32.self, capacity: 1) { - $0.pointee - } - let value = Int32(u16.bigEndian) - return BertNumber(fromInt32: value) - case BertType.SmallBig.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let arity = buffer[0] - if (arity > 7) { - throw BertError.IntegerValueToLarge - } - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let sign = buffer[0] - - var value: Int64 = 0 - var n: Int64 = 1 - for i in 0...arity-1 { - data.getBytes(&buffer, range:NSMakeRange(offset, 1)) - offset += 1 - let v = Int64(buffer[0]) - value += v * n - if i+1 != arity { - n *= 256 - } - } - - if sign > 0 { - value = -value - } - return BertNumber(fromInt64: Int64(value)) - default: - throw BertError.UnexpectedErlangType - } - } - - class func decodeDouble(data: NSData, offset: inout Int) -> BertObject { - offset += 1 - var buffer = [UInt8](repeating: 0, count: 8) - data.getBytes(&buffer, range: NSMakeRange(offset, 8)) - offset += 8 - var i = Int64(UnsafePointer(buffer).withMemoryRebound(to: UInt64.self, capacity: 1) { - $0.pointee - }.bigEndian) - var d: Double = 0 - memcpy(&d, &i, MemoryLayout.size) - return BertFloat(fromDouble: d) - } - - class func decodeString(data: NSData, offset: inout Int) -> BertObject { - offset += 1 - - var buffer = [UInt8](repeating: 0, count: 2) - data.getBytes(&buffer, range: NSMakeRange(offset, 2)) - offset += 2 - let length = Int(UnsafePointer(buffer).withMemoryRebound(to: UInt16.self, capacity: 1) { - $0.pointee - }.bigEndian) - - var stringBuffer = [UInt8](repeating: 0, count: length) - - data.getBytes(&stringBuffer, range: NSMakeRange(offset, length)) - offset += length - - return BertString(fromString: String(bytes: stringBuffer, encoding: String.Encoding.utf8)!) - } - - class func decodeTuple(data: NSData, offset: inout Int) throws -> BertObject { - var buffer = [UInt8](repeating: 0, count: 4) - var n: Int - - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - let type = buffer[0] - - switch type { - case BertType.SmallTuple.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - offset += 1 - n = Int(buffer[0]) - case BertType.LargeTuple.rawValue: - data.getBytes(&buffer, range: NSMakeRange(offset, 4)) - offset += 4 - n = Int(UnsafePointer(buffer).withMemoryRebound(to: UInt32.self, capacity: 1) { - $0.pointee - }.bigEndian) - default: - throw BertError.UnexpectedErlangType - } - - var elements = [BertObject]() - if n > 0 { - for _ in 0...n-1 { - elements.append(try decodeInner(data: data, offset: &offset)) - } - } - - return BertTuple(fromElements: elements) - } - - class func decodeList(data: NSData, offset: inout Int) throws -> BertObject { - offset+=1 - - var buffer = [UInt8](repeating: 0, count: 4) - - data.getBytes(&buffer, range: NSMakeRange(offset, 4)) - offset += 4 - let n = Int(UnsafePointer(buffer).withMemoryRebound(to: UInt32.self, capacity: 1) { - $0.pointee - }.bigEndian) - var elements = [BertObject]() - if n > 0 { - for _ in 0...n-1 { - elements.append(try decodeInner(data: data, offset: &offset)) - } - } - - if data.length > offset { - data.getBytes(&buffer, range: NSMakeRange(offset, 1)) - if (buffer[0] == BertType.Nil.rawValue) { - offset += 1 - } - } - - return BertList(fromElements: elements) - } - - class func decodeNil(data: NSData, offset: inout Int) -> BertObject { - offset += 1 - return BertNil() - } -} diff --git a/apps/roster/priv/macbert/Source/Decoder.swift b/apps/roster/priv/macbert/Source/Decoder.swift deleted file mode 100644 index 7f92a585e..000000000 --- a/apps/roster/priv/macbert/Source/Decoder.swift +++ /dev/null @@ -1,364 +0,0 @@ -func parseObject(name: String, body:[Model], tuple: BertTuple) -> AnyObject? -{ - switch name { - case "chain": - if body.count != 6 { return nil } - let a_chain = chain() - a_chain.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_chain.top = body[1].parse(bert: tuple.elements[2]) as? Int64 - a_chain.rear = body[2].parse(bert: tuple.elements[3]) as? Int64 - a_chain.count = body[3].parse(bert: tuple.elements[4]) as? Int64 - return a_chain - case "push": - if body.count != 6 { return nil } - let a_push = push() - a_push.model = body[0].parse(bert: tuple.elements[1]) as? AnyObject - a_push.type = body[1].parse(bert: tuple.elements[2]) as? String - a_push.title = body[2].parse(bert: tuple.elements[3]) as? String - a_push.alert = body[3].parse(bert: tuple.elements[4]) as? String - a_push.badge = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_push.sound = body[5].parse(bert: tuple.elements[6]) as? String - return a_push - case "Search": - if body.count != 6 { return nil } - let a_Search = Search() - a_Search.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Search.ref = body[1].parse(bert: tuple.elements[2]) as? String - a_Search.field = body[2].parse(bert: tuple.elements[3]) as? String - a_Search.type = body[3].parse(bert: tuple.elements[4]) as? AnyObject - a_Search.value = body[4].parse(bert: tuple.elements[5]) as? [AnyObject] - a_Search.status = body[5].parse(bert: tuple.elements[6]) as? AnyObject - return a_Search - case "p2p": - if body.count != 2 { return nil } - let a_p2p = p2p() - a_p2p.from = body[0].parse(bert: tuple.elements[1]) as? String - a_p2p.to = body[1].parse(bert: tuple.elements[2]) as? String - return a_p2p - case "muc": - if body.count != 1 { return nil } - let a_muc = muc() - a_muc.name = body[0].parse(bert: tuple.elements[1]) as? String - return a_muc - case "mqi": - if body.count != 3 { return nil } - let a_mqi = mqi() - a_mqi.feed_id = body[0].parse(bert: tuple.elements[1]) as? muc - a_mqi.query = body[1].parse(bert: tuple.elements[2]) as? String - a_mqi.status = body[2].parse(bert: tuple.elements[3]) as? AnyObject - return a_mqi - case "Feature": - if body.count != 4 { return nil } - let a_Feature = Feature() - a_Feature.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Feature.key = body[1].parse(bert: tuple.elements[2]) as? String - a_Feature.value = body[2].parse(bert: tuple.elements[3]) as? String - a_Feature.group = body[3].parse(bert: tuple.elements[4]) as? String - return a_Feature - case "Service": - if body.count != 7 { return nil } - let a_Service = Service() - a_Service.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Service.type = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_Service.data = body[2].parse(bert: tuple.elements[3]) as? AnyObject - a_Service.login = body[3].parse(bert: tuple.elements[4]) as? String - a_Service.password = body[4].parse(bert: tuple.elements[5]) as? String - a_Service.expiration = body[5].parse(bert: tuple.elements[6]) as? Int64 - a_Service.status = body[6].parse(bert: tuple.elements[7]) as? AnyObject - return a_Service - case "Member": - if body.count != 17 { return nil } - let a_Member = Member() - a_Member.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Member.container = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_Member.feed_id = body[2].parse(bert: tuple.elements[3]) as? AnyObject - a_Member.prev = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_Member.next = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_Member.feeds = body[5].parse(bert: tuple.elements[6]) as? [AnyObject] - a_Member.phone_id = body[6].parse(bert: tuple.elements[7]) as? String - a_Member.avatar = body[7].parse(bert: tuple.elements[8]) as? String - a_Member.names = body[8].parse(bert: tuple.elements[9]) as? String - a_Member.surnames = body[9].parse(bert: tuple.elements[10]) as? String - a_Member.alias = body[10].parse(bert: tuple.elements[11]) as? String - a_Member.reader = body[11].parse(bert: tuple.elements[12]) as? Int64 - a_Member.update = body[12].parse(bert: tuple.elements[13]) as? Int64 - a_Member.settings = body[13].parse(bert: tuple.elements[14]) as? [Feature] - a_Member.services = body[14].parse(bert: tuple.elements[15]) as? [Service] - a_Member.presence = body[15].parse(bert: tuple.elements[16]) as? AnyObject - a_Member.status = body[16].parse(bert: tuple.elements[17]) as? AnyObject - return a_Member - case "Desc": - if body.count != 5 { return nil } - let a_Desc = Desc() - a_Desc.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Desc.mime = body[1].parse(bert: tuple.elements[2]) as? String - a_Desc.payload = body[2].parse(bert: tuple.elements[3]) as? String - a_Desc.parentid = body[3].parse(bert: tuple.elements[4]) as? String - a_Desc.data = body[4].parse(bert: tuple.elements[5]) as? [Feature] - return a_Desc - case "StickerPack": - if body.count != 9 { return nil } - let a_StickerPack = StickerPack() - a_StickerPack.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_StickerPack.name = body[1].parse(bert: tuple.elements[2]) as? String - a_StickerPack.keywords = body[2].parse(bert: tuple.elements[3]) as? [AnyObject] - a_StickerPack.description = body[3].parse(bert: tuple.elements[4]) as? String - a_StickerPack.author = body[4].parse(bert: tuple.elements[5]) as? String - a_StickerPack.stickers = body[5].parse(bert: tuple.elements[6]) as? [Desc] - a_StickerPack.created = body[6].parse(bert: tuple.elements[7]) as? Int64 - a_StickerPack.updated = body[7].parse(bert: tuple.elements[8]) as? Int64 - a_StickerPack.downloaded = body[8].parse(bert: tuple.elements[9]) as? Int64 - return a_StickerPack - case "Message": - if body.count != 16 { return nil } - let a_Message = Message() - a_Message.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Message.container = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_Message.feed_id = body[2].parse(bert: tuple.elements[3]) as? AnyObject - a_Message.prev = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_Message.next = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_Message.msg_id = body[5].parse(bert: tuple.elements[6]) as? String - a_Message.from = body[6].parse(bert: tuple.elements[7]) as? String - a_Message.to = body[7].parse(bert: tuple.elements[8]) as? String - a_Message.created = body[8].parse(bert: tuple.elements[9]) as? Int64 - a_Message.files = body[9].parse(bert: tuple.elements[10]) as? [Desc] - a_Message.type = body[10].parse(bert: tuple.elements[11]) as? [AnyObject] - a_Message.link = body[11].parse(bert: tuple.elements[12]) as? AnyObject - a_Message.seenby = body[12].parse(bert: tuple.elements[13]) as? [AnyObject] - a_Message.repliedby = body[13].parse(bert: tuple.elements[14]) as? [AnyObject] - a_Message.mentioned = body[14].parse(bert: tuple.elements[15]) as? [AnyObject] - a_Message.status = body[15].parse(bert: tuple.elements[16]) as? AnyObject - return a_Message - case "Link": - if body.count != 6 { return nil } - let a_Link = Link() - a_Link.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Link.name = body[1].parse(bert: tuple.elements[2]) as? String - a_Link.room_id = body[2].parse(bert: tuple.elements[3]) as? String - a_Link.created = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_Link.type = body[4].parse(bert: tuple.elements[5]) as? AnyObject - a_Link.status = body[5].parse(bert: tuple.elements[6]) as? AnyObject - return a_Link - case "Room": - if body.count != 18 { return nil } - let a_Room = Room() - a_Room.id = body[0].parse(bert: tuple.elements[1]) as? String - a_Room.name = body[1].parse(bert: tuple.elements[2]) as? String - a_Room.links = body[2].parse(bert: tuple.elements[3]) as? [Link] - a_Room.description = body[3].parse(bert: tuple.elements[4]) as? String - a_Room.settings = body[4].parse(bert: tuple.elements[5]) as? [Feature] - a_Room.members = body[5].parse(bert: tuple.elements[6]) as? [Member] - a_Room.admins = body[6].parse(bert: tuple.elements[7]) as? [Member] - a_Room.data = body[7].parse(bert: tuple.elements[8]) as? [Desc] - a_Room.type = body[8].parse(bert: tuple.elements[9]) as? AnyObject - a_Room.tos = body[9].parse(bert: tuple.elements[10]) as? String - a_Room.tos_update = body[10].parse(bert: tuple.elements[11]) as? Int64 - a_Room.unread = body[11].parse(bert: tuple.elements[12]) as? Int64 - a_Room.mentions = body[12].parse(bert: tuple.elements[13]) as? [AnyObject] - a_Room.readers = body[13].parse(bert: tuple.elements[14]) as? [AnyObject] - a_Room.last_msg = body[14].parse(bert: tuple.elements[15]) as? AnyObject - a_Room.update = body[15].parse(bert: tuple.elements[16]) as? Int64 - a_Room.created = body[16].parse(bert: tuple.elements[17]) as? Int64 - a_Room.status = body[17].parse(bert: tuple.elements[18]) as? AnyObject - return a_Room - case "Tag": - if body.count != 4 { return nil } - let a_Tag = Tag() - a_Tag.roster_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Tag.name = body[1].parse(bert: tuple.elements[2]) as? String - a_Tag.color = body[2].parse(bert: tuple.elements[3]) as? String - a_Tag.status = body[3].parse(bert: tuple.elements[4]) as? AnyObject - return a_Tag - case "Star": - if body.count != 6 { return nil } - let a_Star = Star() - a_Star.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Star.client_id = body[1].parse(bert: tuple.elements[2]) as? String - a_Star.roster_id = body[2].parse(bert: tuple.elements[3]) as? Int64 - a_Star.message = body[3].parse(bert: tuple.elements[4]) as? Message - a_Star.tags = body[4].parse(bert: tuple.elements[5]) as? [Tag] - a_Star.status = body[5].parse(bert: tuple.elements[6]) as? AnyObject - return a_Star - case "Typing": - if body.count != 2 { return nil } - let a_Typing = Typing() - a_Typing.phone_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Typing.comments = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_Typing - case "Contact": - if body.count != 14 { return nil } - let a_Contact = Contact() - a_Contact.phone_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Contact.avatar = body[1].parse(bert: tuple.elements[2]) as? String - a_Contact.names = body[2].parse(bert: tuple.elements[3]) as? String - a_Contact.surnames = body[3].parse(bert: tuple.elements[4]) as? String - a_Contact.nick = body[4].parse(bert: tuple.elements[5]) as? String - a_Contact.reader = body[5].parse(bert: tuple.elements[6]) as? AnyObject - a_Contact.unread = body[6].parse(bert: tuple.elements[7]) as? Int64 - a_Contact.last_msg = body[7].parse(bert: tuple.elements[8]) as? Message - a_Contact.update = body[8].parse(bert: tuple.elements[9]) as? Int64 - a_Contact.created = body[9].parse(bert: tuple.elements[10]) as? Int64 - a_Contact.settings = body[10].parse(bert: tuple.elements[11]) as? [Feature] - a_Contact.services = body[11].parse(bert: tuple.elements[12]) as? [Service] - a_Contact.presence = body[12].parse(bert: tuple.elements[13]) as? AnyObject - a_Contact.status = body[13].parse(bert: tuple.elements[14]) as? AnyObject - return a_Contact - case "ExtendedStar": - if body.count != 2 { return nil } - let a_ExtendedStar = ExtendedStar() - a_ExtendedStar.star = body[0].parse(bert: tuple.elements[1]) as? Star - a_ExtendedStar.from = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_ExtendedStar - case "Auth": - if body.count != 14 { return nil } - let a_Auth = Auth() - a_Auth.client_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Auth.dev_key = body[1].parse(bert: tuple.elements[2]) as? String - a_Auth.user_id = body[2].parse(bert: tuple.elements[3]) as? String - a_Auth.phone = body[3].parse(bert: tuple.elements[4]) as? AnyObject - a_Auth.token = body[4].parse(bert: tuple.elements[5]) as? String - a_Auth.type = body[5].parse(bert: tuple.elements[6]) as? StringAtom - a_Auth.sms_code = body[6].parse(bert: tuple.elements[7]) as? String - a_Auth.attempts = body[7].parse(bert: tuple.elements[8]) as? Int64 - a_Auth.services = body[8].parse(bert: tuple.elements[9]) as? [AnyObject] - a_Auth.settings = body[9].parse(bert: tuple.elements[10]) as? [Feature] - a_Auth.push = body[10].parse(bert: tuple.elements[11]) as? String - a_Auth.os = body[11].parse(bert: tuple.elements[12]) as? AnyObject - a_Auth.created = body[12].parse(bert: tuple.elements[13]) as? Int64 - a_Auth.last_online = body[13].parse(bert: tuple.elements[14]) as? Int64 - return a_Auth - case "Roster": - if body.count != 13 { return nil } - let a_Roster = Roster() - a_Roster.id = body[0].parse(bert: tuple.elements[1]) as? AnyObject - a_Roster.names = body[1].parse(bert: tuple.elements[2]) as? String - a_Roster.surnames = body[2].parse(bert: tuple.elements[3]) as? String - a_Roster.email = body[3].parse(bert: tuple.elements[4]) as? String - a_Roster.nick = body[4].parse(bert: tuple.elements[5]) as? String - a_Roster.userlist = body[5].parse(bert: tuple.elements[6]) as? [AnyObject] - a_Roster.roomlist = body[6].parse(bert: tuple.elements[7]) as? [Room] - a_Roster.favorite = body[7].parse(bert: tuple.elements[8]) as? [Star] - a_Roster.tags = body[8].parse(bert: tuple.elements[9]) as? [Tag] - a_Roster.phone = body[9].parse(bert: tuple.elements[10]) as? String - a_Roster.avatar = body[10].parse(bert: tuple.elements[11]) as? String - a_Roster.update = body[11].parse(bert: tuple.elements[12]) as? Int64 - a_Roster.status = body[12].parse(bert: tuple.elements[13]) as? AnyObject - return a_Roster - case "Profile": - if body.count != 8 { return nil } - let a_Profile = Profile() - a_Profile.phone = body[0].parse(bert: tuple.elements[1]) as? String - a_Profile.services = body[1].parse(bert: tuple.elements[2]) as? [Service] - a_Profile.rosters = body[2].parse(bert: tuple.elements[3]) as? [AnyObject] - a_Profile.settings = body[3].parse(bert: tuple.elements[4]) as? [Feature] - a_Profile.update = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_Profile.balance = body[5].parse(bert: tuple.elements[6]) as? Int64 - a_Profile.presence = body[6].parse(bert: tuple.elements[7]) as? AnyObject - a_Profile.status = body[7].parse(bert: tuple.elements[8]) as? AnyObject - return a_Profile - case "Presence": - if body.count != 2 { return nil } - let a_Presence = Presence() - a_Presence.uid = body[0].parse(bert: tuple.elements[1]) as? String - a_Presence.status = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_Presence - case "Friend": - if body.count != 4 { return nil } - let a_Friend = Friend() - a_Friend.phone_id = body[0].parse(bert: tuple.elements[1]) as? String - a_Friend.friend_id = body[1].parse(bert: tuple.elements[2]) as? String - a_Friend.settings = body[2].parse(bert: tuple.elements[3]) as? [Feature] - a_Friend.status = body[3].parse(bert: tuple.elements[4]) as? AnyObject - return a_Friend - case "act": - if body.count != 2 { return nil } - let a_act = act() - a_act.name = body[0].parse(bert: tuple.elements[1]) as? String - a_act.data = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_act - case "Job": - if body.count != 12 { return nil } - let a_Job = Job() - a_Job.id = body[0].parse(bert: tuple.elements[1]) as? Int64 - a_Job.container = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_Job.feed_id = body[2].parse(bert: tuple.elements[3]) as? act - a_Job.prev = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_Job.next = body[4].parse(bert: tuple.elements[5]) as? Int64 - a_Job.context = body[5].parse(bert: tuple.elements[6]) as? AnyObject - a_Job.proc = body[6].parse(bert: tuple.elements[7]) as? AnyObject - a_Job.time = body[7].parse(bert: tuple.elements[8]) as? Int64 - a_Job.data = body[8].parse(bert: tuple.elements[9]) as? AnyObject - a_Job.events = body[9].parse(bert: tuple.elements[10]) as? [messageEvent] - a_Job.settings = body[10].parse(bert: tuple.elements[11]) as? [Feature] - a_Job.status = body[11].parse(bert: tuple.elements[12]) as? AnyObject - return a_Job - case "History": - if body.count != 6 { return nil } - let a_History = History() - a_History.roster_id = body[0].parse(bert: tuple.elements[1]) as? String - a_History.feed = body[1].parse(bert: tuple.elements[2]) as? AnyObject - a_History.size = body[2].parse(bert: tuple.elements[3]) as? Int64 - a_History.entity_id = body[3].parse(bert: tuple.elements[4]) as? Int64 - a_History.data = body[4].parse(bert: tuple.elements[5]) as? [AnyObject] - a_History.status = body[5].parse(bert: tuple.elements[6]) as? AnyObject - return a_History - case "error": - if body.count != 1 { return nil } - let a_error = error() - a_error.code = body[0].parse(bert: tuple.elements[1]) as? StringAtom - return a_error - case "ok": - if body.count != 1 { return nil } - let a_ok = ok() - a_ok.code = body[0].parse(bert: tuple.elements[1]) as? String - return a_ok - case "error2": - if body.count != 2 { return nil } - let a_error2 = error2() - a_error2.code = body[0].parse(bert: tuple.elements[1]) as? StringAtom - a_error2.src = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_error2 - case "ok2": - if body.count != 2 { return nil } - let a_ok2 = ok2() - a_ok2.code = body[0].parse(bert: tuple.elements[1]) as? StringAtom - a_ok2.src = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_ok2 - case "io": - if body.count != 2 { return nil } - let a_io = io() - a_io.code = body[0].parse(bert: tuple.elements[1]) as? AnyObject - a_io.data = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_io - case "Ack": - if body.count != 2 { return nil } - let a_Ack = Ack() - a_Ack.table = body[0].parse(bert: tuple.elements[1]) as? StringAtom - a_Ack.id = body[1].parse(bert: tuple.elements[2]) as? String - return a_Ack - case "errors": - if body.count != 2 { return nil } - let a_errors = errors() - a_errors.code = body[0].parse(bert: tuple.elements[1]) as? [AnyObject] - a_errors.data = body[1].parse(bert: tuple.elements[2]) as? AnyObject - return a_errors - case "PushService": - if body.count != 6 { return nil } - let a_PushService = PushService() - a_PushService.recipients = body[0].parse(bert: tuple.elements[1]) as? [AnyObject] - a_PushService.id = body[1].parse(bert: tuple.elements[2]) as? String - a_PushService.ttl = body[2].parse(bert: tuple.elements[3]) as? Int64 - a_PushService.module = body[3].parse(bert: tuple.elements[4]) as? String - a_PushService.priority = body[4].parse(bert: tuple.elements[5]) as? String - a_PushService.payload = body[5].parse(bert: tuple.elements[6]) as? String - return a_PushService - case "PublishService": - if body.count != 3 { return nil } - let a_PublishService = PublishService() - a_PublishService.message = body[0].parse(bert: tuple.elements[1]) as? String - a_PublishService.topic = body[1].parse(bert: tuple.elements[2]) as? String - a_PublishService.qos = body[2].parse(bert: tuple.elements[3]) as? Int64 - return a_PublishService - default: return nil - } -} \ No newline at end of file diff --git a/apps/roster/priv/macbert/Source/Encoder.swift b/apps/roster/priv/macbert/Source/Encoder.swift deleted file mode 100644 index ab1e97b3b..000000000 --- a/apps/roster/priv/macbert/Source/Encoder.swift +++ /dev/null @@ -1,382 +0,0 @@ -// -// Serializer.swift -// NynjaParser -// -// Created by Anton Makarov on 18.07.2017. -// Copyright © 2017 TecSynt Solutions. All rights reserved. -// - -import Foundation - -func serialize(bert: BertObject?) -> [UInt8]? { - if bert != nil { - do { - let bytes = try Bert.encode(object: bert!) - var result = [UInt8](repeating: 0, count: bytes.length) - bytes.getBytes(&result, length: bytes.length) - return result - } catch { - return nil - } - } - return nil -} - -func stringToBertBinary(input: String?) -> BertObject { - if let data = input?.data(using: String.Encoding.utf8) { - let bert = BertBinary(fromNSData: data as NSData) - return bert - } - return BertNil() -} - -func stringToBertAtom(input: StringAtom?) -> BertObject { - if let str = input?.string { - let bert = BertAtom(fromString: str) - return bert - } - return BertNil() -} - -func listFromObjects(input: [T]?) -> BertObject { - if input == nil { - return BertNil() - } else { - if input!.count == 0 { - return BertNil() - } else { - var result = [BertObject]() - for i in input! { - result.append(serialize(object: i as AnyObject)) - } - return BertList(fromElements: result) - } - } -} - -func numberFromInt64(input: Int64?) -> BertObject { - if let id = input { - return BertNumber(fromInt64: Int64(id)) - } else { - return BertNil() - } -} - - -func serialize(object: AnyObject) -> BertTuple { - var items = [BertObject]() - if let instanse = object as? Approve { - items.append(BertAtom(fromString: "Approve")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.user)) - items.append(stringToBertBinary(input: instanse.room)) - } - if let instanse = object as? ok2 { - items.append(BertAtom(fromString: "ok2")) - if let s = instanse.src { - items.append(BertAtom(fromString: s)) - } else { - items.append(BertNil()) - } - items.append(stringToBertAtom(input: instanse.code)) - } - if let instanse = object as? error2 { - items.append(BertAtom(fromString: "error2")) - if let s = instanse.src { - items.append(BertAtom(fromString: s)) - } else { - items.append(BertNil()) - } - items.append(stringToBertAtom(input: instanse.code)) - } - if let instanse = object as? Auth { - items.append(BertAtom(fromString: "Auth")) - items.append(stringToBertBinary(input: instanse.token)) - items.append(stringToBertBinary(input: instanse.dev_key)) - items.append(stringToBertBinary(input: instanse.user_id)) - items.append(stringToBertBinary(input: instanse.phone)) - items.append(stringToBertBinary(input: instanse.client_id)) - items.append(stringToBertAtom(input: instanse.type)) - items.append(stringToBertBinary(input: instanse.sms_code)) - if let atempts = instanse.attempts { - items.append(BertNumber(fromInt64: Int64(atempts))) - } else { - items.append(BertNil()) - } - if let service = instanse.services { - var result = [BertAtom]() - for i in service { - let atom = BertAtom(fromString: i) - result.append(atom) - } - items.append(BertList(fromElements: result)) - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Confirm { - items.append(BertAtom(fromString: "Confirm")) - items.append(stringToBertBinary(input: instanse.id)) - if let rosterId = instanse.roster_id { - items.append(BertNumber(fromInt64: Int64(rosterId))) - } else { - items.append(BertNil()) - } - items.append(stringToBertBinary(input: instanse.friend_id)) - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Contact { - items.append(BertAtom(fromString: "Contact")) - items.append(stringToBertBinary(input: instanse.phone_id)) - items.append(stringToBertBinary(input: instanse.avatar)) - items.append(stringToBertBinary(input: instanse.names)) - items.append(stringToBertBinary(input: instanse.surnames)) - items.append(stringToBertBinary(input: instanse.person_id)) - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - - } - if let instanse = object as? error { - items.append(BertAtom(fromString: "error")) - if let string = instanse.code as? String { - items.append(stringToBertBinary(input: string)) - } else if let string = instanse.code as? StringAtom { - items.append(stringToBertAtom(input: string)) - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Friend { - items.append(BertAtom(fromString: "Friend")) - items.append(stringToBertBinary(input: instanse.id)) - if let rosterId = instanse.roster_id { - items.append(BertNumber(fromInt64: Int64(rosterId))) - } else { - items.append(BertNil()) - } - items.append(stringToBertBinary(input: instanse.friend_id)) - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - - } - if let instanse = object as? History { - items.append(BertAtom(fromString: "History")) - items.append(stringToBertBinary(input: instanse.roster_id)) - items.append(BertNil()) - if let msgs = instanse.data { - if msgs.count == 0 { - items.append(BertNil()) - } else { - var result = [BertTuple]() - for i in msgs { - result.append(serialize(object: i)) - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - - } - if let instanse = object as? io { - items.append(BertAtom(fromString: "io")) - if let o = instanse.code as? ok { - items.append(serialize(object: o)) - } else if let err = instanse.code as? error { - items.append(serialize(object: err)) - } else if let o2 = instanse.code as? ok2 { - items.append(serialize(object: o2)) - } else if let err2 = instanse.code as? error2 { - items.append(serialize(object: err2)) - } else { - items.append(BertNil()) - } - if let o = instanse.data as? String { - items.append(stringToBertBinary(input: o)) - /* //TODO: Model(value:Tuple(name:"",body:[ - Model(value:Atom()), - Model(value:Chain(types:[ - Model(value:Binary()), - Model(value:Number())]))]))]))]))} */ - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Join { - items.append(BertAtom(fromString: "Join")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.user)) - items.append(stringToBertBinary(input: instanse.room)) - } - if let instanse = object as? Leave { - items.append(BertAtom(fromString: "Leave")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.user)) - items.append(stringToBertBinary(input: instanse.room)) - } - if let instanse = object as? Message { - //TODO: - items.append(BertAtom(fromString: "Message")) - items.append(numberFromInt64(input: instanse.id)) - items.append(stringToBertAtom(input: instanse.container)) - items.append(BertNil()) - items.append(numberFromInt64(input: instanse.prev)) - items.append(numberFromInt64(input: instanse.next)) - items.append(BertNil()) - items.append(stringToBertBinary(input: instanse.msg_id)) - items.append(stringToBertBinary(input: instanse.from)) - items.append(stringToBertBinary(input: instanse.to)) - items.append(BertNil()) - items.append(BertNil()) - items.append(BertNil()) - items.append(BertNil()) - if let atom = instanse.status as? StringAtom { - items.append(stringToBertAtom(input: atom)) - } else { - items.append(BertNil()) - } - - } - if let instanse = object as? ok { - items.append(BertAtom(fromString: "ok")) - if let string = instanse.code as? String { - items.append(stringToBertBinary(input: string)) - } else if let string = instanse.code as? StringAtom { - items.append(stringToBertAtom(input: string)) - } else { - items.append(BertNil()) - } - } - if let instanse = object as? Person { - //TODO: - items.append(BertAtom(fromString: "Person")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.names)) - items.append(stringToBertBinary(input: instanse.surnames)) - items.append(stringToBertBinary(input: instanse.username)) - items.append(BertNil()) - items.append(BertNil()) - items.append(stringToBertBinary(input: instanse.avatar)) - items.append(BertNil()) - items.append(BertNil()) - items.append(BertNil()) - items.append(stringToBertBinary(input: instanse.ThemeID)) - items.append(stringToBertBinary(input: instanse.voxImplantID)) - items.append(BertNil()) - items.append(numberFromInt64(input: instanse.balance)) - if let isParticipants = instanse.isParticipants { - if isParticipants.count == 0 { - items.append(BertNil()) - } else { - var result = [BertObject]() - for i in isParticipants { - if let j = stringToBertBinary(input: i) as? BertBinary { - result.append(j) - } - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - items.append(stringToBertAtom(input: instanse.status)) - } - if let instanse = object as? Profile { - items.append(BertAtom(fromString: "Profile")) - items.append(stringToBertBinary(input: instanse.phone)) - items.append(stringToBertBinary(input: instanse.data)) - items.append(stringToBertBinary(input: instanse.person_id)) - if let accounts = instanse.accounts as? [Roster] { - if accounts.count == 0 { - items.append(BertNil()) - } else { - var result = [BertTuple]() - for i in accounts { - result.append(serialize(object: i)) - } - items.append(BertList(fromElements: result)) - } - } else if let accounts = instanse.accounts as? [Int64] { - if accounts.count == 0 { - items.append(BertNil()) - } else { - var result = [BertNumber]() - for i in accounts { - if let n = numberFromInt64(input: i) as? BertNumber { - result.append(n) - } - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - items.append(stringToBertAtom(input: instanse.status)) - } - if let instanse = object as? Revoke { - items.append(BertAtom(fromString: "Revoke")) - items.append(stringToBertBinary(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.user)) - items.append(stringToBertAtom(input: instanse.status)) - } - if let instanse = object as? Room { - items.append(BertAtom(fromString: "Room")) - items.append(stringToBertBinary(input: instanse.desc)) - items.append(listFromObjects(input: instanse.acl)) - items.append(listFromObjects(input: instanse.settings)) - } - if let instanse = object as? Roster { - items.append(BertAtom(fromString: "Roster")) - items.append(numberFromInt64(input: instanse.id)) - items.append(stringToBertBinary(input: instanse.names)) - items.append(stringToBertBinary(input: instanse.surnames)) - items.append(numberFromInt64(input: instanse.size)) - if let userlist = instanse.userlist { - if userlist.count == 0 { - items.append(BertNil()) - } else { - var result = [BertTuple]() - for i in userlist { - result.append(serialize(object: i)) - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - if let roomlist = instanse.roomlist { - if roomlist.count == 0 { - items.append(BertNil()) - } else { - var result = [BertTuple]() - for i in roomlist { - result.append(serialize(object: i)) - } - items.append(BertList(fromElements: result)) - } - } else { - items.append(BertNil()) - } - items.append(BertNil()) //TODO - - } - if let instanse = object as? Typing { - - } - return BertTuple(fromElements: items) -} diff --git a/apps/roster/priv/macbert/Source/StringAtom.swift b/apps/roster/priv/macbert/Source/StringAtom.swift deleted file mode 100644 index 916adf2e5..000000000 --- a/apps/roster/priv/macbert/Source/StringAtom.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// StringAtom.swift -// macbert -// -// Created by Anton Makarov on 19.07.2017. -// Copyright © 2017 TecSynt Solutions. All rights reserved. -// - -import Foundation - -class StringAtom { - var string: String? = nil - init(string: String) { - self.string = string - } -} diff --git a/apps/roster/priv/macbert/Source/TypeSpec.swift b/apps/roster/priv/macbert/Source/TypeSpec.swift deleted file mode 100644 index 1c9fc6a90..000000000 --- a/apps/roster/priv/macbert/Source/TypeSpec.swift +++ /dev/null @@ -1,376 +0,0 @@ -// -// Model.swift -// Nynja -// -// Created by Anton Makarov on 11.07.2017. -// Copyright © 2017 TecSynt Solutions. All rights reserved. -// - -import Foundation -protocol Parsable { func parse(bert: BertObject) -> Any? } - -enum SelectType { - case chain - case tuple - case binary - case atom - case number - case list - case boolean -} - -class Model: Parsable { - var chain: Chain? - var tuple: Tuple? - var binary: Binary? - var number: Number? - var atom: Atom? - var list: List? - var boolean: Boolean? - var select: SelectType! - - init(value: Chain) { self.select = .chain; self.chain = value; } - init(value: Tuple) { self.select = .tuple; self.tuple = value; } - init(value: Atom) { self.select = .atom; self.atom = value; } - init(value: Binary) { self.select = .binary; self.binary = value; } - init(value: Number) { self.select = .number; self.number = value; } - init(value: List) { self.select = .list; self.list = value; } - init(value: Boolean){ self.select = .boolean;self.boolean = value;} - - var description : String { - get { - switch select! { - case .atom: - return atom!.description - case .binary: - return binary!.description - case .chain: - return chain!.description - case .number: - return number!.description - case .tuple: - return tuple!.description - case .list: - return list!.description - case .boolean: - return boolean!.description - } - } - } - func parse(bert: BertObject) -> Any? { - switch select! { - case .atom: - return atom!.parse(bert:bert) - case .binary: - return binary!.parse(bert:bert) - case .chain: - return chain!.parse(bert:bert) - case .number: - return number!.parse(bert:bert) - case .tuple: - return tuple!.parse(bert:bert) - case .list: - return list!.parse(bert: bert) - case .boolean: - return boolean!.parse(bert:bert) - } - } -} - -class Boolean: Parsable { - - func parse(bert: BertObject) -> Any? { - if let bool = bert as? BertBool { - return bool.value - } - return nil - } - - var description : String { - get { - return "Bool()" - } - } -} - - -func parse(bert: BertObject) -> Any? -{ - if let object = bert as? BertAtom { - return object.value - } - if let object = bert as? BertTuple { - var result = [Any]() - for i in object.elements { - if let any = parse(bert: i) { - result.append(any) - } - } - return result - } - if let _ = bert as? BertNil { - return [Any]() - } - if let object = bert as? BertBool { - return object.value as AnyObject - } - if let object = bert as? BertList { - var result = [Any]() - for i in object.elements { - if let any = parse(bert: i) { - result.append(any) - } - } - return result - } - if let object = bert as? BertString { - return object.value - } - if let object = bert as? BertBinary { - return object.value - } - if let object = bert as? BertNumber { - return object.value - } - if let object = bert as? BertFloat { - return object.value - } - return nil -} - - -class Tuple: Parsable { - var name: String? - var body: [Model]? - init(name: String? = nil , body: [Model]? = nil) { self.name = name; self.body = body;} - - func parse(bert: BertObject) -> Any? { - if let tuple = bert as? BertTuple { - if body == nil { - var result = [Any]() - for i in 0.. Any? { - if let const = constant { - if let string = bert as? BertString { - if string.value == const { - return const - } - } - } else { - if let list = bert as? BertList { - if let result = self.addToList(list: list) { - return result - } - } - } - return nil - } - - func addToList(list: BertList) -> [Any]? { - var result = [Any]() - if let mod = model { - for i in list.elements { - if let value = mod.parse(bert: i) { - result.append(value) - } else { - return nil - } - } - } else { - var result = [Any]() - for i in 0.. Any? { - if let atom = bert as? BertAtom { - if let const = constant { - if atom.value == const { - return StringAtom(string:atom.value) - } - } else { - return StringAtom(string:atom.value) - } - } - return nil - } - - var description : String { - get { - return constant ?? "Atom()" - } - } -} - - -class Binary: Parsable { - var constant: String? - init() { constant = nil } - init(constant: String) { self.constant = constant } - func parse(bert: BertObject) -> Any? { - if let bin = bert as? BertBinary { - if let const = constant { - let dataString = String(data: bin.value as Data, encoding: String.Encoding.utf8) - if dataString == const { - return String(data: bin.value as Data, encoding: String.Encoding.utf8) - } - } else { - - return String(data: bin.value as Data, encoding: String.Encoding.utf8) - } - } - return nil - } - var description : String { - get { - return constant ?? "Binary()" - } - } -} - -class Number: Parsable { - var constant: String? - init() { constant = nil } - init(constant: String) { self.constant = constant } - func parse(bert: BertObject) -> Any? { - if let num = bert as? BertNumber { - if let const = constant { - if const == "\(num.value)" { - return Int64(num.value) - } - } else { - return Int64(num.value) - } - } - return nil - } - var description : String { - get { - return constant ?? "Number()" - } - } -} - - -class Chain: Parsable { - var types: [Model]! - init(types: [Model]) { self.types = types } - - func parse(bert: BertObject) -> Any? { - for model in types { - if let obj = model.parse(bert: bert) { - return obj - } - } - return nil - } - - - var description : String { - get { - var text = "" - for i in 0.. Model { - return Model(value:Tuple(name:"Ack",body:[ - Model(value:Atom()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/Auth_Spec.swift b/apps/roster/priv/macbert/Spec/Auth_Spec.swift deleted file mode 100644 index 44b108bb9..000000000 --- a/apps/roster/priv/macbert/Spec/Auth_Spec.swift +++ /dev/null @@ -1,47 +0,0 @@ -func get_Auth() -> Model { - return Model(value:Tuple(name:"Auth",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - Model(value:Tuple(name:nil,body:[ - Model(value:Atom(constant:"fake")), - Model(value:Binary())]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"ios")), - Model(value:Atom(constant:"android")), - Model(value:Atom(constant:"web"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/CDR_Spec.swift b/apps/roster/priv/macbert/Spec/CDR_Spec.swift deleted file mode 100644 index 1e714c03c..000000000 --- a/apps/roster/priv/macbert/Spec/CDR_Spec.swift +++ /dev/null @@ -1,38 +0,0 @@ -func get_CDR() -> Model { - return Model(value:Tuple(name:"CDR",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"pstn")), - Model(value:Atom(constant:"inet"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/CallMember_Spec.swift b/apps/roster/priv/macbert/Spec/CallMember_Spec.swift deleted file mode 100644 index 8eb9ab141..000000000 --- a/apps/roster/priv/macbert/Spec/CallMember_Spec.swift +++ /dev/null @@ -1,48 +0,0 @@ -func get_CallMember() -> Model { - return Model(value:Tuple(name:"CallMember",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - get_Contact(), - get_Member()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"pstn")), - Model(value:Atom(constant:"inet"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"new")), - Model(value:Atom(constant:"join")), - Model(value:Atom(constant:"leave")), - Model(value:Atom(constant:"miss")), - Model(value:Atom(constant:"cancel")), - Model(value:Atom(constant:"active")), - Model(value:Atom(constant:"finish"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Call_Spec.swift b/apps/roster/priv/macbert/Spec/Call_Spec.swift deleted file mode 100644 index d827f117d..000000000 --- a/apps/roster/priv/macbert/Spec/Call_Spec.swift +++ /dev/null @@ -1,24 +0,0 @@ -func get_Call() -> Model { - return Model(value:Tuple(name:"Call",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil,model:get_CallMember())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"start")), - Model(value:Atom(constant:"cancel")), - Model(value:Atom(constant:"active")), - Model(value:Atom(constant:"finish"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Contact_Spec.swift b/apps/roster/priv/macbert/Spec/Contact_Spec.swift deleted file mode 100644 index 5271e6a07..000000000 --- a/apps/roster/priv/macbert/Spec/Contact_Spec.swift +++ /dev/null @@ -1,51 +0,0 @@ -func get_Contact() -> Model { - return Model(value:Tuple(name:"Contact",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - Model(value:List(constant:nil, model:Model(value:Number())))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - get_Message()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil,model:get_Feature())), - Model(value:List(constant:nil,model:get_Service())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"online")), - Model(value:Atom(constant:"offline")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"request")), - Model(value:Atom(constant:"authorization")), - Model(value:Atom(constant:"ignore")), - Model(value:Atom(constant:"internal")), - Model(value:Atom(constant:"friend")), - Model(value:Atom(constant:"last_msg")), - Model(value:Atom(constant:"ban")), - Model(value:Atom(constant:"banned")), - Model(value:Atom(constant:"deleted"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Cursor_Spec.swift b/apps/roster/priv/macbert/Spec/Cursor_Spec.swift deleted file mode 100644 index 8cadac044..000000000 --- a/apps/roster/priv/macbert/Spec/Cursor_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_Cursor() -> Model { - return Model(value:Tuple(name:"Cursor",body:[ - Model(value:Chain(types:[ - get_muc(), - get_p2p()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/Desc_Spec.swift b/apps/roster/priv/macbert/Spec/Desc_Spec.swift deleted file mode 100644 index 941751467..000000000 --- a/apps/roster/priv/macbert/Spec/Desc_Spec.swift +++ /dev/null @@ -1,13 +0,0 @@ -func get_Desc() -> Model { - return Model(value:Tuple(name:"Desc",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Binary()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil,model:get_Feature()))]))} diff --git a/apps/roster/priv/macbert/Spec/ExtendedStar_Spec.swift b/apps/roster/priv/macbert/Spec/ExtendedStar_Spec.swift deleted file mode 100644 index 45d891a2a..000000000 --- a/apps/roster/priv/macbert/Spec/ExtendedStar_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_ExtendedStar() -> Model { - return Model(value:Tuple(name:"ExtendedStar",body:[ - Model(value:Chain(types:[ - get_Star(), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - get_Contact(), - get_Room(), - Model(value:List(constant:""))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Feature_Spec.swift b/apps/roster/priv/macbert/Spec/Feature_Spec.swift deleted file mode 100644 index eaf569a31..000000000 --- a/apps/roster/priv/macbert/Spec/Feature_Spec.swift +++ /dev/null @@ -1,8 +0,0 @@ -func get_Feature() -> Model { - return Model(value:Tuple(name:"Feature",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Binary()), - Model(value:Binary()), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/Friend_Spec.swift b/apps/roster/priv/macbert/Spec/Friend_Spec.swift deleted file mode 100644 index 34ced364e..000000000 --- a/apps/roster/priv/macbert/Spec/Friend_Spec.swift +++ /dev/null @@ -1,14 +0,0 @@ -func get_Friend() -> Model { - return Model(value:Tuple(name:"Friend",body:[ - Model(value:Binary()), - Model(value:Binary()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"ban")), - Model(value:Atom(constant:"unban")), - Model(value:Atom(constant:"request")), - Model(value:Atom(constant:"confirm")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"ignore"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/History_Spec.swift b/apps/roster/priv/macbert/Spec/History_Spec.swift deleted file mode 100644 index 879fccf91..000000000 --- a/apps/roster/priv/macbert/Spec/History_Spec.swift +++ /dev/null @@ -1,38 +0,0 @@ -func get_History() -> Model { - return Model(value:Tuple(name:"History",body:[ - Model(value:Binary()), - Model(value:Chain(types:[ - get_p2p(), - get_muc(), - get_act(), - get_StickerPack(), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_Message(), - get_Job(), - get_StickerPack()]))))])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"updated")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"last_loaded")), - Model(value:Atom(constant:"last_msg")), - Model(value:Atom(constant:"get_reply")), - Model(value:Atom(constant:"double_get")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"image")), - Model(value:Atom(constant:"video")), - Model(value:Atom(constant:"file")), - Model(value:Atom(constant:"link")), - Model(value:Atom(constant:"audio")), - Model(value:Atom(constant:"contact")), - Model(value:Atom(constant:"location")), - Model(value:Atom(constant:"text"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Index_Spec.swift b/apps/roster/priv/macbert/Spec/Index_Spec.swift deleted file mode 100644 index 9f7e4a1f6..000000000 --- a/apps/roster/priv/macbert/Spec/Index_Spec.swift +++ /dev/null @@ -1,6 +0,0 @@ -func get_Index() -> Model { - return Model(value:Tuple(name:"Index",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))))]))} diff --git a/apps/roster/priv/macbert/Spec/Job_Spec.swift b/apps/roster/priv/macbert/Spec/Job_Spec.swift deleted file mode 100644 index 68ba975da..000000000 --- a/apps/roster/priv/macbert/Spec/Job_Spec.swift +++ /dev/null @@ -1,45 +0,0 @@ -func get_Job() -> Model { - return Model(value:Tuple(name:"Job",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"chain")), - Model(value:List(constant:""))])), - get_act(), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - get_process()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - Model(value:List(constant:nil,model:get_Message()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_messageEvent()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"init")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"pending")), - Model(value:Atom(constant:"stop")), - Model(value:Atom(constant:"complete")), - Model(value:Atom(constant:"restart"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Link_Spec.swift b/apps/roster/priv/macbert/Spec/Link_Spec.swift deleted file mode 100644 index 35c091fac..000000000 --- a/apps/roster/priv/macbert/Spec/Link_Spec.swift +++ /dev/null @@ -1,27 +0,0 @@ -func get_Link() -> Model { - return Model(value:Tuple(name:"Link",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"group")), - Model(value:Atom(constant:"channel"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"gen")), - Model(value:Atom(constant:"check")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"join")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"delete"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Loc_Spec.swift b/apps/roster/priv/macbert/Spec/Loc_Spec.swift deleted file mode 100644 index 561dadfc1..000000000 --- a/apps/roster/priv/macbert/Spec/Loc_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_Loc() -> Model { - return Model(value:Tuple(name:"Loc",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/Member_Spec.swift b/apps/roster/priv/macbert/Spec/Member_Spec.swift deleted file mode 100644 index cf7a14112..000000000 --- a/apps/roster/priv/macbert/Spec/Member_Spec.swift +++ /dev/null @@ -1,58 +0,0 @@ -func get_Member() -> Model { - return Model(value:Tuple(name:"Member",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"chain")), - Model(value:Atom(constant:"cur")), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - get_muc(), - get_p2p(), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil)), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Service()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"online")), - Model(value:Atom(constant:"offline"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"admin")), - Model(value:Atom(constant:"member")), - Model(value:Atom(constant:"removed")), - Model(value:Atom(constant:"patch")), - Model(value:Atom(constant:"owner"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Message_Spec.swift b/apps/roster/priv/macbert/Spec/Message_Spec.swift deleted file mode 100644 index 7cde1159f..000000000 --- a/apps/roster/priv/macbert/Spec/Message_Spec.swift +++ /dev/null @@ -1,60 +0,0 @@ -func get_Message() -> Model { - return Model(value:Tuple(name:"Message",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"chain")), - Model(value:Atom(constant:"cur")), - Model(value:List(constant:""))])), - Model(value:Chain(types:[ - get_muc(), - get_p2p()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil,model:get_Desc())), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - Model(value:Atom(constant:"sys")), - Model(value:Atom(constant:"reply")), - Model(value:Atom(constant:"forward")), - Model(value:Atom(constant:"read")), - Model(value:Atom(constant:"edited")), - Model(value:Atom(constant:"cursor"))])))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - get_Message()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - Model(value:Binary()), - Model(value:Number())]))))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Number())))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Number())))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"async")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"clear")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"edit"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Person_Spec.swift b/apps/roster/priv/macbert/Spec/Person_Spec.swift deleted file mode 100644 index c72d2314a..000000000 --- a/apps/roster/priv/macbert/Spec/Person_Spec.swift +++ /dev/null @@ -1,15 +0,0 @@ -func get_Person() -> Model { - return Model(value:Tuple(name:"Person",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil, model:Model(value:Binary()))), - Model(value:List(constant:nil)), - Model(value:List(constant:nil)), - Model(value:List(constant:nil)), - Model(value:List(constant:nil)), - Model(value:Binary()), - Model(value:List(constant:nil, model:Model(value:Binary()))), - Model(value:Number()), - Model(value:List(constant:nil, model:Model(value:Atom()))), - Model(value:List(constant:""))]))} diff --git a/apps/roster/priv/macbert/Spec/Profile_Spec.swift b/apps/roster/priv/macbert/Spec/Profile_Spec.swift deleted file mode 100644 index 063942855..000000000 --- a/apps/roster/priv/macbert/Spec/Profile_Spec.swift +++ /dev/null @@ -1,31 +0,0 @@ -func get_Profile() -> Model { - return Model(value:Tuple(name:"Profile",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Service()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_Roster(), - Model(value:Binary())]))))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Feature()))])), - Model(value:Number()), - Model(value:Number()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"offline")), - Model(value:Atom(constant:"online")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"remove")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"patch")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"create"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/PushService_Spec.swift b/apps/roster/priv/macbert/Spec/PushService_Spec.swift deleted file mode 100644 index 02fe4dd8f..000000000 --- a/apps/roster/priv/macbert/Spec/PushService_Spec.swift +++ /dev/null @@ -1,18 +0,0 @@ -func get_PushService() -> Model { - return Model(value:Tuple(name:"PushService",body:[ - Model(value:List(constant:nil, model:Model(value:Binary()))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/Room_Spec.swift b/apps/roster/priv/macbert/Spec/Room_Spec.swift deleted file mode 100644 index a84bb1410..000000000 --- a/apps/roster/priv/macbert/Spec/Room_Spec.swift +++ /dev/null @@ -1,60 +0,0 @@ -func get_Room() -> Model { - return Model(value:Tuple(name:"Room",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_Link()))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil,model:get_Feature())), - Model(value:List(constant:nil,model:get_Member())), - Model(value:List(constant:nil,model:get_Member())), - Model(value:List(constant:nil,model:get_Desc())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"group")), - Model(value:Atom(constant:"channel")), - Model(value:Atom(constant:"call"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil, model:Model(value:Number()))), - Model(value:List(constant:nil, model:Model(value:Number()))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number()), - get_Message()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"create")), - Model(value:Atom(constant:"leave")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"remove")), - Model(value:Atom(constant:"removed")), - Model(value:Atom(constant:"join")), - Model(value:Atom(constant:"joined")), - Model(value:Atom(constant:"info")), - Model(value:Atom(constant:"patch")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"delete")), - Model(value:Atom(constant:"last_msg")), - Model(value:Atom(constant:"mute")), - Model(value:Atom(constant:"unmute"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Roster_Spec.swift b/apps/roster/priv/macbert/Spec/Roster_Spec.swift deleted file mode 100644 index 9fc58594c..000000000 --- a/apps/roster/priv/macbert/Spec/Roster_Spec.swift +++ /dev/null @@ -1,45 +0,0 @@ -func get_Roster() -> Model { - return Model(value:Tuple(name:"Roster",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_Contact(), - Model(value:Number())])))), - Model(value:List(constant:nil,model:get_Room())), - Model(value:List(constant:nil,model:get_Star())), - Model(value:List(constant:nil,model:get_Tag())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"get")), - Model(value:Atom(constant:"create")), - Model(value:Atom(constant:"del")), - Model(value:Atom(constant:"remove")), - Model(value:Atom(constant:"nick")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"update")), - Model(value:Atom(constant:"list")), - Model(value:Atom(constant:"patch")), - Model(value:Atom(constant:"last_msg"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Schedule_Spec.swift b/apps/roster/priv/macbert/Spec/Schedule_Spec.swift deleted file mode 100644 index 09fbf55e6..000000000 --- a/apps/roster/priv/macbert/Spec/Schedule_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_Schedule() -> Model { - return Model(value:Tuple(name:"Schedule",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Search_Spec.swift b/apps/roster/priv/macbert/Spec/Search_Spec.swift deleted file mode 100644 index c5be4d12b..000000000 --- a/apps/roster/priv/macbert/Spec/Search_Spec.swift +++ /dev/null @@ -1,16 +0,0 @@ -func get_Search() -> Model { - return Model(value:Tuple(name:"Search",body:[ - Model(value:Number()), - Model(value:Binary()), - Model(value:Binary()), - Model(value:Chain(types:[ - Model(value:Atom(constant:"==")), - Model(value:Atom(constant:"!=")), - Model(value:Atom(constant:"like"))])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])))), - Model(value:Chain(types:[ - Model(value:Atom(constant:"profile")), - Model(value:Atom(constant:"roster")), - Model(value:Atom(constant:"contact")), - Model(value:Atom(constant:"member")), - Model(value:Atom(constant:"room"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Service_Spec.swift b/apps/roster/priv/macbert/Spec/Service_Spec.swift deleted file mode 100644 index 3360f9955..000000000 --- a/apps/roster/priv/macbert/Spec/Service_Spec.swift +++ /dev/null @@ -1,26 +0,0 @@ -func get_Service() -> Model { - return Model(value:Tuple(name:"Service",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:Atom(constant:"email")), - Model(value:Atom(constant:"vox")), - Model(value:Atom(constant:"aws")), - Model(value:Atom(constant:"wallet"))])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"verified")), - Model(value:Atom(constant:"added")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"remove"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Star_Spec.swift b/apps/roster/priv/macbert/Spec/Star_Spec.swift deleted file mode 100644 index a4671f16b..000000000 --- a/apps/roster/priv/macbert/Spec/Star_Spec.swift +++ /dev/null @@ -1,17 +0,0 @@ -func get_Star() -> Model { - return Model(value:Tuple(name:"Star",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - get_Message(), - Model(value:List(constant:nil,model:get_Tag())), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"add")), - Model(value:Atom(constant:"remove"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/StickerPack_Spec.swift b/apps/roster/priv/macbert/Spec/StickerPack_Spec.swift deleted file mode 100644 index a37abc69a..000000000 --- a/apps/roster/priv/macbert/Spec/StickerPack_Spec.swift +++ /dev/null @@ -1,19 +0,0 @@ -func get_StickerPack() -> Model { - return Model(value:Tuple(name:"StickerPack",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil, model:Model(value:Binary()))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil,model:get_Desc())), - Model(value:Number()), - Model(value:Number()), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/Tag_Spec.swift b/apps/roster/priv/macbert/Spec/Tag_Spec.swift deleted file mode 100644 index 4f9ae9504..000000000 --- a/apps/roster/priv/macbert/Spec/Tag_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_Tag() -> Model { - return Model(value:Tuple(name:"Tag",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Binary()), - Model(value:Binary()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"create")), - Model(value:Atom(constant:"remove")), - Model(value:Atom(constant:"edit"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Test_Spec.swift b/apps/roster/priv/macbert/Spec/Test_Spec.swift deleted file mode 100644 index 08e0dc24b..000000000 --- a/apps/roster/priv/macbert/Spec/Test_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_Test() -> Model { - return Model(value:Tuple(name:"Test",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"message")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/Typing_Spec.swift b/apps/roster/priv/macbert/Spec/Typing_Spec.swift deleted file mode 100644 index 41ceda8a5..000000000 --- a/apps/roster/priv/macbert/Spec/Typing_Spec.swift +++ /dev/null @@ -1,4 +0,0 @@ -func get_Typing() -> Model { - return Model(value:Tuple(name:"Typing",body:[ - Model(value:Binary()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))} diff --git a/apps/roster/priv/macbert/Spec/Vox_Spec.swift b/apps/roster/priv/macbert/Spec/Vox_Spec.swift deleted file mode 100644 index ad63c47cf..000000000 --- a/apps/roster/priv/macbert/Spec/Vox_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_Vox() -> Model { - return Model(value:Tuple(name:"Vox",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/act_Spec.swift b/apps/roster/priv/macbert/Spec/act_Spec.swift deleted file mode 100644 index 91273021b..000000000 --- a/apps/roster/priv/macbert/Spec/act_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_act() -> Model { - return Model(value:Tuple(name:"act",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:Binary()), - Model(value:Number()), - Model(value:List(constant:nil, model:Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))))]))]))} diff --git a/apps/roster/priv/macbert/Spec/amend_Spec.swift b/apps/roster/priv/macbert/Spec/amend_Spec.swift deleted file mode 100644 index 7a08766c3..000000000 --- a/apps/roster/priv/macbert/Spec/amend_Spec.swift +++ /dev/null @@ -1,8 +0,0 @@ -func get_amend() -> Model { - return Model(value:Tuple(name:"amend",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Tuple())))]))]))} diff --git a/apps/roster/priv/macbert/Spec/beginEvent_Spec.swift b/apps/roster/priv/macbert/Spec/beginEvent_Spec.swift deleted file mode 100644 index f7eefc2ee..000000000 --- a/apps/roster/priv/macbert/Spec/beginEvent_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_beginEvent() -> Model { - return Model(value:Tuple(name:"beginEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple())))]))} diff --git a/apps/roster/priv/macbert/Spec/boundaryEvent_Spec.swift b/apps/roster/priv/macbert/Spec/boundaryEvent_Spec.swift deleted file mode 100644 index e40ced10e..000000000 --- a/apps/roster/priv/macbert/Spec/boundaryEvent_Spec.swift +++ /dev/null @@ -1,19 +0,0 @@ -func get_boundaryEvent() -> Model { - return Model(value:Tuple(name:"boundaryEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Number()), - Model(value:Number())]))])), - Model(value:Binary()), - Model(value:Binary()), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/chain_Spec.swift b/apps/roster/priv/macbert/Spec/chain_Spec.swift deleted file mode 100644 index f492b041c..000000000 --- a/apps/roster/priv/macbert/Spec/chain_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_chain() -> Model { - return Model(value:Tuple(name:"chain",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/complete_Spec.swift b/apps/roster/priv/macbert/Spec/complete_Spec.swift deleted file mode 100644 index 3f6ac99bc..000000000 --- a/apps/roster/priv/macbert/Spec/complete_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_complete() -> Model { - return Model(value:Tuple(name:"complete",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/container_Spec.swift b/apps/roster/priv/macbert/Spec/container_Spec.swift deleted file mode 100644 index ea52d6cf2..000000000 --- a/apps/roster/priv/macbert/Spec/container_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_container() -> Model { - return Model(value:Tuple(name:"container",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/create_Spec.swift b/apps/roster/priv/macbert/Spec/create_Spec.swift deleted file mode 100644 index 40aeb3b46..000000000 --- a/apps/roster/priv/macbert/Spec/create_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_create() -> Model { - return Model(value:Tuple(name:"create",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - get_process(), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Tuple())))]))]))} diff --git a/apps/roster/priv/macbert/Spec/cur_Spec.swift b/apps/roster/priv/macbert/Spec/cur_Spec.swift deleted file mode 100644 index 1594fc906..000000000 --- a/apps/roster/priv/macbert/Spec/cur_Spec.swift +++ /dev/null @@ -1,21 +0,0 @@ -func get_cur() -> Model { - return Model(value:Tuple(name:"cur",body:[ - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:Number(constant:"0")), - Model(value:Number(constant:"1"))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple())])), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - Model(value:Tuple()), - Model(value:Number())]))))]))} diff --git a/apps/roster/priv/macbert/Spec/endEvent_Spec.swift b/apps/roster/priv/macbert/Spec/endEvent_Spec.swift deleted file mode 100644 index 9cd2fe816..000000000 --- a/apps/roster/priv/macbert/Spec/endEvent_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_endEvent() -> Model { - return Model(value:Tuple(name:"endEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple())))]))} diff --git a/apps/roster/priv/macbert/Spec/error2_Spec.swift b/apps/roster/priv/macbert/Spec/error2_Spec.swift deleted file mode 100644 index 1e8be3701..000000000 --- a/apps/roster/priv/macbert/Spec/error2_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_error2() -> Model { - return Model(value:Tuple(name:"error2",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/error_Spec.swift b/apps/roster/priv/macbert/Spec/error_Spec.swift deleted file mode 100644 index 838420e66..000000000 --- a/apps/roster/priv/macbert/Spec/error_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_error() -> Model { - return Model(value:Tuple(name:"error",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())]))]))} diff --git a/apps/roster/priv/macbert/Spec/errors_Spec.swift b/apps/roster/priv/macbert/Spec/errors_Spec.swift deleted file mode 100644 index 4fb43f80a..000000000 --- a/apps/roster/priv/macbert/Spec/errors_Spec.swift +++ /dev/null @@ -1,8 +0,0 @@ -func get_errors() -> Model { - return Model(value:Tuple(name:"errors",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Binary())))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))]))} diff --git a/apps/roster/priv/macbert/Spec/hist_Spec.swift b/apps/roster/priv/macbert/Spec/hist_Spec.swift deleted file mode 100644 index 5859163c6..000000000 --- a/apps/roster/priv/macbert/Spec/hist_Spec.swift +++ /dev/null @@ -1,20 +0,0 @@ -func get_hist() -> Model { - return Model(value:Tuple(name:"hist",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil)), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Atom()), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))} diff --git a/apps/roster/priv/macbert/Spec/histo_Spec.swift b/apps/roster/priv/macbert/Spec/histo_Spec.swift deleted file mode 100644 index 1d8c29ee0..000000000 --- a/apps/roster/priv/macbert/Spec/histo_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_histo() -> Model { - return Model(value:Tuple(name:"histo",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/io_Spec.swift b/apps/roster/priv/macbert/Spec/io_Spec.swift deleted file mode 100644 index 15b432801..000000000 --- a/apps/roster/priv/macbert/Spec/io_Spec.swift +++ /dev/null @@ -1,17 +0,0 @@ -func get_io() -> Model { - return Model(value:Tuple(name:"io",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - get_ok(), - get_error(), - get_ok2(), - get_error2()])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary()), - get_Roster(), - Model(value:Tuple(name:nil,body:[ - Model(value:Atom()), - Model(value:Chain(types:[ - Model(value:Binary()), - Model(value:Number())]))]))]))]))} diff --git a/apps/roster/priv/macbert/Spec/iter_Spec.swift b/apps/roster/priv/macbert/Spec/iter_Spec.swift deleted file mode 100644 index 478e58d57..000000000 --- a/apps/roster/priv/macbert/Spec/iter_Spec.swift +++ /dev/null @@ -1,13 +0,0 @@ -func get_iter() -> Model { - return Model(value:Tuple(name:"iter",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/iterator_Spec.swift b/apps/roster/priv/macbert/Spec/iterator_Spec.swift deleted file mode 100644 index e902370ae..000000000 --- a/apps/roster/priv/macbert/Spec/iterator_Spec.swift +++ /dev/null @@ -1,14 +0,0 @@ -func get_iterator() -> Model { - return Model(value:Tuple(name:"iterator",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil))]))} diff --git a/apps/roster/priv/macbert/Spec/join_application_Spec.swift b/apps/roster/priv/macbert/Spec/join_application_Spec.swift deleted file mode 100644 index db985eaa0..000000000 --- a/apps/roster/priv/macbert/Spec/join_application_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_join_application() -> Model { - return Model(value:Tuple(name:"join_application",body:[ - Model(value:Number()), - Model(value:Binary()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))} diff --git a/apps/roster/priv/macbert/Spec/log_Spec.swift b/apps/roster/priv/macbert/Spec/log_Spec.swift deleted file mode 100644 index dd14f37db..000000000 --- a/apps/roster/priv/macbert/Spec/log_Spec.swift +++ /dev/null @@ -1,12 +0,0 @@ -func get_log() -> Model { - return Model(value:Tuple(name:"log",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/max_tour_Spec.swift b/apps/roster/priv/macbert/Spec/max_tour_Spec.swift deleted file mode 100644 index 237c71183..000000000 --- a/apps/roster/priv/macbert/Spec/max_tour_Spec.swift +++ /dev/null @@ -1,4 +0,0 @@ -func get_max_tour() -> Model { - return Model(value:Tuple(name:"max_tour",body:[ - Model(value:Number()), - Model(value:Number())]))} diff --git a/apps/roster/priv/macbert/Spec/messageEvent_Spec.swift b/apps/roster/priv/macbert/Spec/messageEvent_Spec.swift deleted file mode 100644 index c9af1dbf7..000000000 --- a/apps/roster/priv/macbert/Spec/messageEvent_Spec.swift +++ /dev/null @@ -1,16 +0,0 @@ -func get_messageEvent() -> Model { - return Model(value:Tuple(name:"messageEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Number()), - Model(value:Number())]))]))]))} diff --git a/apps/roster/priv/macbert/Spec/mqi_Spec.swift b/apps/roster/priv/macbert/Spec/mqi_Spec.swift deleted file mode 100644 index 1dd03ebcc..000000000 --- a/apps/roster/priv/macbert/Spec/mqi_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_mqi() -> Model { - return Model(value:Tuple(name:"mqi",body:[ - get_muc(), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom(constant:"admin")), - Model(value:Atom(constant:"member")), - Model(value:Atom(constant:"removed"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/muc_Spec.swift b/apps/roster/priv/macbert/Spec/muc_Spec.swift deleted file mode 100644 index 6074d67af..000000000 --- a/apps/roster/priv/macbert/Spec/muc_Spec.swift +++ /dev/null @@ -1,3 +0,0 @@ -func get_muc() -> Model { - return Model(value:Tuple(name:"muc",body:[ - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/ok2_Spec.swift b/apps/roster/priv/macbert/Spec/ok2_Spec.swift deleted file mode 100644 index 59c2675c1..000000000 --- a/apps/roster/priv/macbert/Spec/ok2_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_ok2() -> Model { - return Model(value:Tuple(name:"ok2",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple(name:nil,body:[ - Model(value:Binary()), - Model(value:Binary())])), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/ok_Spec.swift b/apps/roster/priv/macbert/Spec/ok_Spec.swift deleted file mode 100644 index 0ad3df7da..000000000 --- a/apps/roster/priv/macbert/Spec/ok_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_ok() -> Model { - return Model(value:Tuple(name:"ok",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/operation_Spec.swift b/apps/roster/priv/macbert/Spec/operation_Spec.swift deleted file mode 100644 index d799e38c5..000000000 --- a/apps/roster/priv/macbert/Spec/operation_Spec.swift +++ /dev/null @@ -1,14 +0,0 @@ -func get_operation() -> Model { - return Model(value:Tuple(name:"operation",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil))]))} diff --git a/apps/roster/priv/macbert/Spec/p2p_Spec.swift b/apps/roster/priv/macbert/Spec/p2p_Spec.swift deleted file mode 100644 index b175ecd9f..000000000 --- a/apps/roster/priv/macbert/Spec/p2p_Spec.swift +++ /dev/null @@ -1,4 +0,0 @@ -func get_p2p() -> Model { - return Model(value:Tuple(name:"p2p",body:[ - Model(value:Binary()), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/proc_Spec.swift b/apps/roster/priv/macbert/Spec/proc_Spec.swift deleted file mode 100644 index 6f1007830..000000000 --- a/apps/roster/priv/macbert/Spec/proc_Spec.swift +++ /dev/null @@ -1,5 +0,0 @@ -func get_proc() -> Model { - return Model(value:Tuple(name:"proc",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())]))]))} diff --git a/apps/roster/priv/macbert/Spec/process_Spec.swift b/apps/roster/priv/macbert/Spec/process_Spec.swift deleted file mode 100644 index e9c7e0513..000000000 --- a/apps/roster/priv/macbert/Spec/process_Spec.swift +++ /dev/null @@ -1,56 +0,0 @@ -func get_process() -> Model { - return Model(value:Tuple(name:"process",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Atom()), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:List(constant:nil)), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:List(constant:nil)), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_task(), - get_serviceTask(), - get_userTask(), - get_receiveTask()])))), - Model(value:List(constant:nil, model:Model(value:Chain(types:[ - get_messageEvent(), - get_boundaryEvent(), - get_timeoutEvent()])))), - Model(value:List(constant:"")), - Model(value:List(constant:nil,model:get_sequenceFlow())), - Model(value:List(constant:"")), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple(name:nil,body:[ - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())]))]))} diff --git a/apps/roster/priv/macbert/Spec/push_Spec.swift b/apps/roster/priv/macbert/Spec/push_Spec.swift deleted file mode 100644 index ef9a76e40..000000000 --- a/apps/roster/priv/macbert/Spec/push_Spec.swift +++ /dev/null @@ -1,20 +0,0 @@ -func get_push() -> Model { - return Model(value:Tuple(name:"push",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/reader_Spec.swift b/apps/roster/priv/macbert/Spec/reader_Spec.swift deleted file mode 100644 index 923d86e70..000000000 --- a/apps/roster/priv/macbert/Spec/reader_Spec.swift +++ /dev/null @@ -1,14 +0,0 @@ -func get_reader() -> Model { - return Model(value:Tuple(name:"reader",body:[ - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Number())])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:Number(constant:"0")), - Model(value:Number(constant:"1"))]))]))} diff --git a/apps/roster/priv/macbert/Spec/receiveTask_Spec.swift b/apps/roster/priv/macbert/Spec/receiveTask_Spec.swift deleted file mode 100644 index 81cf3c76b..000000000 --- a/apps/roster/priv/macbert/Spec/receiveTask_Spec.swift +++ /dev/null @@ -1,10 +0,0 @@ -func get_receiveTask() -> Model { - return Model(value:Tuple(name:"receiveTask",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/sequenceFlow_Spec.swift b/apps/roster/priv/macbert/Spec/sequenceFlow_Spec.swift deleted file mode 100644 index bc21a8ebe..000000000 --- a/apps/roster/priv/macbert/Spec/sequenceFlow_Spec.swift +++ /dev/null @@ -1,9 +0,0 @@ -func get_sequenceFlow() -> Model { - return Model(value:Tuple(name:"sequenceFlow",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom()), - Model(value:List(constant:nil, model:Model(value:Atom())))]))]))} diff --git a/apps/roster/priv/macbert/Spec/serviceTask_Spec.swift b/apps/roster/priv/macbert/Spec/serviceTask_Spec.swift deleted file mode 100644 index 586517f5d..000000000 --- a/apps/roster/priv/macbert/Spec/serviceTask_Spec.swift +++ /dev/null @@ -1,10 +0,0 @@ -func get_serviceTask() -> Model { - return Model(value:Tuple(name:"serviceTask",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/task_Spec.swift b/apps/roster/priv/macbert/Spec/task_Spec.swift deleted file mode 100644 index d1734eecb..000000000 --- a/apps/roster/priv/macbert/Spec/task_Spec.swift +++ /dev/null @@ -1,10 +0,0 @@ -func get_task() -> Model { - return Model(value:Tuple(name:"task",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/timeoutEvent_Spec.swift b/apps/roster/priv/macbert/Spec/timeoutEvent_Spec.swift deleted file mode 100644 index c4b03fdc2..000000000 --- a/apps/roster/priv/macbert/Spec/timeoutEvent_Spec.swift +++ /dev/null @@ -1,29 +0,0 @@ -func get_timeoutEvent() -> Model { - return Model(value:Tuple(name:"timeoutEvent",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Tuple(name:nil,body:[ - Model(value:Number()), - Model(value:Number()), - Model(value:Number())]))]))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Binary())]))]))} diff --git a/apps/roster/priv/macbert/Spec/tour_list_Spec.swift b/apps/roster/priv/macbert/Spec/tour_list_Spec.swift deleted file mode 100644 index 01c5825fe..000000000 --- a/apps/roster/priv/macbert/Spec/tour_list_Spec.swift +++ /dev/null @@ -1,3 +0,0 @@ -func get_tour_list() -> Model { - return Model(value:Tuple(name:"tour_list",body:[ - Model(value:List(constant:nil,model:get_join_application()))]))} diff --git a/apps/roster/priv/macbert/Spec/userTask_Spec.swift b/apps/roster/priv/macbert/Spec/userTask_Spec.swift deleted file mode 100644 index 2912b0912..000000000 --- a/apps/roster/priv/macbert/Spec/userTask_Spec.swift +++ /dev/null @@ -1,10 +0,0 @@ -func get_userTask() -> Model { - return Model(value:Tuple(name:"userTask",body:[ - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Atom())])), - Model(value:List(constant:nil, model:Model(value:Tuple()))), - Model(value:Binary())]))} diff --git a/apps/roster/priv/macbert/Spec/writer_Spec.swift b/apps/roster/priv/macbert/Spec/writer_Spec.swift deleted file mode 100644 index 2fb05c68a..000000000 --- a/apps/roster/priv/macbert/Spec/writer_Spec.swift +++ /dev/null @@ -1,11 +0,0 @@ -func get_writer() -> Model { - return Model(value:Tuple(name:"writer",body:[ - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Number()), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple())])), - Model(value:Chain(types:[Model(value:Tuple()),Model(value:Atom()),Model(value:Binary()),Model(value:Number()),Model(value:List(constant:""))])), - Model(value:Chain(types:[ - Model(value:List(constant:"")), - Model(value:Tuple())]))]))} diff --git a/apps/roster/priv/macbert/json-bert.js b/apps/roster/priv/macbert/json-bert.js index 078933c38..852877e51 100644 --- a/apps/roster/priv/macbert/json-bert.js +++ b/apps/roster/priv/macbert/json-bert.js @@ -62,7 +62,7 @@ function encreader(d) { var tup = atom('reader'); var id = 'id' in d && d.id ? encode(d.id) : nil(); var pos = 'pos' in d && d.pos ? number(d.pos) : nil(); - var cache = 'cache' in d && d.cache ? number(d.cache) : nil(); + var cache = 'cache' in d && d.cache ? encode(d.cache) : nil(); var args = 'args' in d && d.args ? encode(d.args) : nil(); var feed = 'feed' in d && d.feed ? encode(d.feed) : nil(); var dir = 'dir' in d && d.dir ? encode(d.dir) : nil(); @@ -73,7 +73,7 @@ function decreader(d) { var r={}; r.tup = 'reader'; r.id = d && d.v[1] ? decode(d.v[1]) : undefined; r.pos = d && d.v[2] ? d.v[2].v : undefined; - r.cache = d && d.v[3] ? d.v[3].v : undefined; + r.cache = d && d.v[3] ? decode(d.v[3]) : undefined; r.args = d && d.v[4] ? decode(d.v[4]) : undefined; r.feed = d && d.v[5] ? decode(d.v[5]) : undefined; r.dir = d && d.v[6] ? decode(d.v[6]) : undefined; @@ -818,7 +818,7 @@ function encFeature(d) { var tup = atom('Feature'); var id = 'id' in d && d.id ? bin(d.id) : nil(); var key = 'key' in d && d.key ? bin(d.key) : nil(); - var value = 'value' in d && d.value ? bin(d.value) : nil(); + var value = 'value' in d && d.value ? encode(d.value) : nil(); var group = 'group' in d && d.group ? bin(d.group) : nil(); return tuple(tup,id,key,value,group); } @@ -827,7 +827,7 @@ function decFeature(d) { var r={}; r.tup = 'Feature'; r.id = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; r.key = d && d.v[2] ? utf8_arr(d.v[2].v) : undefined; - r.value = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; + r.value = d && d.v[3] ? decode(d.v[3]) : undefined; r.group = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; return clean(r); } @@ -869,8 +869,8 @@ function encMember(d) { var avatar = 'avatar' in d && d.avatar ? bin(d.avatar) : nil(); var names = 'names' in d && d.names ? bin(d.names) : nil(); var surnames = 'surnames' in d && d.surnames ? bin(d.surnames) : nil(); - var alias = 'alias' in d && d.alias ? bin(d.alias) : nil(); - var reader = 'reader' in d && d.reader ? number(d.reader) : nil(); + var alias = 'alias' in d && d.alias ? encode(d.alias) : nil(); + var reader = 'reader' in d && d.reader ? encode(d.reader) : nil(); var update = 'update' in d && d.update ? number(d.update) : nil(); var settings = []; if ('settings' in d && d.settings) { d.settings.forEach(function(x){ @@ -901,8 +901,8 @@ function decMember(d) { r.avatar = d && d.v[8] ? utf8_arr(d.v[8].v) : undefined; r.names = d && d.v[9] ? utf8_arr(d.v[9].v) : undefined; r.surnames = d && d.v[10] ? utf8_arr(d.v[10].v) : undefined; - r.alias = d && d.v[11] ? utf8_arr(d.v[11].v) : undefined; - r.reader = d && d.v[12] ? d.v[12].v : undefined; + r.alias = d && d.v[11] ? decode(d.v[11]) : undefined; + r.reader = d && d.v[12] ? decode(d.v[12]) : undefined; r.update = d && d.v[13] ? d.v[13].v : undefined; r.settings = []; (d && d.v[14] && d.v[14].v) ? @@ -1295,10 +1295,7 @@ function encAuth(d) { { d.services.forEach(function(x){ services.push(encode(x))}); services={t:108,v:services}; } else { services = nil() }; - var settings = []; if ('settings' in d && d.settings) - { d.settings.forEach(function(x){ - settings.push(encode(x))}); - settings={t:108,v:settings}; } else { settings = nil() }; + var settings = 'settings' in d && d.settings ? encode(d.settings) : nil(); var push = 'push' in d && d.push ? bin(d.push) : nil(); var os = 'os' in d && d.os ? atom(d.os) : nil(); var created = 'created' in d && d.created ? number(d.created) : nil(); @@ -1314,17 +1311,14 @@ function decAuth(d) { r.user_id = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; r.phone = d && d.v[4] ? decode(d.v[4]) : undefined; r.token = d && d.v[5] ? utf8_arr(d.v[5].v) : undefined; - r.type = d && d.v[6] ? d.v[6].v : undefined; + r.type = d && d.v[6] ? decode(d.v[6]) : undefined; r.sms_code = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; r.attempts = d && d.v[8] ? d.v[8].v : undefined; r.services = []; (d && d.v[9] && d.v[9].v) ? d.v[9].v.forEach(function(x){r.services.push(decode(x))}) : r.services = undefined; - r.settings = []; - (d && d.v[10] && d.v[10].v) ? - d.v[10].v.forEach(function(x){r.settings.push(decode(x))}) : - r.settings = undefined; + r.settings = d && d.v[10] ? decode(d.v[10]) : undefined; r.push = d && d.v[11] ? utf8_arr(d.v[11].v) : undefined; r.os = d && d.v[12] ? decode(d.v[12]) : undefined; r.created = d && d.v[13] ? d.v[13].v : undefined; @@ -1338,18 +1332,9 @@ function encRoster(d) { var surnames = 'surnames' in d && d.surnames ? bin(d.surnames) : nil(); var email = 'email' in d && d.email ? bin(d.email) : nil(); var nick = 'nick' in d && d.nick ? bin(d.nick) : nil(); - var userlist = []; if ('userlist' in d && d.userlist) - { d.userlist.forEach(function(x){ - userlist.push(encode(x))}); - userlist={t:108,v:userlist}; } else { userlist = nil() }; - var roomlist = []; if ('roomlist' in d && d.roomlist) - { d.roomlist.forEach(function(x){ - roomlist.push(encode(x))}); - roomlist={t:108,v:roomlist}; } else { roomlist = nil() }; - var favorite = []; if ('favorite' in d && d.favorite) - { d.favorite.forEach(function(x){ - favorite.push(encode(x))}); - favorite={t:108,v:favorite}; } else { favorite = nil() }; + var userlist = 'userlist' in d && d.userlist ? encode(d.userlist) : nil(); + var roomlist = 'roomlist' in d && d.roomlist ? encode(d.roomlist) : nil(); + var favorite = 'favorite' in d && d.favorite ? encode(d.favorite) : nil(); var tags = []; if ('tags' in d && d.tags) { d.tags.forEach(function(x){ tags.push(encode(x))}); @@ -1369,18 +1354,9 @@ function decRoster(d) { r.surnames = d && d.v[3] ? utf8_arr(d.v[3].v) : undefined; r.email = d && d.v[4] ? utf8_arr(d.v[4].v) : undefined; r.nick = d && d.v[5] ? utf8_arr(d.v[5].v) : undefined; - r.userlist = []; - (d && d.v[6] && d.v[6].v) ? - d.v[6].v.forEach(function(x){r.userlist.push(decode(x))}) : - r.userlist = undefined; - r.roomlist = []; - (d && d.v[7] && d.v[7].v) ? - d.v[7].v.forEach(function(x){r.roomlist.push(decode(x))}) : - r.roomlist = undefined; - r.favorite = []; - (d && d.v[8] && d.v[8].v) ? - d.v[8].v.forEach(function(x){r.favorite.push(decode(x))}) : - r.favorite = undefined; + r.userlist = d && d.v[6] ? decode(d.v[6]) : undefined; + r.roomlist = d && d.v[7] ? decode(d.v[7]) : undefined; + r.favorite = d && d.v[8] ? decode(d.v[8]) : undefined; r.tags = []; (d && d.v[9] && d.v[9].v) ? d.v[9].v.forEach(function(x){r.tags.push(decode(x))}) : @@ -1594,14 +1570,14 @@ function decIndex(d) { function encWhitelist(d) { var tup = atom('Whitelist'); - var phone = 'phone' in d && d.phone ? bin(d.phone) : nil(); + var phone = 'phone' in d && d.phone ? encode(d.phone) : nil(); var created = 'created' in d && d.created ? number(d.created) : nil(); return tuple(tup,phone,created); } function lenWhitelist() { return 3; } function decWhitelist(d) { var r={}; r.tup = 'Whitelist'; - r.phone = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; + r.phone = d && d.v[1] ? decode(d.v[1]) : undefined; r.created = d && d.v[2] ? d.v[2].v : undefined; return clean(r); } @@ -1618,13 +1594,13 @@ function decerror(d) { function encok(d) { var tup = atom('ok'); - var code = 'code' in d && d.code ? bin(d.code) : nil(); + var code = 'code' in d && d.code ? atom(d.code) : nil(); return tuple(tup,code); } function lenok() { return 2; } function decok(d) { var r={}; r.tup = 'ok'; - r.code = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; + r.code = d && d.v[1] ? decode(d.v[1]) : undefined; return clean(r); } function encerror2(d) { @@ -1742,15 +1718,15 @@ function decPublishService(d) { function encFakeNumbers(d) { var tup = atom('FakeNumbers'); - var phone = 'phone' in d && d.phone ? bin(d.phone) : nil(); - var created = 'created' in d && d.created ? number(d.created) : nil(); + var phone = 'phone' in d && d.phone ? encode(d.phone) : nil(); + var created = 'created' in d && d.created ? encode(d.created) : nil(); return tuple(tup,phone,created); } function lenFakeNumbers() { return 3; } function decFakeNumbers(d) { var r={}; r.tup = 'FakeNumbers'; - r.phone = d && d.v[1] ? utf8_arr(d.v[1].v) : undefined; - r.created = d && d.v[2] ? d.v[2].v : undefined; + r.phone = d && d.v[1] ? decode(d.v[1]) : undefined; + r.created = d && d.v[2] ? decode(d.v[2]) : undefined; return clean(r); } function encDraft(d) { @@ -1797,19 +1773,21 @@ function dechandler(d) { function encpi(d) { var tup = atom('pi'); - var name = 'name' in d && d.name ? atom(d.name) : nil(); + var name = 'name' in d && d.name ? encode(d.name) : nil(); + var table = 'table' in d && d.table ? atom(d.table) : nil(); var sup = 'sup' in d && d.sup ? atom(d.sup) : nil(); var module = 'module' in d && d.module ? atom(d.module) : nil(); var state = 'state' in d && d.state ? encode(d.state) : nil(); - return tuple(tup,name,sup,module,state); } + return tuple(tup,name,table,sup,module,state); } -function lenpi() { return 5; } +function lenpi() { return 6; } function decpi(d) { var r={}; r.tup = 'pi'; - r.name = d && d.v[1] ? d.v[1].v : undefined; - r.sup = d && d.v[2] ? d.v[2].v : undefined; - r.module = d && d.v[3] ? d.v[3].v : undefined; - r.state = d && d.v[4] ? decode(d.v[4]) : undefined; + r.name = d && d.v[1] ? decode(d.v[1]) : undefined; + r.table = d && d.v[2] ? d.v[2].v : undefined; + r.sup = d && d.v[3] ? d.v[3].v : undefined; + r.module = d && d.v[4] ? d.v[4].v : undefined; + r.state = d && d.v[5] ? decode(d.v[5]) : undefined; return clean(r); } function enccx(d) { @@ -1828,10 +1806,7 @@ function enccx(d) { var path = 'path' in d && d.path ? bin(d.path) : nil(); var session = 'session' in d && d.session ? bin(d.session) : nil(); var formatter = 'formatter' in d && d.formatter ? atom(d.formatter) : nil(); - var params = []; if ('params' in d && d.params) - { d.params.forEach(function(x){ - params.push(encode(x))}); - params={t:108,v:params}; } else { params = nil() }; + var params = 'params' in d && d.params ? encode(d.params) : nil(); var node = 'node' in d && d.node ? atom(d.node) : nil(); var client_pid = 'client_pid' in d && d.client_pid ? encode(d.client_pid) : nil(); var state = 'state' in d && d.state ? encode(d.state) : nil(); @@ -1857,10 +1832,7 @@ function deccx(d) { r.path = d && d.v[6] ? utf8_arr(d.v[6].v) : undefined; r.session = d && d.v[7] ? utf8_arr(d.v[7].v) : undefined; r.formatter = d && d.v[8] ? decode(d.v[8]) : undefined; - r.params = []; - (d && d.v[9] && d.v[9].v) ? - d.v[9].v.forEach(function(x){r.params.push(decode(x))}) : - r.params = undefined; + r.params = d && d.v[9] ? decode(d.v[9]) : undefined; r.node = d && d.v[10] ? d.v[10].v : undefined; r.client_pid = d && d.v[11] ? decode(d.v[11]) : undefined; r.state = d && d.v[12] ? decode(d.v[12]) : undefined; @@ -2020,3 +1992,59 @@ function decftpack(d) { r.status = d && d.v[9] ? decode(d.v[9]) : undefined; return clean(r); } +function encschema(d) { + var tup = atom('schema'); + var tables = 'tables' in d && d.tables ? encode(d.tables) : nil(); + return tuple(tup,tables); } + +function lenschema() { return 2; } +function decschema(d) { + var r={}; r.tup = 'schema'; + r.tables = d && d.v[1] ? decode(d.v[1]) : undefined; + return clean(r); } + +function enctable(d) { + var tup = atom('table'); + var container = 'container' in d && d.container ? encode(d.container) : nil(); + var type = 'type' in d && d.type ? encode(d.type) : nil(); + var fields = 'fields' in d && d.fields ? encode(d.fields) : nil(); + var keys = 'keys' in d && d.keys ? encode(d.keys) : nil(); + return tuple(tup,container,type,fields,keys); } + +function lentable() { return 5; } +function dectable(d) { + var r={}; r.tup = 'table'; + r.container = d && d.v[1] ? decode(d.v[1]) : undefined; + r.type = d && d.v[2] ? decode(d.v[2]) : undefined; + r.fields = d && d.v[3] ? decode(d.v[3]) : undefined; + r.keys = d && d.v[4] ? decode(d.v[4]) : undefined; + return clean(r); } + +function enccolumn(d) { + var tup = atom('column'); + var key = 'key' in d && d.key ? encode(d.key) : nil(); + var ro = 'ro' in d && d.ro ? encode(d.ro) : nil(); + return tuple(tup,key,ro); } + +function lencolumn() { return 3; } +function deccolumn(d) { + var r={}; r.tup = 'column'; + r.key = d && d.v[1] ? decode(d.v[1]) : undefined; + r.ro = d && d.v[2] ? decode(d.v[2]) : undefined; + return clean(r); } + +function encquery(d) { + var tup = atom('query'); + var types = 'types' in d && d.types ? encode(d.types) : nil(); + var values = 'values' in d && d.values ? encode(d.values) : nil(); + var next_ph_num = 'next_ph_num' in d && d.next_ph_num ? encode(d.next_ph_num) : nil(); + return tuple(tup,types,values,next_ph_num); } + +function lenquery() { return 4; } +function decquery(d) { + var r={}; r.tup = 'query'; + r.types = d && d.v[1] ? decode(d.v[1]) : undefined; + r.values = d && d.v[2] ? decode(d.v[2]) : undefined; + r.next_ph_num = d && d.v[3] ? decode(d.v[3]) : undefined; + return clean(r); } + diff --git a/apps/roster/priv/macbert/main.swift b/apps/roster/priv/macbert/main.swift deleted file mode 100644 index 9dc998a13..000000000 --- a/apps/roster/priv/macbert/main.swift +++ /dev/null @@ -1,43 +0,0 @@ - -import Foundation - -/* func test3() { - let bin: [UInt8] = [131,104,11,100,0,6,82,111,115,116,101,114,97,63,109,0,0, - 0,5,65,110,116,111,110,109,0,0,0,1,77,97,1,108,0,0,0,1, - 104,7,100,0,7,67,111,110,116,97,99,116,109,0,0,0,15,51, - 56,48,57,57,52,51,56,50,55,57,56,95,54,51,106,106,106, - 106,106,106,106,100,0,4,116,114,117,101,109,0,0,0,12,51, - 56,48,57,57,52,51,56,50,55,57,56,109,0,0,0,25,104,116, - 116,112,58,47,47,97,118,97,116,97,114,46,99,111,109,47, - 97,118,97,46,112,110,103,100,0,5,112,97,116,99,104] - let data = NSData(bytes: bin, length: bin.count) - do { - let bert = try Bert.decode(data: data) - if let roster = get_Roster().parse(bert: bert) as? Roster { - print("parsed") - } - } catch { - print("I Can't parse Bin to Bert") - } - -} */ - - -//test3() - - -func testProfile() { - let bin: [UInt8] = [131, 104, 7, 100, 0, 7, 80, 114, 111, 102, 105, 108, 101, 109, 0, 0, 0, 12, 51, 56, 48, 54, 51, 50, 56, 56, 57, 56, 57, 48, 106, 109, 0, 0, 0, 14, 51, 56, 48, 54, 51, 50, 56, 56, 57, 56, 57, 48, 95, 52, 108, 0, 0, 0, 1, 104, 12, 100, 0, 6, 82, 111, 115, 116, 101, 114, 97, 4, 106, 106, 97, 1, 108, 0, 0, 0, 1, 104, 10, 100, 0, 7, 67, 111, 110, 116, 97, 99, 116, 109, 0, 0, 0, 14, 51, 56, 48, 54, 51, 50, 56, 56, 57, 56, 57, 48, 95, 52, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 100, 0, 4, 116, 114, 117, 101, 109, 0, 0, 0, 12, 51, 56, 48, 54, 51, 50, 56, 56, 57, 56, 57, 48, 106, 106, 106, 106, 106, 100, 0, 3, 103, 101, 116] - let data = NSData(bytes: bin, length: bin.count) - do { - let bert = try Bert.decode(data: data) - if let profile = get_Profile().parse(bert: bert) { - print("parsed") - } - } catch { - print("I Can't parse Bin to Bert") - } -} - -testProfile() - diff --git a/apps/roster/src/api/google_api.erl b/apps/roster/src/api/google_api.erl index a0f5d4591..f26708f8c 100644 --- a/apps/roster/src/api/google_api.erl +++ b/apps/roster/src/api/google_api.erl @@ -1,5 +1,5 @@ -module(google_api). - +-dialyzer({nowarn_function, gs_upload/3}). -compile(export_all). -include_lib("enenra/include/enenra.hrl"). @@ -61,10 +61,8 @@ start() -> case filelib:is_file(PathFile) of true -> os:putenv("GOOGLE_APPLICATION_CREDENTIALS", PathFile), - case enenra:load_credentials(os:getenv("GOOGLE_APPLICATION_CREDENTIALS")) of - {ok, Creds} -> application:set_env(roster, google_creds, Creds); - Err-> roster:error(?MODULE, "cannot load googlr creds: ~p", [Err]) - end; + {ok, Creds} = enenra:load_credentials(os:getenv("GOOGLE_APPLICATION_CREDENTIALS")), + application:set_env(roster, google_creds, Creds); _ -> roster:error(?MODULE, "google credential file ~p not found", PathFile) end, case ?GOOGLE_API_KEY of @@ -198,7 +196,7 @@ send_operation(LongRequest, OperationName, Counter, Timeout, Fun) -> <<>> -> {error, invalid_transcribe}; Text -> Text end); #{<<"name">> := OperationName} -> timer:apply_after(Timeout, ?MODULE, send_operation, [LongRequest, OperationName, Counter - 1, Timeout, Fun]); - #{} = R -> roster:error("invalid long operation ~p", [R]), + #{} -> roster:error("invalid long operation ~p", [R]), Fun({error, invalid_transcribe}) end; {error, _} = Err -> Fun(Err) @@ -241,7 +239,10 @@ gs_upload(FileIn, Bucket, ContentType) -> Size = filelib:file_size(FileOut), {ok, Md5} = enenra:compute_md5(FileOut), case enenra:upload_file(FileOut, - #object{name = Name, bucket = Bucket, contentType = ContentType, md5Hash = Md5, size = Size}, Creds) of + #object{name = Name, + bucket = Bucket, + contentType = ContentType, + md5Hash = Md5, size = Size}, Creds) of {ok, #object{}} -> roster:info(?MODULE, "object ~p is uploaded successfully", [GsUri = iolist_to_binary(["gs://",Bucket,"/",Name])]), [file:delete(filename:absname(File)) || File<-[FileIn2, FileOut]], diff --git a/apps/roster/src/micro.erl b/apps/roster/src/micro.erl index 04db6a13f..58a139dd5 100644 --- a/apps/roster/src/micro.erl +++ b/apps/roster/src/micro.erl @@ -33,9 +33,7 @@ uuid_to_id(Table, Acc) -> _ -> [] end; _ -> [] - end; -uuid_to_id(Table, ?IS_UUID = Acc) -> - uuid_to_id(Table, uuid:to_binary(binary_to_list(Acc))). + end. norm_uuid(<<_:128>> = Uuid) -> list_to_binary(uuid:to_string(Uuid)); norm_uuid(?IS_UUID = Uuid) -> Uuid. diff --git a/apps/roster/src/processes/job.erl b/apps/roster/src/processes/job.erl index c2c6497ce..49c339edd 100644 --- a/apps/roster/src/processes/job.erl +++ b/apps/roster/src/processes/job.erl @@ -49,14 +49,14 @@ action({request,'Action'}, #process{id=Id, options=Opts}=Proc) -> %job_process:get_proc(Id,pos), case bpe:doc(#'Schedule'{},Proc) of #'Schedule'{data = <<"stop">>} -> {reply,'Stop',Proc}; - #'Schedule'{id=Time, data = []} -> catch n2o_async:pid(system,roster_bpe) ! {next, Proc, Time}, + #'Schedule'{id=Time, data = []} -> catch n2o_pi:pid(system,roster_bpe) ! {next, Proc, Time}, {reply,'Stop',Proc}; #'Schedule'{id=Time}=Sh when Time/=[] -> Timeout=Time-roster:now_msec(), case Timeout-CTimeout of T when T =<3*?QUANT -> %io:format("Pub ~p, ~p ~n", [Id,Timeout]), - catch n2o_async:pid(system,roster_bpe) ! {publish, Proc}, + catch n2o_pi:pid(system,roster_bpe) ! {publish, Proc}, {reply,'Stop',Proc}; - T -> catch n2o_async:pid(system,roster_bpe) ! {timeout, Sh, Timeout}, + T -> catch n2o_pi:pid(system,roster_bpe) ! {timeout, Sh, Timeout}, {reply,'Timeout',Proc} end; _ -> {reply,'Stop',Proc} end; @@ -64,24 +64,23 @@ action({request,'Action'}, #process{id=Id, options=Opts}=Proc) -> action({request,'Final'}, #process{id=Id, options=Opt}=Proc) -> io:format(" Final~n"), %roster:send_event(C, <<>>, <<>>, #'Job'{id=Id, status=delete}), - %n2o_async:pid(system,roster_bpe) ! #'Job'{id=Id, status=delete}, - n2o_async:pid(system,roster_bpe) ! {clean, Proc#process{}}, + %n2o_pi:pid(system,roster_bpe) ! #'Job'{id=Id, status=delete}, + n2o_pi:pid(system,roster_bpe) ! {clean, Proc#process{}}, {reply,Proc}. worker(#process{id=Id}=P) -> - case kvs:get(feed,process) of - {ok,Feed} when Feed#feed.top =:= Id -> - case bpe:hist(Id) of - [H|_] ->%kvs:info(?MODULE,"Worker Start: ~p~n",[Id]), - worker_do(calendar:time_difference(H#hist.time,calendar:local_time()),P); - __ -> skip end; - __ -> skip end - . + try + {ok, #feed{top = Id }} = kvs:get(feed,process), + #hist{time = HistTime} = hd(bpe:hist(Id)), + worker_do(calendar:time_difference(HistTime,calendar:local_time()),P) + catch + _-> skip + end. worker_do({Days,Time},P) when Days >= 14 -> skip; worker_do({Days,Time},#process{id=Id}=P) when P#process.task =:= 'Action' -> -% catch n2o_async:pid(system,roster_bpe) ! {restart, P}, +% catch n2o_pi:pid(system,roster_bpe) ! {restart, P}, bpe:start(P, []), %bpe:complite(Id), kvs:info(?MODULE,"BPE Start: ~p~n",[Id]); @@ -126,7 +125,9 @@ next(R,Current) -> clear_schedule()-> [kvs:delete('Schedule', Time) || #'Schedule'{id=Time} <- kvs:all('Schedule'), Time < roster:now_msec()]. -clear_hist(#process{id=Id}=P)-> case bpe:hist(Id) of - [H|T] -> [kvs:remove(hist,Id) || #'hist'{id=Id} <- T]; - __ -> skip end. - +clear_hist(#process{id=Id}=P)-> + try + [kvs:remove(hist,Id) || #'hist'{id=Id} <- tl(bpe:hist(Id))] + catch + _-> skip + end. \ No newline at end of file diff --git a/apps/roster/src/processes/job_process.erl b/apps/roster/src/processes/job_process.erl index 4662dec78..1bd0da741 100644 --- a/apps/roster/src/processes/job_process.erl +++ b/apps/roster/src/processes/job_process.erl @@ -1,7 +1,7 @@ -module(job_process). -include("roster.hrl"). -compile(export_all). - +-dialyzer({nowarn_function, [definition/0,definition/1]}). definition() -> #process { name = 'Schedule', diff --git a/apps/roster/src/protocol/micro_auth.erl b/apps/roster/src/protocol/micro_auth.erl index e8c0d08fa..a2be0ab02 100644 --- a/apps/roster/src/protocol/micro_auth.erl +++ b/apps/roster/src/protocol/micro_auth.erl @@ -9,7 +9,7 @@ -compile(export_all). start() -> - n2o_async:start(#handler{module = micro_auth, class = system, group = roster, name = micro_auth, state = []}). + n2o_pi:start(#pi{module = micro_auth, table = system, sup = roster, name = micro_auth, state = []}). init([Listeners]) -> {ok, Listeners}. description() -> "Micro Authentication Module". @@ -31,7 +31,7 @@ check(#mqtt_client{client_id = <<"emqttd_", _/binary>> = ClientId, username = << {ok, AccUuid} -> emqttd_client:subscribe(ClientPid, [{roster:action_topic(ClientId), 2}]), PhoneId = micro:uuid_to_id('LinkRoster', AccUuid), - AuthPid = n2o_async:pid(system, ?MODULE), + AuthPid = n2o_pi:pid(system, ?MODULE), Ver = binary_to_list(BVer), case kvs:get('Auth', ClientId) of {ok, #'Auth'{user_id = PhoneId} = Auth} -> @@ -59,7 +59,7 @@ check(#mqtt_client{client_id = <<"emqttd_", _/binary>> = ClientId, username = << end; _ -> {error, invalid_version} end; -check(#mqtt_client{client_id = <<"emqttd_", _/binary>> = ClientId, username = Username}, _, State) when Username /= <<"api">>, Username /= <<"micro">> -> +check(#mqtt_client{client_id = <<"emqttd_", _/binary>> = ClientId, username = Username}, _, _State) when Username /= <<"api">>, Username /= <<"micro">> -> roster:info(?MODULE, "~p:Auth:auth(micro)/check:invalid_username: ~p", [ClientId, Username]), {error, invalid_username}; check(_Client, _Password, _Opts) -> ignore. @@ -76,16 +76,16 @@ info(#'Auth'{type = update, client_id = <<"emqttd_", _/binary>> = ClientId, toke {error, _} -> #io{code = #error{code = session_not_found}, data = ClientId} end, {reply, {bert, IO}, Req, State}; -info(#'Auth'{type = clear, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, _Req, #cx{client_pid = C} = State) -> - Reply = {reply, {bert, IO}, _, _} = roster_auth:info(Auth, State#cx{params = ClientId}), +info(#'Auth'{type = clear, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, Req, #cx{client_pid = C} = State) -> + Reply = {reply, {bert, IO}, _, _} = roster_auth:info(Auth, Req, State#cx{params = ClientId}), roster:send_action(C, ClientId, IO), Reply; -info(#'Auth'{type = delete, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, _Req, #cx{client_pid = C} = State) -> - Reply = {reply, {bert, IO}, _, _} = roster_auth:info(Auth, State#cx{params = ClientId}), +info(#'Auth'{type = delete, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, Req, #cx{client_pid = C} = State) -> + Reply = {reply, {bert, IO}, _, _} = roster_auth:info(Auth, Req, State#cx{params = ClientId}), roster:send_action(C, ClientId, IO), Reply; info(#'Auth'{type = logout, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, Req, #cx{params = SysClientId, client_pid = C} = State) -> IO = case kvs:get('Auth', ClientId) of {ok, #'Auth'{} = StoredAuth} -> - roster_presence:on_disconnect(A = StoredAuth#'Auth'{type = logout}, C), + roster_presence:on_disconnect(StoredAuth#'Auth'{type = logout}, C), roster:send_action(C, SysClientId, Auth), %%TODO send uuid phone and roster_id to micro? <<>>; {error, _} -> #io{code = #error{code = session_not_found}} @@ -98,31 +98,31 @@ info(#'Auth'{phone = Phone} = Auth, Req, #cx{params = ClientId} = State) -> {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. %% micro_auth handlers -proc(init, #handler{name = micro_auth} = Async) -> +proc(init, #pi{name = micro_auth} = Async) -> {ok, C} = emqttc:start_link([{client_id, <<"micro_auth">>}, {logger, {console, error}}, {reconnect, 5}]), roster:info(?MODULE, "ASYNC AUTH PROC started", []), - {ok, Async#handler{state = C, seq = 0}}; + {ok, Async#pi{state = C}}; proc(#'Auth'{type = {ver, Ver}, phone = Phone, client_id = <<"emqttd_", _/binary>> = ClientId}, - #handler{state = C} = H) -> + #pi{state = C} = H) -> roster:info(?MODULE, "~p:~p:Auth(micro)/login", [Phone, ClientId]), catch roster_presence:on_connect(Phone, ClientId, C, Ver), %%TODO send Auth updated session? {reply, [], H}; proc({disconnect, #'Auth'{client_id = <<"emqttd_", _/binary>>} = Auth}, - #handler{state = C} = H) -> roster_presence:on_disconnect(Auth, C), + #pi{state = C} = H) -> roster_presence:on_disconnect(Auth, C), {reply, [], H}; -proc(#'Auth'{type = {reg, Ver}, client_id = <<"emqttd_", _/binary>> = ClientId, phone = Phone, user_id = UserId} = Stored, - #handler{state = C} = H) -> +proc(#'Auth'{type = {reg, Ver}, client_id = <<"emqttd_", _/binary>> = ClientId, phone = Phone, user_id = UserId}, + #pi{state = C} = H) -> roster:info(?MODULE, "~p:~p:Auth(micro)/login(created session)", [Phone, ClientId]), roster_presence:on_verify(ClientId, UserId), roster_presence:on_connect(Phone, ClientId, C, Ver), {reply, [], H}; -proc({mqttc, C, connected}, State = #handler{state = C, seq = S}) -> {ok, State#handler{seq = S + 1}}; +proc({mqttc, C, connected}, State = #pi{state = C}) -> {ok, State}; proc({mqttc, _C, disconnected}, State) -> {ok, State}; -proc(Unknown, #handler{} = H) -> +proc(Unknown, #pi{} = H) -> roster:info(?MODULE, "invalid auth data :~p", [Unknown]), {reply, [], H}. diff --git a/apps/roster/src/protocol/micro_roster.erl b/apps/roster/src/protocol/micro_roster.erl index b6ec49ca9..2e9baef77 100644 --- a/apps/roster/src/protocol/micro_roster.erl +++ b/apps/roster/src/protocol/micro_roster.erl @@ -4,7 +4,7 @@ -include_lib("n2o/include/n2o.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Roster'{status = add, phone = LinkPhone, id = LinkRosterId} = Roster, Req, #cx{params = <<"sys_", _/binary>> = ClientId} = State) -> diff --git a/apps/roster/src/protocol/roster_acl.erl b/apps/roster/src/protocol/roster_acl.erl index 570bea6ef..6078c0982 100644 --- a/apps/roster/src/protocol/roster_acl.erl +++ b/apps/roster/src/protocol/roster_acl.erl @@ -11,6 +11,7 @@ -export([init/1, check_acl/2, reload_acl/1, reload_acl/0, description/0]). -define(ACL_RULE_TAB, roster_acl_rule). +-dialyzer({nowarn_function, description/0}). -record(state, {config, nomatch = deny, vnodes = []}). %%-------------------------------------------------------------------- @@ -72,13 +73,13 @@ check_acl({#mqtt_client{client_id = <<"emqttd_", _/binary>> = Client}, publish, allow; check_acl({#mqtt_client{client_id = <<"emqttd_", _/binary>>}, publish, <<"auth/", _/binary>>}, #state{}) -> deny; -check_acl({#mqtt_client{client_id = <<"emqttd_", _/binary>> = Client}, publish, <<"events/", _/binary>>} = Who, #state{}) -> +check_acl({#mqtt_client{client_id = <<"emqttd_", _/binary>> = Client}, publish, <<"events/", _/binary>>} = _Who, #state{}) -> case kvs:get('Auth', Client) of {ok, #'Auth'{type = expired}} -> deny; {ok, _} -> allow; {error, _} -> deny end; -check_acl({Client, PubSub, Topic} = Who, #state{nomatch = Default}) -> +check_acl({Client, PubSub, Topic} = _Who, #state{nomatch = Default}) -> case match(Client, Topic, lookup(PubSub)) of {matched, allow} -> allow; {matched, deny} -> deny; diff --git a/apps/roster/src/protocol/roster_auth.erl b/apps/roster/src/protocol/roster_auth.erl index ea7d594ba..b2b33297f 100644 --- a/apps/roster/src/protocol/roster_auth.erl +++ b/apps/roster/src/protocol/roster_auth.erl @@ -16,9 +16,9 @@ -define(CHECK_FAKE_NUMBERS, application:get_env(roster, fake_numbers_check, false)). start() -> - n2o_async:start(#handler{module = roster_auth, class = system, group = roster, name = roster_auth, state = []}). + n2o_pi:start(#pi{module = roster_auth, table = system, sup = roster, name = roster_auth, state = []}). stop() -> - n2o_async:stop(system, roster_auth). + n2o_pi:stop(system, roster_auth). init([Listeners]) -> {ok, Listeners}. description() -> "Roster Authentication Module". @@ -188,8 +188,7 @@ info(#'Auth'{type = verify, phone = Phone, dev_key = DevKey, settings = Settings PhoneId = roster:phone_id(Phone, Roster), NewSettings = [F#'Feature'{id = <>} || #'Feature'{key = Key} = F <-Settings], - kvs:put(P = #'Profile'{phone = Phone, rosters = [Roster], - settings = NewSettings, update = roster:now_msec()}), + kvs:put(P = #'Profile'{phone = Phone, rosters = [Roster], settings = NewSettings, update = roster:now_msec()}), % roster:n2o_pid(?MODULE) ! {vox, P, client(RegClientId)}, {roster, Roster} end, UserId = roster:phone_id(Phone, RosterId), ClientId = client(RegClientId), @@ -273,17 +272,17 @@ info(#'Auth'{phone = Phone} = Auth, Req, #cx{params = ClientId} = State) -> {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. %% roster_auth handlers -proc(init, #handler{name = roster_auth} = Async) -> +proc(init, #pi{name = roster_auth} = Async) -> {ok, C} = emqttc:start_link([{client_id, <<"roster_auth">>}, {logger, {console, error}}, {reconnect, 5}]), _ = (catch locus:start_loader(city, application:get_env(locus, url, ?GEO_URL))), case catch locus:wait_for_loader(city, 10000) of {ok, _} -> ok; Err -> roster:error(?MODULE, "error:~p:locus", [Err]) end, roster:info(?MODULE, "ASYNC AUTH PROC:~p started", [C]), - {ok, Async#handler{state = C, seq = 0}}; + {ok, Async#pi{state = C}}; -%%proc(#'Auth'{type = verified, client_id = <<"emqttd_", Post/binary>> = ClientId, user_id = UserId} = Stored, #handler{} = H) -> +%%proc(#'Auth'{type = verified, client_id = <<"emqttd_", Post/binary>> = ClientId, user_id = UserId} = Stored, #pi{} = H) -> %% proc(Stored#'Auth'{type = {reg,?VERSION}}, H); -proc(#'Auth'{type = {reg,Ver}, client_id = <<"emqttd_", Post/binary>> = ClientId, user_id = UserId} = Stored, #handler{} = H) -> +proc(#'Auth'{type = {reg,Ver}, client_id = <<"emqttd_", Post/binary>> = ClientId, user_id = UserId} = Stored, #pi{} = H) -> Reply = proc(Stored#'Auth'{type = {ver,Ver}}, H), RegClientId = <<"reg_", Post/binary>>, n2o_vnode:unsubscribe(RegClientId, roster:action_topic(RegClientId)), @@ -292,24 +291,24 @@ proc(#'Auth'{type = {reg,Ver}, client_id = <<"emqttd_", Post/binary>> = ClientId %%proc(#'Auth'{type = [], token = Token, phone = Phone, client_id = <<"emqttd_", _/binary>> = ClientId}=Auth,H)-> %% proc(Auth#'Auth'{type = {ver,?VERSION}}, H); proc(#'Auth'{type = {ver,Ver}, token = Token, phone = Phone, client_id = <<"emqttd_", _/binary>> = ClientId}, - #handler{state = C} = H) -> + #pi{state = C} = H) -> NewC=roster:restart_module(C,roster_auth), roster:info(?MODULE, "~p:~p:Auth/login:~p", [Phone, ClientId, binary:part(Token, 0, 16)]), catch roster_presence:on_connect(Phone, ClientId, NewC, Ver), - {reply, [], H#handler{state = NewC}}; -proc(#'Auth'{type = update, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, #handler{state = C} = H) -> + {reply, [], H#pi{state = NewC}}; +proc(#'Auth'{type = update, client_id = <<"emqttd_", _/binary>> = ClientId} = Auth, #pi{state = C} = H) -> {ok, #'Auth'{token = T}} = kvs:get('Auth', ClientId), %NewC=roster:restart_module(C,roster_auth), {'Token', Token2} = roster:gen_token([], binary:part(T, 0, 10)), roster:info(?MODULE, "~p:Auth/update:~p", [ClientId, binary:part(Token2, 0, 16)]), catch n2o_vnode:send(C, roster:action_topic(ClientId), term_to_binary(Auth#'Auth'{token = Token2}), [{qos, 0}]), - {reply, [], H#handler{state = C}}; -proc({disconnect, #'Auth'{client_id = <<"emqttd_", _/binary>>} = Auth}, #handler{state = C} = H) -> + {reply, [], H#pi{state = C}}; +proc({disconnect, #'Auth'{client_id = <<"emqttd_", _/binary>>} = Auth}, #pi{state = C} = H) -> % NewC=roster:restart_client(C,<<"roster_auth">>), % spawn(roster, client_pid, [C,<<"roster_auth">>]), catch roster_presence:on_disconnect(Auth, C), - {reply, [], H#handler{state = C}}; -proc({vox, #'Profile'{phone = Phone, services = Services} = Profile, Cli}, #handler{state = C} = H) -> + {reply, [], H#pi{state = C}}; +proc({vox, #'Profile'{phone = Phone, services = Services} = Profile, Cli}, #pi{state = C} = H) -> {VoxStatus, VoxResponse} = vox_api:create_voximplant_user(Phone), Service = case VoxStatus of ok -> {VoxResponse1} = VoxResponse, @@ -323,7 +322,7 @@ proc({vox, #'Profile'{phone = Phone, services = Services} = Profile, Cli}, #hand Profile2#'Profile'{presence = online, rosters = lists:map(fun roster:roster/1, Rosters)}) end, {reply, [], H}; -proc({sms, Phone, SmsCode}, #handler{} = H) -> +proc({sms, Phone, SmsCode}, #pi{} = H) -> roster:info(?MODULE, "~p:sms:~p", [Phone, SmsCode]), Half = size(SmsCode) - round(size(SmsCode) / 2), [Codes1, Codes2] = [binary:part(SmsCode, S, Half) || S <- [0, Half]], @@ -331,14 +330,14 @@ proc({sms, Phone, SmsCode}, #handler{} = H) -> spawn(fun () -> telesign_api:send_sms(Phone, ClientSms, fun(_) -> ok end) end), {reply, [], H}; -proc({voice, Phone, SmsCode, Lang}, #handler{} = H) -> +proc({voice, Phone, SmsCode, Lang}, #pi{} = H) -> roster:info(?MODULE, "~p:telesign:~p:~p", [Phone, SmsCode, Lang]), % telesign_api:telesign_voice_call(Phone, SmsCode, [], Lang), {reply, [], H}; -proc({mqttc, C, connected}, State = #handler{state = C, seq = S}) -> {ok, State#handler{seq = S + 1}}; +proc({mqttc, C, connected}, State = #pi{state = C}) -> {ok, State}; proc({mqttc, _C, disconnected}, State) -> {ok, State}; -proc(Unknown, #handler{} = H) -> +proc(Unknown, #pi{} = H) -> roster:info(?MODULE, "invalid auth data :~p", [Unknown]), {reply, [], H}. diff --git a/apps/roster/src/protocol/roster_bpe.erl b/apps/roster/src/protocol/roster_bpe.erl index 2e105a5bc..1d3ae5f65 100644 --- a/apps/roster/src/protocol/roster_bpe.erl +++ b/apps/roster/src/protocol/roster_bpe.erl @@ -12,7 +12,7 @@ -define(JOBS_MS_LIMIT, 500). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'History'{roster_id = Roster, feed = Feed, size = N, entity_id = MId, status = get} = Data, Req, #cx{params = ClientId} = State) -> @@ -31,7 +31,7 @@ info(#'History'{roster_id = Roster, feed = Feed, size = N, entity_id = MId, stat {ok, #reader{cache = []} = Rdr} when MId == 0 -> #writer{count = Count, cache = #'Job'{id = Id}} = Writer, case Count of - 0 -> n2o:error(?MODULE, "There are not messages: ~p:~n", [Writer]), {[], 0}, <<>>; + 0 -> roster:error(?MODULE, "There are not messages: ~p:~n", [Writer]), {[], 0}, <<>>; _ -> #reader{cache = {_, RId}} = kvs_stream:save(kvs_stream:top((Rdr#reader{dir = 0}))), %{ok,#'Job'{prev = ID }}=kvs:get('Job',RId), Js = roster:exclude({'Job', RId}, #'Job'.status, -?JOBS_LIMIT, 0, []), @@ -72,7 +72,7 @@ info(#'Job'{id = [], feed_id = {act, <<"publish">>, PhoneId} = Feed, time = [], %J = J0#'Job'{id = Id = kvs:next_id('Job', 1)}, Replay = case roster:phone_id(ClientId) of PhoneId -> %roster:restart_module(Pid,?MODULE), - n2o_async:pid(system, ?MODULE) ! {send, Msgs}, <<>>; + n2o_pi:pid(system, ?MODULE) ! {send, Msgs}, <<>>; _ -> roster_channel_helper:error_response_400(RequestData) %% #io{code = #error{code = invalid_data}} end, @@ -108,7 +108,7 @@ info(#'Job'{id = [], feed_id = {act, <<"publish">>, PhoneId} = Feed, time = Time {J0#'Job'{time = round(Time / ?QUANT) * ?QUANT, context = NewR}, {0, 0}}; _ -> {J0#'Job'{time = round(Time / ?QUANT) * ?QUANT}, {0, 0}} end, - catch n2o_async:pid(system, ?MODULE) ! {update, J#'Job'{container = chain, data = D, status = pending}, Context, S}, + catch n2o_pi:pid(system, ?MODULE) ! {update, J#'Job'{container = chain, data = D, status = pending}, Context, S}, <<>>; _ -> roster_channel_helper:error_response_400(J0) %% #io{code = #error{code = invalid_data}} @@ -132,11 +132,11 @@ info(#'Job'{id = Id, time = T0, feed_id = {act, <<"publish">>, PhoneId} = Feed, {ok, #'Schedule'{id = SID, data = Data} = Sh} when abs(Time - OldTime) > 2 * ?QUANT, NData /= 0 -> case Data--[{'Job', Id}] of [] -> kvs:delete('Schedule', SID); ND -> kvs:put(Sh#'Schedule'{data = ND}) end, - n2o_async:pid(system, ?MODULE) ! {update, NewJ, {OldTime, 0}, S}, <<>>; + n2o_pi:pid(system, ?MODULE) ! {update, NewJ, {OldTime, 0}, S}, <<>>; {ok, #'Schedule'{}} when NData /= 0 -> kvs:put(NewJ), roster:send_ses(C, roster:phone(PhoneId), NewJ#'Job'{status = update}), <<>>; - _ when NData /= 0 -> n2o_async:pid(system, ?MODULE) ! {update, NewJ, {OldTime, 0}, S}, + _ when NData /= 0 -> n2o_pi:pid(system, ?MODULE) ! {update, NewJ, {OldTime, 0}, S}, <<>>; __________ -> roster_channel_helper:error_response_400(RequestData) %% #io{code = #error{code = invalid_data}} @@ -191,7 +191,7 @@ info(#'Job'{feed_id = Feed} = RequestData, R, S) -> info(M, R, S) -> roster:info(?MODULE, "UNKNOWN:~w", [M]), {unknown, M, R, S}. -proc(init, #handler{name = roster_bpe} = Async) -> +proc(init, #pi{name = roster_bpe} = Async) -> {ok, C} = emqttc:start_link([{client_id, <<"sys_bpe">>}, {logger, {console, error}}, {reconnect, 5}]), Table = process, Proc = case kvs:get(feed, Table) of @@ -221,10 +221,10 @@ proc(init, #handler{name = roster_bpe} = Async) -> % bpe:amend(Proc,{send_pid, C},noflow), roster:info(?MODULE, "ASYNC BPE started: ~p; ~p", [C, Proc]), % Proc is transfered through state - {ok, Async#handler{state = {C, Proc}, seq = 0}}; + {ok, Async#pi{state = {C, Proc}}}; proc({update, #'Job'{id = Id0, time = Time, feed_id = {act, <<"publish">>, PhoneId} = Feed, data = D} = J, {OldTime, Limit}, - #cx{params = ClientId} = CX}, #handler{state = {C, Proc}} = H) when Limit < 8 -> + #cx{params = ClientId} = CX}, #pi{state = {C, Proc}} = H) when Limit < 8 -> roster:restart_module(C,roster_bpe), P = bpe:load(Proc), {NewJ0, Id} = case Id0 of [] -> NId = kvs:next_id('Job', 1), {J#'Job'{id = NId, proc = Proc}, NId}; _ -> @@ -267,24 +267,24 @@ proc({update, #'Job'{id = Id0, time = Time, feed_id = {act, <<"publish">>, Phone case NewD of [] -> roster:send_ses(C, roster:phone(PhoneId), case OldTime of 0 -> NewJ; _ -> NewJ#'Job'{status = update} end), - {reply, [], H#handler{state = {C, Proc}}}; + {reply, [], H#pi{state = {C, Proc}}}; _ -> try amend(Proc, NewSh = #'Schedule'{id = T, proc = Proc, data = NewD}, Par), roster:send_ses(C, roster:phone(PhoneId), case OldTime of 0 -> NewJ; _ -> NewJ#'Job'{status = update} end), - {reply, [], H#handler{state = {C, Proc}}} - catch Err:Rea -> n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]), + {reply, [], H#pi{state = {C, Proc}}} + catch Err:Rea -> roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]), restart_bpe(P, C), timer:sleep(300), bpe:complete(Proc), - proc({update, NewJ0, {OldTime, Limit + 1}, CX}, #handler{state = {C, Proc}, seq = S} = H) + proc({update, NewJ0, {OldTime, Limit + 1}, CX}, #pi{state = {C, Proc}} = H) end end; proc({update, #'Job'{id = Id0, time = Time, feed_id = {act, <<"publish">>, PhoneId} = Feed, data = D} = J, {OldTime, Limit}, - #cx{params = ClientId} = S}, #handler{state = {C, Proc}} = H) -> + #cx{params = ClientId} = S}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE update limit ~p; ~p", [C, Proc]), {reply, [], H}; -proc({publish, #process{id = Id} = P}, #handler{state = {C, Proc}, seq = S} = H) -> +proc({publish, #process{id = Id} = P}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC publish: ~p", [Id]), roster:restart_module(C,roster_bpe), %#act{data=Jobs}=bpe:doc(#act{},Proc), @@ -307,65 +307,65 @@ proc({publish, #process{id = Id} = P}, #handler{state = {C, Proc}, seq = S} = H) #'Schedule'{id = Current} -> Current; _ -> roster:now_msec() end, job:clear_hist(P), - proc({next, P, Curr}, #handler{state = {C, Proc}, seq = S} = H); + proc({next, P, Curr}, #pi{state = {C, Proc}} = H); -proc({next, #process{id = Id} = P, Current}, #handler{state = {C, Proc}, seq = S} = H) -> +proc({next, #process{id = Id} = P, Current}, #pi{state = {C, Proc}} = H) -> %roster:info(?MODULE, "BPE PROC next: ~p", [P]), FirstS = try mnesia:dirty_first('Schedule') of '$end_of_table' -> Current; Key -> Key catch _ -> Current end, Stop = #'Schedule'{id = roster:now_msec(), data = <<"stop">>}, Docs = case job:next('Schedule', Current) of - [] -> [Stop]; + [] -> Stop; % kvs:put(Stop); - Doc when FirstS =:= Current -> [Doc]; + Doc when FirstS =:= Current -> Doc; _ -> case kvs:get('Schedule', FirstS) of - {ok, #'Schedule'{} = Doc} -> [Doc]; - _ -> [Stop] + {ok, #'Schedule'{} = Doc} -> Doc; + _ -> Stop end end, - try bpe:amend(Id, Docs) catch Err:Rea -> n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]) end, + try bpe:amend(Id, Docs) catch Err:Rea -> roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, kvs:delete('Schedule', Current), {reply, [], H}; -proc({restart, #'process'{id = Id} = P}, #handler{state = {C, Proc}, seq = S} = H) -> +proc({restart, #'process'{id = Id} = P}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC restarted", []), % P1=job_process:update_event(P, 'Action', {0, {0, 0, 1}}), Proc = restart_bpe(P, C), bpe:complete(Proc), - {reply, [], #handler{state = {C, Proc}} = H}; + {reply, [], #pi{state = {C, Proc}} = H}; -proc({timeout, #'Schedule'{id = Current} = Sh, T}, #handler{state = {C, Proc}} = H) -> +proc({timeout, #'Schedule'{id = Current} = Sh, T}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC Timeout: ~p", [T]), %{value,#boundaryEvent{timeout = BT},_}=lists:keytake('*',#boundaryEvent.name,bpe:events(P)), %{ok, TRef} = timer:apply_after(T, bpe, complete, [Proc]), {ok, TRef} = timer:apply_after(T, roster_bpe, publish, [Proc]), try bpe:amend(Proc, Sh#'Schedule'{state = TRef}, noflow) catch Err:Rea -> - n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]) end, kvs:put(Sh#'Schedule'{state = TRef}), + rosetr:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, kvs:put(Sh#'Schedule'{state = TRef}), %job_process:update_opt(bpe:load(Proc),{timer,TRef}), {reply, [], H}; -proc({clean, #'process'{id = Id} = P}, #handler{state = {C, Proc}} = H) -> +proc({clean, #'process'{id = Id} = P}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC clean", []), bpe:complete(Id), {value, #boundaryEvent{timeout = BT}, _} = lists:keytake('*', #boundaryEvent.name, bpe:events(P)), %bpe:find_pid(Id) ! {'DOWN', <<>>, <<>>, <<>>, <<>>}, - timer:apply_after(roster:daystimeToms(BT) + 5000, bpe, cleanup, [Id]), + timer:apply_after(roster:daystime_to_ms(BT) + 5000, bpe, cleanup, [Id]), {reply, [], H}; -proc({send, Msgs}, #handler{state = {C, Proc}} = H) -> +proc({send, Msgs}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC send", []), roster:restart_module(C,roster_bpe), -% [case kvs:get(mqtt_session, roster:get_vnode(Msg)) of {ok,#mqtt_session{sess_pid = Pid}} -> n2o_async:send(Pid,{publish, , Msg}); _ -> skip end || Msg = #'Message'{} <- Msgs], +% [case kvs:get(mqtt_session, roster:get_vnode(Msg)) of {ok,#mqtt_session{sess_pid = Pid}} -> n2o_pi:send(Pid,{publish, , Msg}); _ -> skip end || Msg = #'Message'{} <- Msgs], [begin roster:send_event(C, <<"sys_bpe">>, <<>>, Msg, roster:get_vnode(<<"sys_bpe">>,Msg)),timer:sleep(5) end || Msg = #'Message'{} <- Msgs], - {reply, [], H#handler{state = {C, Proc}}}; + {reply, [], H#pi{state = {C, Proc}}}; -proc({mqttc, C, connected}, State = #handler{state = {C, Proc}, seq = S}) -> {ok, State#handler{seq = S + 1}}; +proc({mqttc, C, connected}, State = #pi{state = {C, Proc}}) -> {ok, State}; proc({mqttc, _C, disconnected}, State) -> {ok, State}. -publish(Proc) -> n2o_async:pid(system, ?MODULE) ! {publish, bpe:load(Proc)}. +publish(Proc) -> n2o_pi:pid(system, ?MODULE) ! {publish, bpe:load(Proc)}. restart_bpe(#process{id = Id} = P, _C) -> try case bpe:find_pid(Id) of @@ -399,4 +399,4 @@ set_schedule(_, Time, #'Job'{id = Id, proc = Proc, time = T0} = J) -> action(#'History'{status=update}=Term,R,S)-> - roster_history:info(Term, R, S). \ No newline at end of file + roster_history:info(Term, R, S). diff --git a/apps/roster/src/protocol/roster_friend.erl b/apps/roster/src/protocol/roster_friend.erl index 60623787c..aebe15a75 100644 --- a/apps/roster/src/protocol/roster_friend.erl +++ b/apps/roster/src/protocol/roster_friend.erl @@ -5,7 +5,7 @@ -include_lib("kvs/include/kvs.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Friend'{phone_id = Me, friend_id = Friend, status = request}, {Req, handled}, #cx{params = ClientId, client_pid = C} = State) -> @@ -14,7 +14,7 @@ info(#'Friend'{phone_id = Me, friend_id = Friend, status = request}, {Req, handl [{ok, FromR}, {ok, ToR}] = [kvs:get('Roster', Id) || Id <- [FromId, ToId]], D = case {roster:get_contact(FromR, Friend), roster:get_contact(ToR, Me)} of {#'Contact'{status = S1}, #'Contact'{status = S2}} when S1 =/= [];S2 =/= [] -> - #io{code = invalid_data}; + #io{code = #error{code = invalid_data}}; _ -> [Mc] = roster:to_contact([FromR], authorization), [Fc] = roster:to_contact([ToR], request), @@ -25,7 +25,7 @@ info(#'Friend'{phone_id = Me, friend_id = Friend, status = request}, {Req, handl _Remote = roster:add_contacts(FromR, [Friendc]), roster:send_ses(C, To, roster:presence(#'Contact'{reader = Rs} = roster:readmsgs(Mec, Friend))), roster:send_ses(C, From, roster:presence(Friendc#'Contact'{reader = lists:reverse(Rs)})), - n2o_async:pid(system, ?MODULE) ! {send_push, Me, Friend, <<"request">>}, + n2o_pi:pid(system, ?MODULE) ! {send_push, Me, Friend, <<"request">>}, roster:info(?MODULE, "~p:~p:Friend/request:~p", [Me, ClientId, Friend]), <<>> end, @@ -52,7 +52,7 @@ info(#'Friend'{friend_id = Friend, status = ignore}, Req, #cx{params = ClientId, case roster:update_contact(Me, Contact2 = Contact#'Contact'{status = ignore}) of {ok, added} -> roster:send_ses(C, roster:phone(Me), roster:presence(Contact2)), <<>>; E -> #io{code = E} end; - _ -> #io{code = invalid_data} + _ -> #io{code = #error{code = invalid_data}} end, {reply, {bert, IO}, Req, State}; @@ -84,9 +84,9 @@ info(#'Friend'{friend_id = Friend, status = confirm}, Req, #cx{params = ClientId [n2o_vnode:subscribe(Client, Topic) || Client <- Tos ++ Froms], roster:send_ses(C, To, Mec2 = roster:presence(#'Contact'{reader = Rs} = roster:readmsgs(Mec#'Contact'{update = Now, created = Now, unread = 1}, Friend))), roster:send_ses(C, From, roster:presence(Friendc#'Contact'{update = Now, created = Now, unread = 1, reader = lists:reverse(Rs)})), - n2o_async:pid(system, ?MODULE) ! {send_push, Mec2, Friend, <<"friend">>}, + n2o_pi:pid(system, ?MODULE) ! {send_push, Mec2, Friend, <<"friend">>}, {io, Local, Remote}; - _ -> #io{code = invalid_data} + _ -> #io{code = #error{code = invalid_data}} end, {reply, {bert, D}, Req, State}; @@ -160,14 +160,14 @@ info(#'Friend'{phone_id = Roster, friend_id = Friend} = F, Req, State) -> roster:info(?MODULE, "~p:~p:Friend/unknown", [Roster, F]), {reply, {bert, <<>>}, Req, State}. -proc(init, #handler{name = ?MODULE} = Async) -> +proc(init, #pi{name = ?MODULE} = Async) -> roster:info(?MODULE, "ASYNC", []), {ok, Async}; -proc({send_push, #'Contact'{names = FromName} = FromContactPayload, To, PushType}, #handler{} = H) -> +proc({send_push, #'Contact'{names = FromName} = FromContactPayload, To, PushType}, #pi{} = H) -> ActionText = case PushType of <<"request">> -> " wants to add you on NYNJA!"; _ -> " accepted your contact request! Send a message!" end, PushAlert = iolist_to_binary([FromName, ActionText]), [roster_push:send_push_notification(Ses, FromContactPayload, PushAlert, PushType) || #'Auth'{} = Ses <- kvs:index('Auth', user_id, To)], {reply, [], H}; -proc({send_push, From, To, PushType}, #handler{} = H) -> +proc({send_push, From, To, PushType}, #pi{} = H) -> proc({send_push, roster:user(roster:roster_id(To), From), To, PushType}, H). diff --git a/apps/roster/src/protocol/roster_ftp.erl b/apps/roster/src/protocol/roster_ftp.erl index 8a498de09..85542215c 100644 --- a/apps/roster/src/protocol/roster_ftp.erl +++ b/apps/roster/src/protocol/roster_ftp.erl @@ -7,7 +7,11 @@ -define(ROOT, application:get_env(roster, upload, code:priv_dir(roster))). -define(NEXT, 250 * 1024). % 256K chunks for best 25MB/s speed -define(STOP, 0). - +-define(N2O_ENV, application:get_all_env(n2o)). +-define(REPLY_ENCODER, + begin + proplists:get_value(formatter,?N2O_ENV,n2o_bert) + end). % Callbacks filename(#ftp{sid = Sid, filename = FileName}) -> FileName. %filename:join(nitro:to_list(Sid),FileName). @@ -20,10 +24,11 @@ info(#ftp{status = {event, _}} = FTP, Req, State) -> [] -> index; M -> M end, Reply = try Module:event(FTP) - catch E:R -> Error = n2o:stack(E, R), - roster:info(?MODULE, "Catch: ~p:~p~n~p", Error), - Error end, - {reply, n2o:format({io, n2o_nitro:render_actions(n2o:actions()), Reply}), Req, State}; + catch E:R -> + roster:error(?MODULE, "Catch: ~p~n", {E, R}), + [E, R, erlang:get_stacktrace()] + end, + {reply, {bert, reply_encode(Reply)}, Req, State}; %% TODO delete RelPath usage info(#ftp{id = Link, status = <<"init">>, block = Block, offset = Offset} = FTP, Req, State) -> @@ -40,14 +45,14 @@ info(#ftp{id = Link, status = <<"init">>, block = Block, offset = Offset} = FTP, Offset2 = case FileSize >= Offset of true -> FileSize; false -> 0 end, FTP2 = FTP#ftp{block = Block2, offset = Offset2, data = <<>>}, - n2o_async:stop(file, Link), - n2o_async:start(#handler{module = ?MODULE, class = file, group = n2o, state = FTP2, name = Link}), + n2o_pi:stop(file, Link), + n2o_pi:start(#pi{module = ?MODULE, table = file, sup = n2o, state = FTP2, name = Link}), {reply, {bert, FTP2}, Req, State}; info(#ftp{id = Link, status = <<"send">>} = FTP, Req, State) -> roster:info(?MODULE, "Info Send: ~p", [FTP#ftp{data = <<>>}]), - Reply = try gen_server:call(n2o_async:pid({file, Link}), FTP) + Reply = try gen_server:call(n2o_pi:pid({file, Link}), FTP) catch E:R -> skip, roster:info(?MODULE, "Info Error call the sync: ~p", [{E, R}]), FTP#ftp{data = <<>>, block = ?STOP} end, @@ -58,7 +63,7 @@ info(Message, Req, State) -> {unknown, Message, Req, State}. % n2o Handlers -proc(init, #handler{state = #ftp{sid = Sid, meta = ClientId} = FTP} = Async) -> +proc(init, #pi{state = #ftp{sid = Sid, meta = ClientId} = FTP} = Async) -> roster:info(?MODULE, "Proc Init: ~p~n Sid: ~p ClientId: ~p", [FTP#ftp{data = <<>>}, Sid, ClientId]), FTP2 = FTP#ftp{data = <<>>, status = {event, init}}, roster:info(?MODULE, "~n~n~n~n FTP2 ~p ~n~n~n~n", [FTP2]), @@ -67,7 +72,7 @@ proc(init, #handler{state = #ftp{sid = Sid, meta = ClientId} = FTP} = Async) -> proc(#ftp{id = Link, sid = Sid, data = Data, status = <<"send">>, block = Block, meta = ClientId} = FTP, - #handler{state = #ftp{size = TotalSize, offset = Offset, filename = RelPath}} = Async) when Offset + Block >= TotalSize -> + #pi{state = #ftp{size = TotalSize, offset = Offset, filename = RelPath}} = Async) when Offset + Block >= TotalSize -> {S3_Status, S3_Data} = amazon_api:push_to_s3([], RelPath, Data, []), case S3_Status of ok -> @@ -75,23 +80,26 @@ proc(#ftp{id = Link, sid = Sid, data = Data, status = <<"send">>, block = Block, FTP2 = FTP#ftp{data = <<>>, block = ?STOP}, FTP3 = FTP2#ftp{status = {event, stop}, filename = RelPath}, n2o_ring:send({publish, <<"events/1//index/anon/", ClientId/binary, "/", Sid/binary>>, term_to_binary(FTP3)}), - spawn(fun() -> n2o_async:stop(file, Link) end), - {stop, normal, FTP2, Async#handler{state = FTP2}}; + spawn(fun() -> n2o_pi:stop(file, Link) end), + {stop, normal, FTP2, Async#pi{state = FTP2}}; _ -> - {reply, {error, S3_Data / binary}, Async} + {reply, {error, S3_Data}, Async} end; proc(#ftp{data = Data, block = Block} = FTP, - #handler{state = #ftp{offset = Offset, filename = RelPath}} = Async) -> + #pi{state = #ftp{offset = Offset, filename = RelPath}} = Async) -> FTP2 = FTP#ftp{status = <<"send">>, offset = Offset + Block}, roster:info(?MODULE, "Proc Process ~p", [FTP2#ftp{data = <<>>}]), {S3_Status, S3_Data} = amazon_api:push_to_s3([], RelPath, Data, []), case S3_Status of ok -> roster:info(?MODULE, "~n~n Uploaded to S3 file with link ~p ~n~n", [S3_Data]), - {reply, FTP2#ftp{data = <<>>}, Async#handler{state = FTP2#ftp{filename = RelPath}}}; + {reply, FTP2#ftp{data = <<>>}, Async#pi{state = FTP2#ftp{filename = RelPath}}}; _ -> - {reply, {error, S3_Data / binary}, Async} + {reply, {error, S3_Data }, Async} end; -proc(_, Async) -> {reply, #ftpack{}, Async}. \ No newline at end of file +proc(_, Async) -> {reply, #ftpack{}, Async}. + +reply_encode(Reply)-> + (?REPLY_ENCODER):encode(Reply). \ No newline at end of file diff --git a/apps/roster/src/protocol/roster_history.erl b/apps/roster/src/protocol/roster_history.erl index 91004dbad..9a1d22237 100644 --- a/apps/roster/src/protocol/roster_history.erl +++ b/apps/roster/src/protocol/roster_history.erl @@ -4,7 +4,7 @@ -include_lib("kvs/include/kvs.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). -define(HISTORY_UPDATE_ACTION, <<"history_update">>). -define(HISTORY_DELETE_ACTION, <<"history_delete">>). @@ -47,6 +47,7 @@ info(#'History'{status = get} = History, Req, #cx{state = []} = State) -> info(History, Req, State#cx{state = {status, get}}); info(#'History'{status = get, feed = [], data = [#'Message'{feed_id = Feed}|_]} = History, Req, State) when Feed /= []-> info(History#'History'{feed = Feed}, Req, State); + info(#'History'{status = get, roster_id = Roster0, feed = Feed, size = N, entity_id = MId, data = MsgData} = History, Req, #cx{params = ClientId, state = {status, InitialStatus}} = State) when N /= 0 andalso (is_record(Feed, p2p) orelse is_record(Feed, muc)) andalso @@ -180,12 +181,12 @@ info(#'History'{status = update, feed = Feed, entity_id = MId}, Req, members = [roster:reader_cache(roster:muc_member(PhoneId, Room, presence))]}, roster:reader_cache(UpdRoom#'Room'.readers)}; #p2p{} -> {_, FR, _, U} = roster:get_feed_data(Feed, roster:friend(PhoneId, Feed)), - {U, [roster:reader_cache(RId) || RId <- [FR, UpdReader]]}; - _ -> {<<>>, <<>>} + {U, [roster:reader_cache(RId) || RId <- [FR, UpdReader]]} + % _ -> {<<>>, <<>>} %% TODO: ------------------- To be removed in the future. ------------------- end, Res = roster:update_field(Record, [{unread, Unread}, {reader, Readers }, {readers, Readers }, {status, last_msg}]), roster:send_ses(C, From, Res), - n2o_async:pid(system, ?MODULE) ! {send_push, PhoneId, Feed, ?HISTORY_UPDATE_ACTION}, + n2o_pi:pid(system, ?MODULE) ! {send_push, PhoneId, Feed, ?HISTORY_UPDATE_ACTION}, <<>>; false -> Unread end, @@ -207,7 +208,7 @@ info(#'History'{feed = Feed, status = delete}, Req, #cx{client_pid = C, params = %% D=case is_integer(Unread) of true -> roster:send_ses(C, From, roster:update_field(FList,Record,unread,Unread)), <<>>; false -> Unread end, roster:send_feed(C, Feed, roster:readmsgs(Internal#'Message'{next = []}, PhoneId)), %% send push if no history clean error occured - n2o_async:pid(system, ?MODULE) ! {send_push, PhoneId, Feed, ?HISTORY_DELETE_ACTION}, + n2o_pi:pid(system, ?MODULE) ! {send_push, PhoneId, Feed, ?HISTORY_DELETE_ACTION}, <<>>; {I,_} -> I end, {reply, {bert, IO}, Req, State}; @@ -270,18 +271,18 @@ clean_history(Feed, From, To, Rs) -> _ -> {#io{code = #error{code = invalid_data}}, <<>>} end. -proc(init, #handler{name = roster_history} = Async) -> +proc(init, #pi{name = roster_history} = Async) -> roster:info(?MODULE, "ASYNC:~p", [?MODULE]), {ok, Async}; -proc({send_push, ToPhoneId, Feed, Action}, #handler{} = H) -> +proc({send_push, ToPhoneId, Feed, Action}, #pi{} = H) -> PushType = <<"message">>, Payload = case Feed of {muc, RoomId} -> try Room = #'Room'{} = roster:room(roster:roster_id(ToPhoneId), RoomId), case Action of ?HISTORY_UPDATE_ACTION -> Room#'Room'{last_msg = []}; _ -> Room end catch Err:Rea -> - roster:error(?MODULE, ":~p~n", [n2o:stack_trace(Err, Rea)]) + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end; #p2p{} -> Contact = roster:user(roster:roster_id(ToPhoneId), roster:friend(ToPhoneId, Feed)), diff --git a/apps/roster/src/protocol/roster_link.erl b/apps/roster/src/protocol/roster_link.erl index 632de7d92..95ecc1ba7 100644 --- a/apps/roster/src/protocol/roster_link.erl +++ b/apps/roster/src/protocol/roster_link.erl @@ -57,9 +57,8 @@ info(#'Link'{id = LinkId, room_id = RoomId, type = Type, status = update = LStat Res = case roster:muc_member(ClientId, RoomId) of #'Member'{status = Status} when Status == owner; Status == admin -> case update_link(RequestData) of - {error, invalid_data} = E -> #io{code = E}; - {error, not_found} = E -> #io{code = E}; - NewLink -> NewLink + #'Link'{} = NewLink -> NewLink; + {error, invalid_data} = E -> #io{code = E} end; #'Member'{status = member} -> #io{code = #error{code = permission_denied}}; @@ -89,15 +88,17 @@ info(#'Link'{} = RequestData, Req, #cx{params = ClientId} = State) -> update_link(#'Link'{id=[], room_id = EId, type=Type}) ->gen_link(EId,Type); update_link(#'Link'{id=LinkId, room_id = EId, type=Type} = Link) -> - case get_link(kvs:get('Room',EId)) of - #'Link'{id=LinkId, room_id = EId} = L -> kvs:put(NewL=L#'Link'{type=Type}), - NewL#'Link'{status=update}; - #'Link'{id=Links0, room_id = EId} = L -> ok = kvs:delete('Link', Links0), - kvs:put(NewL=L#'Link'{id=LinkId, created=roster:now_msec(),type=Type}), - NewL#'Link'{status=update}; - {error, not_found} -> {error, invalid_data}; - E -> E - end. + case get_link(kvs:get('Room',EId)) of + #'Link'{id=LinkId, room_id = EId} = L -> + kvs:put(NewL=L#'Link'{type=Type}), + NewL#'Link'{status=update}; + #'Link'{id=Links0, room_id = EId} = L -> + ok = kvs:delete('Link', Links0), + kvs:put(NewL=L#'Link'{id=LinkId, created=roster:now_msec(),type=Type}), + NewL#'Link'{status=update}; + _ -> + {error, invalid_data} + end. %% NOTE - Not used at the moment, to be finished in next release @@ -127,7 +128,7 @@ delete_link(ClientId, #'Link'{id = LinkId, room_id = RoomId}) -> lists:map( fun (#'Member'{status = member}) -> {error, permission_denied}; - (#'Member'{status = Status}) when Status == owner; Status == admin -> + (#'Member'{status = Status}) when Status =:= admin; Status =:= owner -> case kvs:get('Room', RoomId) of {ok, #'Room'{id = RoomId, links = Links} = Room} -> ok = kvs:put(Room#'Room'{links = lists:keydelete(LinkId, #'Link'.id, Links)}), diff --git a/apps/roster/src/protocol/roster_message.erl b/apps/roster/src/protocol/roster_message.erl index 67c7dd4fd..b9796cd5c 100644 --- a/apps/roster/src/protocol/roster_message.erl +++ b/apps/roster/src/protocol/roster_message.erl @@ -10,7 +10,7 @@ -define(MSG_EDIT_ACTION, <<"message_edit">>). -define(MSG_DELETE_ACTION, <<"message_delete">>). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Typing'{phone_id = Phone, comments = Comments}, Req, #cx{} = State) -> @@ -97,7 +97,7 @@ info(#'Message'{status = [], id = [], feed_id = F, from=From0, to = To, roster:info(?MODULE, "~p:Message/new:~p", [From, To]), %% have to skip push notifications for call bubbles case [lists:keyfind(BubbleContentType, #'Desc'.mime, Descs) || BubbleContentType <- [?CONTENT_TYPE_VIDEOCALL, ?CONTENT_TYPE_AUDIOCALL]] of - [false, false] -> n2o_async:pid(system, ?MODULE) ! {send_push, From, To, Msg2, []}; + [false, false] -> n2o_pi:pid(system, ?MODULE) ! {send_push, From, To, Msg2, []}; _ -> skip end, <<>> @@ -145,10 +145,9 @@ info(#'Message'{status = edit, id = Id, msg_id = ClMID, feed_id = Feed, from = F %% move cursor kvs_stream:save(R = kvs_stream:top(kvs_stream:load_reader(Reader))), roster:put_readers(write_top, Ent, R), - n2o_async:pid(system, ?MODULE) ! {send_push, From1, To1, Internal, ?MSG_EDIT_ACTION}, + n2o_pi:pid(system, ?MODULE) ! {send_push, From1, To1, Internal, ?MSG_EDIT_ACTION}, %% publish - roster:send_feed(C, Feed, Internal), <<>>; - E -> E + roster:send_feed(C, Feed, Internal), <<>> end, {reply, {bert, IO}, Req, State}; @@ -228,7 +227,7 @@ info(#'Message'{id = Id, msg_id = ClMID, feed_id = Feed, from = From0, seenby = n2o_vnode:send(C, Topic, term_to_binary(Internal)), %% NOTE! send push about deleted msg only if acted user is in the seenby case Seen of [-1] -> - n2o_async:pid(system, ?MODULE) ! {send_push, From1, To1, Internal, ?MSG_DELETE_ACTION}; _ -> + n2o_pi:pid(system, ?MODULE) ! {send_push, From1, To1, Internal, ?MSG_DELETE_ACTION}; _ -> skip end, case {Type, Link} of {[reply], Link} when is_integer(Link) andalso NewSeen == [-1] -> @@ -276,7 +275,7 @@ info(#'Message'{status = update, id = Id, files = [#'Desc'{mime = <<"transcribe" when is_integer(Id), not is_tuple(Req) -> Type = case roster:get_data_val(<<"TYPE">>, Data) of [] -> short; T -> binary_to_atom(T, utf8) end, Lang = roster:get_data_val(?LANG_KEY, Data), - Pid = n2o_async:pid(system, roster_message), + Pid = n2o_pi:pid(system, roster_message), case kvs:get('Message', Id) of {ok, #'Message'{feed_id = Feed, from = From, to = To, files = [#'Desc'{mime = <<"audio">>, payload = Uri} | _]}} -> roster:info(?MODULE, "enter ~p transcribe process with ~p", [Type, Uri]), @@ -296,7 +295,7 @@ info(#'Message'{status = update, id = Id, files = [#'Desc'{mime = <<"transcribe" [file:delete(filename:absname(File)) || File <- [FileIn, FileOut]], R; {error, ErrInfo} -> roster:error(?MODULE, "invalid url for transcribe: ~p", [ErrInfo]), - #io{code = {error, invaid_data}, data = ErrMsg} + #io{code = {error, invalid_data}, data = ErrMsg} end, Pid ! {Res, ClientId} end), {reply, {bert, #io{code = #ok{code = transcribe}, data = Id}}, Req, State}; long -> @@ -316,7 +315,7 @@ info(#'Message'{status = update, id = Id, files = [#'Desc'{mime = <<"transcribe" end; {ok, InvalidMsg} -> roster:info(?MODULE, "invalid audio transcribe for ~p", [InvalidMsg]), - {reply, {bert, #io{code = invalid_data, data = InvalidMsg}}, Req, State}; + {reply, {bert, #io{code = #error{code = invalid_data}, data = InvalidMsg}}, Req, State}; {error, _} = E -> roster:error(?MODULE, "message ~p not found for transcribe", [Id]), {reply, {bert, #io{code = E}, #'Message'{id = Id}}, Req, State} end; @@ -378,12 +377,12 @@ info(#'Message'{from = From, to = To} = ReqData, Req, State) -> roster:info(?MODULE, "~p:~p:Message/unknown:~p", [From, To, {ReqData, Req}]), {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. -proc(init, #handler{name = roster_message} = Async) -> +proc(init, #pi{name = roster_message} = Async) -> roster:info(?MODULE, "ASYNC:~p", [?MODULE]), {ok, C} = emqttc:start_link([{client_id, <<"roster_message">>}, {logger, {console, error}}, {reconnect, 5}]), - {ok, Async#handler{state = C, seq = 0}}; + {ok, Async#pi{state = C}}; -proc({send_push, From, To, #'Message'{type = TypeList} = Msg, Action}, #handler{} = H) -> +proc({send_push, From, To, #'Message'{type = TypeList} = Msg, Action}, #pi{} = H) -> %% Check should server proceed push %% TODO add push for message/delete case From of @@ -391,21 +390,21 @@ proc({send_push, From, To, #'Message'{type = TypeList} = Msg, Action}, #handler{ _ -> notify(From, To, Msg, Action) end, {reply, [], H}; -proc({#io{} = IO, ClientId}, #handler{state = C} = H) -> +proc({#io{} = IO, ClientId}, #pi{state = C} = H) -> roster:error(?MODULE, "~p", [IO]), roster:send_action(C, ClientId, IO), {reply, [], H}; -proc({#'Message'{status = update} = Msg, ClientId}, #handler{state = C} = H) -> +proc({#'Message'{status = update} = Msg, ClientId}, #pi{state = C} = H) -> roster:info(?MODULE, "UPDATE TRANSCRIBE: ~p", [Msg]), try {reply, {bert, IO}, _, _} = info(Msg, {[], handled}, #cx{params = ClientId, client_pid = C, state = ack}), roster:send_action(C, ClientId, IO) catch Err:Rea -> - roster:error(?MODULE, ":~p~n", [n2o:stack_trace(Err, Rea)]) + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, {reply, [], H}; -proc({mqttc, C, connected}, State = #handler{state = C, seq = S}) -> {ok, State#handler{seq = S + 1}}; +proc({mqttc, C, connected}, State = #pi{state = C}) -> {ok, State}; proc({mqttc, _C, disconnected}, State) -> {ok, State}; -proc(Unknown, #handler{} = H) -> +proc(Unknown, #pi{} = H) -> roster:info(?MODULE, "invalid message data :~p", [Unknown]), {reply, [], H}. diff --git a/apps/roster/src/protocol/roster_presence.erl b/apps/roster/src/protocol/roster_presence.erl index b184d0bb1..6a58e3da6 100644 --- a/apps/roster/src/protocol/roster_presence.erl +++ b/apps/roster/src/protocol/roster_presence.erl @@ -28,7 +28,7 @@ on_connect(Phone, ClientId, C, Ver) -> roster:send_cache(ClientId, C) end catch Err:Rea -> - roster:info(?MODULE, "Catch:~p", [n2o:stack_trace(Err, Rea)]) + roster:info(?MODULE, "Catch:~p~n", [{Err, Rea}]) end. on_disconnect(#'Auth'{type = logout, phone = Phone, client_id = ClientId, user_id = PhoneId}, C) -> diff --git a/apps/roster/src/protocol/roster_profile.erl b/apps/roster/src/protocol/roster_profile.erl index 9314153bd..655cb0226 100644 --- a/apps/roster/src/protocol/roster_profile.erl +++ b/apps/roster/src/protocol/roster_profile.erl @@ -3,7 +3,7 @@ -include_lib("n2o/include/n2o.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module=?MODULE,class=system,group=roster,name=?MODULE,state=[]}). +start() -> n2o_pi:start(#pi{module=?MODULE,table=system,sup=roster,name=?MODULE,state=[]}). %%info(#'Profile'{phone=Phone, rosters=Rosters, status=set} = Data, Req, %% #cx{params = ClientId} = State) -> @@ -82,18 +82,18 @@ info(#'Profile'{status = init} = Data, Req, State) -> info(#'Profile'{} = Data, Req, State) -> {reply, {bert, Data}, Req, State}. -proc(init,#handler{name=?MODULE} = Async) -> +proc(init,#pi{name=?MODULE} = Async) -> roster:info(?MODULE, "ASYNC",[]), {ok,Async}; -proc({restart, M}, #handler{state = {C, Proc}, seq = S} = H) -> +proc({restart, M}, #pi{state = {C, Proc}} = H) -> roster:info(?MODULE, "BPE PROC restarted", []), roster:restart_module(M), {reply, [], H}. %% TODO maybe in future -%%proc({send_email,#'Service'{id = Addr, data = Code}}, #handler{}=H) -> +%%proc({send_email,#'Service'{id = Addr, data = Code}}, #pi{}=H) -> %% Half = size(Code)-round(size(Code)/2), %% Codes1 = binary:part(Code, 0, Half), %% Codes2 = binary:part(Code, Half, Half), @@ -104,7 +104,7 @@ proc({restart, M}, #handler{state = {C, Proc}, seq = S} = H) -> %% {reply, [], H}; %% TODO maybe in future -%%proc({aws, ClientId}, #handler{state = C} = H) -> +%%proc({aws, ClientId}, #pi{state = C} = H) -> %% Res = case amazon_api:gen_temp_creds() of %% {error, Reason} -> #io{code = #error{code = Reason}}; %% {ok, {AccessKeyId, SecretAccessKey, SessionToken, Expiration}} -> @@ -127,11 +127,11 @@ del_roster(UID,RosterId) -> roster:unsubscribe_p2p(UID, RosterId), roster:remove_member(PId), roster:unsubscribe_muc(PId), - [roster:update_writer(#muc{name=Name},{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = "Deleted"}]}) + [roster:update_writer(#muc{name=Name},{#'Message'.from, PId},{#'Message'.files,[#'Desc'{payload = <<"Deleted">>}]}) || #'Room'{id=Name} <- Rooms], - [roster:update_writer(roster:feed_key(p2p,PId,FId),{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = "Deleted"}]}) + [roster:update_writer(roster:feed_key(p2p,PId,FId),{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = <<"Deleted">>}]}) || #'Contact'{phone_id = FId} <- Conts], - roster:update_chains({'Message',from},{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = "Deleted"}]}), + roster:update_chains({'Message',from},{#'Message'.from,PId},{#'Message'.files,[#'Desc'{payload = <<"Deleted">>}]}), kvs:delete('Index', {nick, string:lowercase(Nick)}), case roster:is_online(user_id,PId) of offline -> roster:delete_sessions(user_id, PId); online -> roster:force_logout(user_id,PId) end, % TODO Add force_logout/2 diff --git a/apps/roster/src/protocol/roster_push.erl b/apps/roster/src/protocol/roster_push.erl index 961ea4961..7c2445c60 100644 --- a/apps/roster/src/protocol/roster_push.erl +++ b/apps/roster/src/protocol/roster_push.erl @@ -4,13 +4,13 @@ -include_lib("kvs/include/kvs.hrl"). -compile(export_all). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). -proc(init, #handler{name = ?MODULE} = Async) -> +proc(init, #pi{name = ?MODULE} = Async) -> roster:info(?MODULE, "ASYNC", []), {ok, Async}; -proc({async_push, Session, Payload, PushAlert, PushType}, #handler{} = H) -> +proc({async_push, Session, Payload, PushAlert, PushType}, #pi{} = H) -> send_push_notification(Session, Payload, PushAlert, PushType), {reply, [], H}. diff --git a/apps/roster/src/protocol/roster_room.erl b/apps/roster/src/protocol/roster_room.erl index 184a9fb36..8ac837367 100644 --- a/apps/roster/src/protocol/roster_room.erl +++ b/apps/roster/src/protocol/roster_room.erl @@ -9,7 +9,7 @@ -define(MAX_ROOM_LENGTH, 32). -define(MIN_ROOM_LENGTH, 1). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Room'{status = create, id = Room, admins = [Admin|_], type=Type} = R, Req, #cx{state = verified} = State) -> @@ -65,7 +65,7 @@ info(#'Room'{status = patch, id = Room, name = Name, data = AvatarDesc} = R, Req files = [#'Desc'{payload = iolist_to_binary([?SYS_MSG_UPDATE_GROUP_NAME, " \"", NewName, "\""])}], type = [sys], status = []}, roster:get_reader(RoomFeed, PId)), roster:send_room(C, Room, NewNameMsg), - n2o_async:pid(system, ?MODULE) ! {send_push, [], NewNameMsg, name}, + n2o_pi:pid(system, ?MODULE) ! {send_push, [], NewNameMsg, name}, NewNameLastMsgId; _ -> StoredLastMsgId end, @@ -82,7 +82,7 @@ info(#'Room'{status = patch, id = Room, name = Name, data = AvatarDesc} = R, Req #'Desc'{payload = AvatarPayload, mime = AvatarMime}], type = [sys], status = []}, roster:get_reader(RoomFeed, PId)), roster:send_room(C, Room, NewAvatarMsg), - n2o_async:pid(system, ?MODULE) ! {send_push, [], NewAvatarMsg, photo}, + n2o_pi:pid(system, ?MODULE) ! {send_push, [], NewAvatarMsg, photo}, NewAvatarLastMsgId; _ -> NameLastMsgId end; @@ -136,16 +136,22 @@ info(#'Room'{status = St, id = Room, members = Members, admins = Admins, readers case roster:muc_member(PhoneId, Room, presence) of #'Member'{status = removed} = M when Status == admin; Status == member-> M2 = roster:patch_member(M#'Member'{status = Status}, Member), - {M3, _, UpdRoom} = roster:add_member(TmpRoom, M2, {no_muc_message, HL}), - kvs:put(M3), - {M3, UpdRoom}; + case lists:map(fun handle_add_member/1, + [roster:add_member(TmpRoom, M2, {no_muc_message, HL})]) + of + [{M3, _} = Resource]-> ok = kvs:put(M3), Resource; + _ -> error + end; #'Member'{phone_id = APId} = M -> {ignore, M}; #'Member'{} = M -> kvs:put(M2 = roster:patch_member(M#'Member'{status = Status}, Member)), {ignore, M2}; - _ -> {M2, _, UpdRoom} = roster:add_member(TmpRoom, - Member#'Member'{feed_id = #muc{name = Room}, reader = 0}, {no_muc_message, HL}), - {M2, UpdRoom} + _ -> + [Resource] = + lists:map(fun handle_add_member/1, [roster:add_member(TmpRoom, + Member#'Member'{feed_id = #muc{name = Room}, reader = 0}, + {no_muc_message, HL})]), + Resource end, case MmbrRoom of error -> roster:info(?MODULE, "ERROR:add_member:RosterNotFound:~p", [PhoneId]), @@ -185,7 +191,7 @@ info(#'Room'{status = St, id = Room, members = Members, admins = Admins, readers to = Room, msg_id = roster:msg_id(), files = [#'Desc'{payload = Payload}]}, Reader), {_, PutRoom} = roster:put_readers(write_top, AdmMember, R), - n2o_async:pid(system, ?MODULE) ! {send_push, NewMmbrs, Msg, RStatus2}, + n2o_pi:pid(system, ?MODULE) ! {send_push, NewMmbrs, Msg, RStatus2}, {PutRoom#'Room'{last_msg = Msg}, PutRoom#'Room'{last_msg = Msg#'Message'.id}} end, R5 = R3#'Room'{status = RStatus2, members = Members2, admins = Admins3, links=[roster_link:get_link({ok,R3})]}, [ begin roster:send_ses(C, roster:phone(PhId), @@ -225,7 +231,7 @@ info(#'Room'{status = remove, members = Members, admins = Admins0, id = Room}, R lists:ukeymerge(#'Room'.id, [StoredRoom#'Room'{status = removed}], Rooms)}, Feed), kvs:put(M2 = M#'Member'{status = removed, update = roster:now_msec()}), {[M2 | Ms], [Alias, <<",">> | Alss], [Roster2 | Rs]}; - false -> Acc end end, {[], [], []}, Members ++ Admins), + [] -> Acc end end, {[], [], []}, Members ++ Admins), {Admins2, Members2} = roster:split_members(Mmbrs), Admins3 = lists:ukeymerge(#'Member'.id, lists:ukeysort(#'Member'.id, Admins2), [AdmMember]), Msg = roster:add_message(#'Message'{feed_id = #muc{name = Room}, from = APId, to = Room, @@ -239,7 +245,7 @@ info(#'Room'{status = remove, members = Members, admins = Admins0, id = Room}, R roster:send_room(C, R2), [roster:send_ses(C, roster:phone(PhoneId), Rec) || #'Member'{phone_id = PhoneId} <- Mmbrs, Rec <- [R2, Msg]], - n2o_async:pid(system, ?MODULE) ! {send_push, Mmbrs, Msg, remove}, + n2o_pi:pid(system, ?MODULE) ! {send_push, Mmbrs, Msg, remove}, roster:send_room(C, Room, Msg); #'Member'{} -> #io{code = #error{code = permission_denied}}; _ -> #io{code = #error{code = member_not_found}} end; @@ -295,7 +301,7 @@ info(#'Room'{status = leave, id = Room}, Req, #cx{params = ClientId, client_pid roster:send_room(C, R), [roster:cache_ses(PId, R)|| #'Member'{phone_id = PId} <-roster:members(#muc{name = Room}, active)], roster:send_room(C, Room, Msg), - n2o_async:pid(system, ?MODULE) ! {send_push, [], Msg, leave}, + n2o_pi:pid(system, ?MODULE) ! {send_push, [], Msg, leave}, Room2#'Room'{update = roster:now_msec(), last_msg = Msg#'Message'.id} end, kvs:put(M#'Member'{reader = 0, update = roster:now_msec(), status = removed}), @@ -344,11 +350,11 @@ info(#'Member'{} = Member, Req, #cx{params = ClientId} = State) -> {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. -proc(init, #handler{name = roster_room} = Async) -> +proc(init, #pi{name = roster_room} = Async) -> roster:info(?MODULE, "ASYNC ROOM PROC started", []), {ok, Async}; %% TODO use roster_push instead -proc({send_push, NewMembers, Msg, Type}, #handler{} = H) -> +proc({send_push, NewMembers, Msg, Type}, #pi{} = H) -> PushType = <<"message">>, #'Message'{from = FromPhoneId, to = RoomId} = Msg, {ok, #'Room'{name = RoomName}} = kvs:get('Room', RoomId), @@ -399,4 +405,8 @@ proc({send_push, NewMembers, Msg, Type}, #handler{} = H) -> end, roster_push:send_push_notification(Ses, Payload, PushAlert, PushType) end || {MemPhoneId, _} = Mem <- ToRoomMembers, Ses <- kvs:index('Auth', user_id, MemPhoneId) - ], {reply, [], H}. \ No newline at end of file + ], {reply, [], H}. + +handle_add_member({error,_})-> error; +handle_add_member({Member, _, Room}) when Member =/= error-> {Member, Room}; +handle_add_member(_)-> error. diff --git a/apps/roster/src/protocol/roster_roster.erl b/apps/roster/src/protocol/roster_roster.erl index 0466809ed..84799da43 100644 --- a/apps/roster/src/protocol/roster_roster.erl +++ b/apps/roster/src/protocol/roster_roster.erl @@ -7,7 +7,7 @@ -define(MIN_NAME_LENGTH, 2). -define(MIN_SURNAME_LENGTH, 1). -start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Roster'{status = patch, avatar = Avatar} = Data, Req, #cx{params = ClientId, client_pid = C, @@ -25,7 +25,7 @@ info(#'Roster'{status = patch, avatar = Avatar} = Data, Req, roster:send_ac(C, PhoneId, NewC#'Contact'{unread = []}), roster:send_ses(C, Phone, UpdRoster#'Roster'{userlist = [NewC#'Contact'{presence = online}], roomlist = [], favorite = []}), - n2o_async:send(system, ?MODULE, {update_ac, NewC}), + n2o_pi:send(system, ?MODULE, {update_ac, NewC}), %% TODO clarify logic of update user/member info case Avatar of OldAvatar -> skip; [] -> skip; _ -> [case roster:muc_member(PhoneId, Room) of @@ -80,11 +80,12 @@ info(#'Roster'{id = RosterId, nick = NickToBeValidated, status = nick} = Data, R #io{code = #error{code = invalid_nick}}; {ok, Nick} -> %% set processing data to lowercase - OldNickLow = string:lowercase(OldNick), - NickValidationError = - case NickLow = string:lowercase(Nick) of - [] -> false; - _ -> %% check is nick taken by another user + OldNickLow = list_to_binary(string:to_lower(nitro:to_list(OldNick))), + NickLow = list_to_binary(string:to_lower(nitro:to_list(Nick))), + NickValidationError = case NickLow of + <<>> -> false; + _ -> +%% check is nick taken by another user case kvs:get('Index', {nick, NickLow}) of {ok, #'Index'{roster = [TakenRosterId]}} when TakenRosterId /= ActedRosterId -> true; _ -> false @@ -98,17 +99,17 @@ info(#'Roster'{id = RosterId, nick = NickToBeValidated, status = nick} = Data, R %% index processing case NickLow of OldNickLow -> skip; - [] -> n2o_async:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}); + <<>> -> n2o_pi:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}); _ -> - n2o_async:send(system, ?MODULE, {update_index, #'Roster'{id = ActedRosterId, nick = NickLow}}), - n2o_async:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}) + n2o_pi:send(system, ?MODULE, {update_index, #'Roster'{id = ActedRosterId, nick = NickLow}}), + n2o_pi:send(system, ?MODULE, {delete_index, #'Roster'{id = ActedRosterId, nick = OldNickLow}}) end, %% NOTE! Pay attention! Copypaste from Roster/Patch, need to check [NewC] = roster:to_contact([UpdRoster#'Roster'{status = Status}], friend), UpdNewC = NewC#'Contact'{unread = []}, roster:send_ac(C, roster:phone_id(Phone, ActedRosterId), UpdNewC), roster:send_ses(C, Phone, UpdRoster#'Roster'{userlist = [UpdNewC#'Contact'{presence = online}], roomlist = [], favorite = []}), - n2o_async:send(system, ?MODULE, {update_ac, UpdNewC}), + n2o_pi:send(system, ?MODULE, {update_ac, UpdNewC}), <<>>; true -> roster:info(?MODULE, "Debug.GotNickAlreadyUsedError", []), @@ -160,11 +161,11 @@ info(#'Roster'{id = RosterId, status = Status}, Req, #cx{params = ClientId} = St roster:info(?MODULE, "~p:~p:Roster/unknown:~p", [RosterId, ClientId, Status]), {reply, {bert, #io{code = #error{code = invalid_data}}}, Req, State}. -proc(init, #handler{name = ?MODULE} = Async) -> +proc(init, #pi{name = ?MODULE} = Async) -> roster:info(?MODULE, "ASYNC", []), {ok, Async}; -proc({update_ac, #'Contact'{phone_id = PhoneId} = C}, #handler{} = H) -> +proc({update_ac, #'Contact'{phone_id = PhoneId} = C}, #pi{} = H) -> [Phone, RosterId] = roster:parts_phone_id(PhoneId), [begin [P, FriendId] = roster:parts_phone_id(PId), Res = case roster:get_contact(FriendId, PhoneId) of @@ -174,12 +175,12 @@ proc({update_ac, #'Contact'{phone_id = PhoneId} = C}, #handler{} = H) -> || #'Contact'{phone_id = PId} <- roster:get_on_status(RosterId, friend)], {reply, [], H}; -proc({update_index, #'Roster'{id = RosterId, nick = Nick}}, #handler{} = H) -> +proc({update_index, #'Roster'{id = RosterId, nick = Nick}}, #pi{} = H) -> kvs:put(#'Index'{id = {nick, Nick}, roster = [RosterId]}), %% @TODO: Have to be code for adding new nick into B-tree for nicks {reply, [], H}; %% TODO refactor me -proc({delete_index, #'Roster'{id = RosterId, nick = Nick}}, #handler{} = H) -> +proc({delete_index, #'Roster'{id = RosterId, nick = Nick}}, #pi{} = H) -> kvs:delete('Index', {nick, Nick}), {reply, [], H}. \ No newline at end of file diff --git a/apps/roster/src/protocol/roster_search.erl b/apps/roster/src/protocol/roster_search.erl index 03fc9f085..462702e8b 100644 --- a/apps/roster/src/protocol/roster_search.erl +++ b/apps/roster/src/protocol/roster_search.erl @@ -3,7 +3,7 @@ -include_lib("n2o/include/n2o.hrl"). -compile(export_all). -%start() -> n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, name = ?MODULE, state = []}). +% start() -> n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, name = ?MODULE, state = []}). info(#'Search'{id = FromRosterId, ref = Ref, field = <<"link">>, type = '==', value = SearchVal, status = room}, Req, #cx{params = <<"emqttd_",_/binary>> = ClientId} = State) -> @@ -66,14 +66,6 @@ info(#'Search'{id = From, ref = Ref, field = <<"phone">>, type = '==', value = P %roster:info(?MODULE, "Res.Search/phone:~p", [Res]), {reply, {bert, {io, {ok, Ref}, Res}}, Req, State}; -%% TBD is this method neccesery? -info(#'Search'{id = From, ref = Ref, field = K, type = 'like', value = V, status = roster}, Req, - #cx{params = <<"emqttd_", _/binary>> = ClientId} = State) when is_atom(K), Ref /=[] -> - roster:info(?MODULE, "~p:~p:Search/names:~p", [From, ClientId, V]), - L = [binary_to_list(string:lowercase(V)) ++ F - || F <- ets:match(K, {binary_to_list(string:lowercase(V)) ++ '$1'})], - {reply, {bert, {io, {ok, Ref}, L}}, Req, State}; - info(#'Search'{} = Data, Req, State) -> roster:info(?MODULE, "Search/unknown:~p", [Data]), {reply, {bert, {io, {error,invalid_data}}}, Req, State}. @@ -105,4 +97,4 @@ info(#'Search'{} = Data, Req, State) -> %% _ -> skip %% end, %% index_next(R, K, Next),ok -%% end. \ No newline at end of file +%% end. diff --git a/apps/roster/src/rest/rest_chat_csv.erl b/apps/roster/src/rest/rest_chat_csv.erl index c49a7ac09..4afdbba64 100644 --- a/apps/roster/src/rest/rest_chat_csv.erl +++ b/apps/roster/src/rest/rest_chat_csv.erl @@ -25,9 +25,8 @@ ]). %% Custom data types --type type_chat_element() :: {MsgDate::integer(), Username::string(), Message::string()}. +-type type_chat_element() :: {MsgDate::integer(), Username::string(), MessageType:: [] | binary(), Message::string()}. -type type_chat() :: [type_chat_element()]. --type type_chat_history() :: list(#'Message'{}). -type type_user_data() :: {binary(), string()}. %%%============================================================================= @@ -64,7 +63,7 @@ handle_request('GET', #{room := GroupChatId}, Req) -> try ChatHistory = get_chat_history({muc, RoomId}), Members = get_group_chat_members(RoomId), - GroupChatName = get_group_chat_name(RoomId), + GroupChatName = binary_to_list(get_group_chat_name(RoomId)), #'Member'{id = MemberId} = roster:muc_member(rest_main_helper:get_client_phone_id(Req), RoomId), ChatData = extract_chat_data(ChatHistory, Members, FromDate, ToDate, AllowedMessageTypes, MemberId), CsvText = conversation_to_csv(ChatData, GroupChatName, FromDate, ToDate, TimeZone, AllowedMessageTypes), @@ -111,7 +110,7 @@ conversation_to_csv(ChatData, ToUsername, FromDate, ToDate, TimeZone, AllowedMes TemplateRows = build_template_rows(ChatSpanTimezone, ToUsername, AllowedMessageTypes), build_message_rows(ChatData, TimeZone, TemplateRows). --spec build_template_rows(tuple(), string(), list()) -> list(). +-spec build_template_rows(tuple(), string(), list()) -> [string()]. build_template_rows({FromDate, ToDate}, ToUsername, AllowedMessageTypes) -> Template = ["NYNJA Chat Export", ?NEW_LINE, ?NEW_LINE, "From Date:", ?NEW_COLUMN, format_date(FromDate, "M dS Y"), ?NEW_LINE, @@ -164,8 +163,7 @@ extract_user_id(PhoneId) -> match_member_to_phone_id(Members, PhoneId) -> case lists:dropwhile(fun({Id, _}) -> Id /= PhoneId end, Members) of [] -> throw({no_username_match, PhoneId}); - [{_, Username} | _] -> Username; - _ -> throw({no_username_match, PhoneId}) + [{_, Username} | _] -> Username end. -spec get_username_by_id(Id::non_neg_integer()) -> string(). @@ -175,7 +173,7 @@ get_username_by_id(Id) -> {error, _} -> throw({no_username, Id}) end. --spec get_group_chat_members(RoomId::binary()) -> list(#'Member'{}). +-spec get_group_chat_members(RoomId::binary()) -> list({binary(), list()}) | no_return(). get_group_chat_members(RoomId) -> case roster:members({muc, RoomId}) of [] -> @@ -188,22 +186,22 @@ get_group_chat_members(RoomId) -> phone_id = PhoneId} <- Members] end. --spec get_group_chat_name(RoomId::binary()) -> string(). +-spec get_group_chat_name(RoomId::binary()) -> binary() | no_return(). get_group_chat_name(RoomId) -> case kvs:get('Room', RoomId) of {ok, #'Room'{name = RoomName}} -> RoomName; {error, _} -> throw({no_muc_name, RoomId}) end. --spec get_chat_history(Feed::tuple()) -> list(#'Message'{}). +-spec get_chat_history(Feed::tuple()) -> list(#'Message'{}) | no_return(). get_chat_history(Feed) -> case roster_db:get_chain('Message', roster:feed_key(Feed)) of [] -> throw({no_chat_history, Feed}); History -> History end. --spec get_chat_time_span(type_chat_element(), integer(), integer()) -> {integer(), integer()}. -get_chat_time_span([], FromDate, ToDate) -> throw({no_chat_history, get_chat_time_span}); +-spec get_chat_time_span(type_chat(), integer(), integer()) -> {integer(), integer()}. +get_chat_time_span([], _FromDate, _ToDate) -> throw({no_chat_history, get_chat_time_span}); get_chat_time_span(Chat, FromDate, ToDate) -> From = case FromDate of @@ -221,14 +219,15 @@ get_chat_time_span(Chat, FromDate, ToDate) -> end, {From, To}. --spec format_msg_type(binary()) -> list(binary()). +-spec format_msg_type(<<_:8,_:_*8>>) -> [[any()] | char()]. +% Due to the fact that we have a functionl pattern matching format_msg_type(<>) -> io_lib:format("~s~s", [string:uppercase(FirstLetter), Rest]). -spec format_date(tuple(), string()) -> string(). format_date(Date, Format) -> qdate:to_string(Format, Date). --spec format_timezone(integer(), string()) -> tuple() | integer(). +-spec format_timezone(integer() | tuple(), string()) -> tuple() | integer(). format_timezone(Timestamp, TimeZone) when is_integer(Timestamp), is_list(TimeZone) -> format_timezone(roster:msToUT(Timestamp), TimeZone); format_timezone({{_, _, _}, {_, _, _}} = Date, TimeZone) -> @@ -236,4 +235,4 @@ format_timezone({{_, _, _}, {_, _, _}} = Date, TimeZone) -> {error, unknown_tz} -> throw({unknown_timezone, TimeZone}); LocalDate -> LocalDate end; -format_timezone(Timestamp, _) -> Timestamp. \ No newline at end of file +format_timezone(Timestamp, _) -> Timestamp. diff --git a/apps/roster/src/rest/rest_cri.erl b/apps/roster/src/rest/rest_cri.erl index 5ec01ce34..662d7ff48 100644 --- a/apps/roster/src/rest/rest_cri.erl +++ b/apps/roster/src/rest/rest_cri.erl @@ -7,6 +7,7 @@ -include_lib("roster/include/static/roster_text.hrl"). -include_lib("roster/include/static/roster_var.hrl"). -include_lib("roster/include/static/main_var.hrl"). +-dialyzer({nowarn_function, strict_list/1}). -export([ description/0, diff --git a/apps/roster/src/rest/rest_handler.erl b/apps/roster/src/rest/rest_handler.erl index ba8b76dcd..512c1c6be 100644 --- a/apps/roster/src/rest/rest_handler.erl +++ b/apps/roster/src/rest/rest_handler.erl @@ -59,7 +59,6 @@ handle_request(Req) -> _ -> case rest_auth_helper:authorized(Req) of false -> rest_response_helper:response(Req, ?HTTP_CODE_401, rest_response_helper:error_401()); {error, invalid_token} -> rest_response_helper:error_response_api(Req, ?HTTP_CODE_401, "Token is invalid."); - {error, token_expired} -> rest_response_helper:error_response_api(Req, ?HTTP_CODE_401, "Token is expired."); {true, api} -> handle_request2(Req:get(method), Req:get(path), Req); %% We hit here if authentication is Bearer (Not Basic) _ -> handle_request(Req:get(method), Req:get(path), Req) end @@ -82,7 +81,6 @@ handle_request(Method, Path, Req) %% NOTE! uncomment the row under to turn on call bubbles %% handle_request(_, ?RCI_BUBBLE_ENDPOINT, Req) -> rest_cri :handle_request(Req); -handle_request(Method, "/metrics" = Path, Req) -> rest_metric :handle_request(Method, Path, Req); handle_request(Method, ?MSG_PUSH_ENDPOINT = Path, Req) -> rest_push:handle_request(Method, Path, Req); handle_request(Method, ?ROOM_ENDPOINT = Path, Req) -> rest_deeplink:handle_request(Method, Path, Req); handle_request(Method, ?PUBLISH_ENDPOINT = Path, Req) -> rest_publish:handle_request(Method, Path, Req); diff --git a/apps/roster/src/rest/rest_message.erl b/apps/roster/src/rest/rest_message.erl index 265ef3644..da290c25d 100644 --- a/apps/roster/src/rest/rest_message.erl +++ b/apps/roster/src/rest/rest_message.erl @@ -19,7 +19,7 @@ handle_request('GET', #{user := Receiver}, Req) -> friend_confirm -> case rest_gw:send_p2p_message(SenderPhoneId, ReceiverPhoneId, Message) of ok -> {?HTTP_CODE_200, rest_response_helper:success_response(<<"ok_message_sent">>, <<"Message send to: ", Receiver/binary>>)}; - {error, send_message} -> {?HTTP_CODE_400, rest_response_helper:error_response(<<"error_send_message">>, <<"Error sending Message to: ", Receiver/binary>>)} + {error, permission_denied} -> {?HTTP_CODE_400, rest_response_helper:error_response(<<"error_send_message">>, <<"Error sending Message to: ", Receiver/binary>>)} end; friend_request -> {?HTTP_CODE_200, rest_response_helper:error_response(<<"ok_request_friend">>, <<"Friend request send to: ", Receiver/binary>>)}; diff --git a/apps/roster/src/rest/rest_push.erl b/apps/roster/src/rest/rest_push.erl index 21fb0cf1c..2f3b3d843 100644 --- a/apps/roster/src/rest/rest_push.erl +++ b/apps/roster/src/rest/rest_push.erl @@ -21,7 +21,7 @@ handle_request('POST', _, Req) -> #'PushService'{payload = Payload, recipients = Recipient, module = Module} = 'PushServiceRest':from_json(jsx:decode(ReqBody), #'PushService'{}), %% also server should make all values from string to binary because erlang works with binary() data PushAlert = PushType = list_to_binary(Module), - [[n2o_async:pid(system, roster_push) ! {async_push, Auth, list_to_binary(Payload), PushAlert, PushType} + [[n2o_pi:pid(system, roster_push) ! {async_push, Auth, list_to_binary(Payload), PushAlert, PushType} || Auth <- kvs:index('Auth', user_id, PhoneId)] || PhoneId <- list_elements_to_binary(Recipient)], ?HTTP_CODE_200 end, diff --git a/apps/roster/src/rest/rest_transcribe.erl b/apps/roster/src/rest/rest_transcribe.erl index dede61b15..4029f528b 100644 --- a/apps/roster/src/rest/rest_transcribe.erl +++ b/apps/roster/src/rest/rest_transcribe.erl @@ -34,9 +34,9 @@ handle_request('GET', #{room := RoomId, message := MessageId}, Req) -> send_response(Transcription, Req) catch throw:{msg_not_found, Id} -> - rest_response_helper:error_response(Req, ?HTTP_CODE_404, io_lib:format("Message with ID=~i not found", [Id])); + rest_response_helper:error_response_api(Req, ?HTTP_CODE_404, io_lib:format("Message with ID=~i not found", [Id])); _:_ -> - rest_response_helper:error_response(Req, ?HTTP_CODE_404, "Something went wrong!") + rest_response_helper:error_response_api(Req, ?HTTP_CODE_404, "Something went wrong!") end; {error, wrong_data} -> rest_response_helper:error_400_response(Req) @@ -55,9 +55,9 @@ handle_request('GET', #{user := UserId, message := MessageId}, Req) -> send_response(Transcription, Req) catch throw:{msg_not_found, Id} -> - rest_response_helper:error_response(Req, ?HTTP_CODE_404, io_lib:format("Message with ID=~i not found", [Id])); + rest_response_helper:error_response_api(Req, ?HTTP_CODE_404, io_lib:format("Message with ID=~i not found", [Id])); _:_ -> - rest_response_helper:error_response(Req, ?HTTP_CODE_404, "Something went wrong!") + rest_response_helper:error_response_api(Req, ?HTTP_CODE_404, "Something went wrong!") end; {error, wrong_data} -> rest_response_helper:error_400_response(Req) diff --git a/apps/roster/src/roster.app.src b/apps/roster/src/roster.app.src index e5ed15838..6cf6b237f 100644 --- a/apps/roster/src/roster.app.src +++ b/apps/roster/src/roster.app.src @@ -1,7 +1,29 @@ {application, roster, - [{description, "Roster Protocol"}, - {vsn, "1"}, - {registered, []}, - {applications, [kernel,stdlib,mnesia,kvs,emqttd,n2o,bpe,locus,prometheus,libphonenumber_erlang]}, - {mod, { roster, []}}, - {env, []} ]}. + [ + {description, "Roster Protocol"}, + {vsn, "1"}, + {registered, []}, + {applications, + [ + kernel, + stdlib, + mnesia, + kvs, + ibrowse, + mimerl, + enenra, + hackney, + idna, + metrics, + unicode_util_compat, + emqttd, + n2o, + bpe, + locus, + prometheus, + libphonenumber_erlang + ]}, + {mod, { roster, []}}, + {env, []} + ] +}. diff --git a/apps/roster/src/roster.erl b/apps/roster/src/roster.erl index 569a6a973..e3d0bdf5e 100644 --- a/apps/roster/src/roster.erl +++ b/apps/roster/src/roster.erl @@ -11,6 +11,7 @@ -include_lib("emqttd/include/emqttd.hrl"). -include_lib("mnesia/src/mnesia.hrl"). -compile({parse_transform, bert_validator}). +-dialyzer({nowarn_function, validate/1}). -define(BPE_SYS_CLIENT, <<"sys_bpe">>). @@ -46,6 +47,7 @@ register_acl_mod() -> atoms() -> [android, ios, contact, signup, signin, welcome]. init([]) -> {ok, {{one_for_one, 5, 10}, []}}. start(_, _) -> atoms(), catch load([]), + syn:init(), application:stop(n2o), application:start(n2o), X = try begin A = supervisor:start_link({local, roster}, roster, []), @@ -459,7 +461,7 @@ on_client_disconnected(_Reason, _Client = #mqtt_client{}, _Env) -> ok. on_disconnect(<<"emqttd_", _/binary>> = ClientId) -> info(roster_auth, "~p:CLIENT DISCONNECT",[ClientId]), case kvs:get('Auth', ClientId) of - {ok, Auth} -> n2o_async:pid(system, roster_auth) ! {disconnect, Auth}, + {ok, Auth} -> n2o_pi:pid(system, roster_auth) ! {disconnect, Auth}, kvs:put(Auth#'Auth'{last_online = now_msec()}); _ -> skip end, ok. @@ -539,7 +541,7 @@ delete_msg(PhoneId) -> update_writer(Feed,{E1,V1},{E2,V2})-> case kvs_stream:load_writer(Feed) of - #writer{cache = M}=W when M/=[]-> + #writer{cache = #'Message'{}= M}=W -> case element(E1,M)==V1 of true -> M1=erlang:setelement(E2,M,V2), kvs_stream:save(W#writer{cache = M1}); @@ -569,20 +571,26 @@ add_message(#'Message'{feed_id = Feed} = Msg) -> add_message(#'Message'{} = Msg, Reader) -> kvs_stream:save(offset_reader(#writer{cache = LMsg} = add_message(Msg), Reader)), LMsg. --spec unread_msg(#muc{} |#p2p{} |#writer{} |#error{}, - integer() | #reader{}, - integer() |binary()|#'Member'{}) -> - {binary(), #'Message'{} | update, [integer()]}. +-spec unread_msg(#muc{} | #p2p{} | #writer{} | #error{} | #'Message'{} | + {'Message', [] | integer() | #'Message'{}}, + integer() | #reader{}, + integer() | binary() | #'Member'{}) -> + {integer() | binary(), #'Message'{} | update, [integer()]}. + +%% TODO: A temporary solution unread_msg({error, _}, _, _) -> {0, [], []}; unread_msg(_, {error, _}, _) -> {0, [], []}; unread_msg(#writer{cache = #'Message'{id = MaxReadId, type = [sys|_]} = LastMsg} = Writer, #reader{cache = {'Message', ReadMsgId}, pos = 0} = Reader, #'Member'{id = UID, status = removed}) when ReadMsgId /= [], ReadMsgId >= MaxReadId -> - GetFun = - fun (_T, MaxReadId, _D) -> {ok, LastMsg#'Message'{seenby = []}}; - (T, Id, D) -> kvs:get(T, Id, D) - end, + GetFun = fun(T, Id, D) -> + case Id of + N when MaxReadId /= [], MaxReadId >= N-> + {ok, LastMsg#'Message'{seenby = []}}; + _-> kvs:get(T, Id, D) + end + end, unread_msg(Writer#writer{cache = LastMsg}, Reader#reader{cache = {'Message', MaxReadId}}, UID, GetFun); unread_msg(#writer{} = Writer, #reader{} = Reader, #'Member'{id = UID}) -> unread_msg(Writer, Reader, UID); @@ -796,7 +804,7 @@ validate(Payload, ClientId) -> [] -> ok; Res -> info(?MODULE, "validate error:~n~p", [Res]), emqttd:publish(emqttd_message:make( - ClientId, 2, action_topic(ClientId), + {ClientId,undefined}, 2, action_topic(ClientId), term_to_binary(#errors{code = [<<"666">>], data = Res}))), error end. @@ -877,8 +885,7 @@ member_lastmsg2(PhoneId, Room) -> R -> R end. add_member(#'Room'{} = R, #'Member'{} = M) -> add_member(R, M, {no_muc_message, []}). -add_member(#'Room'{} = R, #'Member'{id = MId, reader = 0, feed_id = Feed, phone_id = PhoneId, alias = Alias} = M, - {MsgPayload, HL} = Args) -> +add_member(#'Room'{} = R, #'Member'{id = MId, reader = 0, feed_id = Feed, phone_id = PhoneId, alias = Alias} = M, {MsgPayload, HL} = Args) -> case kvs:get('Roster', roster_id(PhoneId)) of {ok, #'Roster'{nick = Nick, names = Names, surnames = Surnames, avatar = Avatar}} -> Alias2 = case Alias of EmptyAlias when EmptyAlias == []; EmptyAlias == <<>> -> Nick; _ -> Alias end, @@ -895,21 +902,20 @@ add_member(#'Room'{} = R, #'Member'{id = MId, reader = 0, feed_id = Feed, phone_ {M2, Msg, Room}; #error{} -> {error, roster_not_found} %% TODO add error handler end; -add_member(#'Room'{} = R, #'Member'{feed_id = #muc{name = Room} = Feed, alias = Alias, - phone_id = Roster = #'Roster'{id = RosterId, phone = Phone, - names = Name, surnames = Surname}} = M, {MsgPayload, _}) -> - PhoneId = phone_id(Phone, RosterId), - Msg = case MsgPayload of - no_muc_message -> []; - _ -> #writer{cache = LastMsg} = add_message(#'Message'{status = [], type = [sys], feed_id = Feed, from = PhoneId, to = Room, - files = [#'Desc'{payload = MsgPayload}]}), LastMsg end, - update_rooms(Roster, R), subscribe_room(M2 = M#'Member'{phone_id = PhoneId}), - subscribe_muc(PhoneId, Feed), - {M2#'Member'{alias = member_alias(Alias, Name, Surname)}, Msg, R}; -add_member(#'Room'{} = R, #'Member'{phone_id = PhoneId} = M, Args) -> +add_member(#'Room'{} = R, #'Member'{phone_id = PhoneId, alias = Alias, feed_id = #muc{name = Room} = Feed} = M, {MsgPayload, _}) -> case kvs:get('Roster', roster_id(PhoneId)) of - {ok, Roster} -> add_member(R, M#'Member'{phone_id = Roster}, Args); - #error{} = Err -> Err end. + {ok, Roster = #'Roster'{names = Name, surnames = Surname}} -> + Msg = case MsgPayload of + no_muc_message -> []; + _ -> #writer{cache = LastMsg} = add_message(#'Message'{status = [], type = [sys], + feed_id = Feed, from = PhoneId, to = Room, files = [#'Desc'{payload = MsgPayload}]}), + LastMsg + end, + update_rooms(Roster, R), subscribe_room(M2 = M#'Member'{phone_id = PhoneId}), + subscribe_muc(PhoneId, Feed), + {M2#'Member'{alias = member_alias(Alias, Name, Surname)}, Msg, R}; + #error{} = Err -> Err + end. member_alias([], [], []) -> []; member_alias([], N, []) -> N; member_alias([], [], S) -> S; member_alias([], Name, Surname) when Name /= [], Surname /= [] -> <>/binary, Surname/binary>>; @@ -984,7 +990,7 @@ contact_readmsg(LocalPhoneId, PhoneId) -> _ -> 0 end. %% TODO need refactoring. Reader may be found by feed? update_room(#'Roster'{roomlist = Rooms} = Roster, #'Room'{status = Status} = Room)-> - kvs:put(Roster#'Roster'{roomlist = lists:keyreplace(#'Room'.id, Room)}). + kvs:put(Roster#'Roster'{roomlist = lists:keyreplace(Room#'Room'.id, #'Room'.id, Rooms, Room)}). update_rooms(#'Roster'{roomlist = Rooms} = Roster, #'Room'{status = Status} = R) -> R2 = case Status of removed -> R;_ -> R#'Room'{last_msg = []} end, @@ -1118,7 +1124,7 @@ user(#'Roster'{id = Id, phone = Phone}, {Presence, Update} = is_online2(PhoneId), Msgs = case catch p2p_readmsgs(Local, PhoneId) of {'EXIT', {Err, _}} -> - n2o:error(?MODULE,"Catch:~p~n",[n2o:stack_trace(error, Err)]), + roster:error(?MODULE,"Catch:~p~n",[{error, Err}]), throw({error, {user, Local, PhoneId}}); Ms -> Ms end, C#'Contact'{presence = Presence, update = Update, services = get_services(phone(PhoneId)), @@ -1163,7 +1169,7 @@ room(#'Roster'{id = Id, phone = Phone}, #'Room'{id = Name, last_msg = LMId, type %% = unread_msg(Rec, Reader, UID), %%TODO fix if writer is empty {ok, #'Room'{readers = Readers}} = kvs:get('Room', Name), - LastPhoneId = case LastMsg of #'Message'{from = LPhoneId} -> LPhoneId; _ -> 0 end, + #'Message'{from = LastPhoneId} = LastMsg, Membrs = lists:flatten( case muc_member(LastPhoneId, Name, presence) of #'Member'{phone_id = Local} = M -> [M]; @@ -1275,7 +1281,7 @@ sub_muc(Subscr, #'Roster'{id = RosterId, phone = Phone, userlist = Cntcts, rooml is_shared_rooms(Rooms, PId)} of {subscribe, #'Contact'{status = friend}, true} -> false; {subscribe, _, IsShared} -> IsShared; - {unsubscribe, true, _} -> true; + {unsubscribe, #'Contact'{}, _} -> true; {unsubscribe, false, false} -> true; _ -> false end]; sub_muc(Subscr, PhoneId, Members, ClientIds) -> @@ -1407,7 +1413,7 @@ norm_reader(Reader) -> Reader. is_visible_msg(#'Message'{seenby = Seen} = Msg, UID) when Seen == []; Seen == [-1]; Seen == [0] -> msg_filter(Msg, UID); -is_visible_msg(#'Message'{feed_id = #muc{name = Room} = Msg}, PhoneId) when is_binary(PhoneId)-> +is_visible_msg(#'Message'{feed_id = #muc{name = Room}} = Msg, PhoneId) when is_binary(PhoneId)-> case muc_member(PhoneId, Room) of [] -> 0; #'Member'{id = MembId} -> msg_filter(Msg, MembId) end; is_visible_msg(Msg, UID) -> msg_filter(Msg, UID). @@ -1442,12 +1448,10 @@ msg_update(Msg, UID) -> msg_filter(Msg, UID). concat(A, B) when is_integer(A), is_integer(B) -> A + B; concat(A, B) when is_list(A), is_list(B) -> A ++ B; -concat({A, MA, SA, []}, {_, _, _, _} = B) -> - concat({A, MA, SA, #'Message'{id = 0}}, B); -concat({_, _, _, _} = A, {B, MB, SB, []} = B) -> - concat(A, {B, MB, SB, #'Message'{id = 0}}); +concat({A, MA, SA, []}, {_, _, _, _} = B) -> concat({A, MA, SA, #'Message'{id = 0}}, B); +concat({_, _, _, _} = A, {B, MB, SB, []}) -> concat(A, {B, MB, SB, #'Message'{id = 0}}); concat({A, MA, StA, #'Message'{id = IdA} = MsgA}, - {B, MB, StB, #'Message'{id = IdB} = MsgB}) -> + {B, MB, StB, #'Message'{id = IdB} = MsgB}) -> {A + B, MA ++ MB, case StA of [] -> StA;_ -> StB end, case IdA > IdB of true -> MsgA;_ -> MsgB end}. @@ -1555,7 +1559,7 @@ get_data(Key, Data) -> false -> []; F -> F end. set_data(Key, Val, Data) -> case get_data(Key, Data) of - false -> Data; + [] -> Data; #'Feature'{} = F -> set_data(F#'Feature'{value = Val}, Data) end. @@ -1621,7 +1625,6 @@ get_reader(Feed, RosterId) -> %% mnesia utils backup() -> roster_db:backup(). %TODO It will be removed after update backup_script on Prod - next_key(Table, Count) -> next_key(Table, mnesia:dirty_first(Table), Count). next_key(Table, CurrentId, Count) -> @@ -1662,7 +1665,7 @@ fold(Fun, Acc, Table, Start, Finish, Driver, Direction, Count, GetFun) when Star {_, _} when Dir -> Acc2; _ -> fold(Fun, Acc2, Table, Prev, Finish, Driver, Direction, Count2) end; _ -> Acc end catch Err:Rea -> - n2o:error(?MODULE, "Catch fold2:~p~n", [n2o:stack_trace(Err, Rea)]), Acc end. + roster:error(?MODULE, "Catch fold2:~p~n", [{Err, Rea}]), Acc end. %%count(#reader{pos = P}, #writer{count = T}) -> T - P. @@ -1688,8 +1691,7 @@ mover(#reader{pos = Pos, cache = {_, Id}, dir = D} = R, T) -> true -> R; false -> case kvs_stream:drop(R#reader{args = 2}) of #reader{pos = Pos} = NR -> NR; - #reader{} = NR -> mover(NR, T); - E -> E + #reader{} = NR -> mover(NR, T) end end. @@ -1893,7 +1895,7 @@ merge_data(Index, Data, OldData) -> sync_indexes() -> lists:map(fun sync_indexes/1, tables()). sync_indexes(#table{name = Table, keys = Keys}) -> - mnesia:wait_for_tables(Table, 10000), + mnesia:wait_for_tables([Table], 10000), #cstruct{attributes = Attrs} = mnesia:table_info(Table, cstruct), Indexes = mnesia:table_info(Table, index), IndexedKeys = [lists:nth(I-1, Attrs)|| I <- Indexes], @@ -1948,13 +1950,14 @@ add_fake_number(PhoneNumber) when is_binary(PhoneNumber) -> end. %% TEST API -check(Module) -> case lists:all(fun(X) -> X == ok end, Module:suite()) of - true -> roster:info("ALL TESTS PASSED", []), true; - false -> roster:info("TEST ERRORS", []), false end. - +check(Module) -> + case lists:all(fun(X) -> X == ok end, Module:suite()) of + true -> roster:info("ALL TESTS PASSED", []), true; + false -> roster:info("TEST ERRORS", []), false + end. n2o_pid(Name) -> - case n2o_async:pid(system, Name) of + case n2o_pi:pid(system, Name) of Pid when is_pid(Pid) -> case process_info(Pid) of undefined -> @@ -1971,22 +1974,22 @@ restart_module(M) -> restart_module(Pid,M) when is_pid(Pid)-> case process_info(Pid) of undefined -> - n2o_async:pid(system, roster_profile) ! {restart, M}; + n2o_pi:pid(system, roster_profile) ! {restart, M}; _ -> Pid end; restart_module(Class,Name) -> - H=case n2o_async:pid(Class,Name) of + H=case n2o_pi:pid(Class,Name) of Pid when is_pid(Pid) -> - #handler{group=Group} = Async=case process_info(Pid) of - undefined -> #handler{module = Name, class = Class, group = roster, name = Name, state = []}; - _ -> n2o_async:send(Pid,{get}) + #pi{sup=Group} = Async=case process_info(Pid) of + undefined -> #pi{module = Name, table = Class, sup = roster, name = Name, state = []}; + _ -> n2o_pi:send(Pid,{get}) end, [ supervisor:F(Group,{Class,Name}) || F <- [ terminate_child , delete_child ] ], n2o:cache(Class,{Class,Name},undefined), Async; - _ -> #handler{module = Name, class = Class, group = roster, name = Name, state = []} + _ -> #pi{module = Name, table = Class, sup = roster, name = Name, state = []} end, - {NPid,_}=n2o_async:start(H), NPid. + {NPid,_}=n2o_pi:start(H), NPid. wait_for(Fun) -> diff --git a/apps/roster/src/roster_channel_helper.erl b/apps/roster/src/roster_channel_helper.erl index c51cf8283..177aa2e2c 100644 --- a/apps/roster/src/roster_channel_helper.erl +++ b/apps/roster/src/roster_channel_helper.erl @@ -111,7 +111,7 @@ check_user_permissions(ChannelId, ClientId, PermissionKey) -> [] -> ResponseSuccess; _ -> %% check admin permission list - case lists:keyfind(PermissionKey, #'Feature'.key, PermList) of + case lists:keyfind(PermissionKey, #'Feature'.key, PermList) of %% TODO: "true ?" investigate ! #'Feature'{value = true} -> ResponseSuccess; _ -> ResponseError end @@ -134,8 +134,12 @@ add_members(#'Room'{id = ChannelId, readers = ChannelReaders} = Channel, Members case MemberStatus of removed -> PrePatchedMember = roster:patch_member(ExistingMember#'Member'{status = member}, ExistingMember), - {PatchedMember, _, _} = roster:add_member(Channel, PrePatchedMember, {no_muc_message, ChannelReaders}), - kvs:put(PatchedMember); + case roster:add_member(Channel, PrePatchedMember, {no_muc_message, ChannelReaders}) of + {PatchedMember = #'Member'{}, _, _} -> kvs:put(PatchedMember); + {error,_} -> skip + % when ErrCode == duplicated; + % ErrCode == not_found; ErrCode == roster_not_found + end; _ -> skip end end diff --git a/apps/roster/src/roster_client.erl b/apps/roster/src/roster_client.erl index 3a9970019..8f1ccde09 100644 --- a/apps/roster/src/roster_client.erl +++ b/apps/roster/src/roster_client.erl @@ -18,7 +18,7 @@ start_client(ClientId, Token, Opts) -> receive_drop(), stop_client(ClientId), Username = proplists:get_value(username, Opts, <<"api">>), - n2o_async:start(#handler{module = ?MODULE, class = system, group = roster, + n2o_pi:start(#pi{module = ?MODULE, table = system, sup = roster, state = #state{mqtt_opts = [{password, Token}|Opts ++ ?DEFAULT_MQTTC_OPTS], username = Username, receive_pid = self()}, name = ClientId}), init = receive_test(ClientId, init), ok. @@ -33,13 +33,13 @@ start_cli_receive(ClientId, Token, Counter, Opts) -> start_client(ClientId, Toke stop_client(ClientIds) when is_list(ClientIds) -> [stop_client(ClientId) || ClientId <- ClientIds], ok; stop_client(ClientId) -> - case n2o_async:pid(system, ClientId) of + case n2o_pi:pid(system, ClientId) of Pid when is_pid(Pid) -> case process_info(Pid) of undefined -> catch [supervisor:F(roster, {system, ClientId}) || F <- [terminate_child, delete_child]], n2o:cache(system, {system, ClientId}, undefined), ok; - _ -> n2o_async:stop(system, ClientId), ok end; _ -> ok end. + _ -> n2o_pi:stop(system, ClientId), ok end; _ -> ok end. receive_drop() -> receive _ -> receive_drop() after ?DRP_TMOUT -> skip end. @@ -62,48 +62,48 @@ filter_friend(Term, State) -> Status == ban;Status == unban;Status == banned;Status == friend;Status == update -> send; {_, Res} -> Res end. -proc(#mqttc{}, #handler{} = H) -> {reply, [], H}; -proc(init, #handler{name = ?SYS_REST_CLIENT, state = #state{receive_pid = Self} = State} = Async) -> +proc(#mqttc{}, #pi{} = H) -> {reply, [], H}; +proc(init, #pi{name = ?SYS_REST_CLIENT, state = #state{receive_pid = Self} = State} = Async) -> {ok, C} = application:get_env(rest, rest_pid), Self ! init, - {ok, Async#handler{state = State#state{mqttc = C, client_id = ?SYS_REST_CLIENT}, seq = 0}}; -proc(init, #handler{name = ?SYS_BRIDGE_TEST_CLIENT, state = #state{receive_pid = Self} = State} = Async) -> + {ok, Async#pi{state = State#state{mqttc = C, client_id = ?SYS_REST_CLIENT}}}; +proc(init, #pi{name = ?SYS_BRIDGE_TEST_CLIENT, state = #state{receive_pid = Self} = State} = Async) -> {ok, C} = emqttc:start_link([{client_id, ?SYS_BRIDGE_TEST_CLIENT}, {logger, {console, error}}, {reconnect, 5}]), roster:info(?MODULE, "MICRO BRIDGE SIMULATOR PROC started", []), register(sys_bridge, C), Self ! init, - {ok, Async#handler{state = State#state{mqttc = whereis(sys_bridge), client_id = ?SYS_BRIDGE_TEST_CLIENT}, seq = 0}}; -proc(init, #handler{name = ClientId, state = #state{mqtt_opts = Opts, receive_pid = Self, username = Username} = State} = Async) -> + {ok, Async#pi{state = State#state{mqttc = whereis(sys_bridge), client_id = ?SYS_BRIDGE_TEST_CLIENT}}}; +proc(init, #pi{name = ClientId, state = #state{mqtt_opts = Opts, receive_pid = Self, username = Username} = State} = Async) -> roster:info(?MODULE, "ClientInit:~p\r", [ClientId]), {ok, C} = emqttc:start_link([{client_id, ClientId}, {clean_sess, false}, {logger, {console, error}}, {username, Username}, {reconnect, 5}] ++ Opts), Self ! init, - {ok, Async#handler{state = State#state{mqttc = C, client_id = ClientId}, seq = 0}}; + {ok, Async#pi{state = State#state{mqttc = C, client_id = ClientId}}}; -proc({filter, Filter}, #handler{state = #state{receive_pid = Self} = State} = H) -> +proc({filter, Filter}, #pi{state = #state{receive_pid = Self} = State} = H) -> Self ! ok, - {reply, [], H#handler{state = State#state{filter = Filter}}}; + {reply, [], H#pi{state = State#state{filter = Filter}}}; -proc(last_res, #handler{state = #state{receive_pid = Self, last_res = LastRes} = State} = H) -> +proc(last_res, #pi{state = #state{receive_pid = Self, last_res = LastRes} = State} = H) -> Self ! lists:ukeysort(1, LastRes), - {reply, [], H#handler{state = State#state{last_res = []}}}; -proc(unsort_last_res, #handler{state = #state{receive_pid = Self, last_res = LastRes} = State} = H) -> + {reply, [], H#pi{state = State#state{last_res = []}}}; +proc(unsort_last_res, #pi{state = #state{receive_pid = Self, last_res = LastRes} = State} = H) -> Self ! LastRes, - {reply, [], H#handler{state = State#state{last_res = []}}}; -proc({publish, _, BinTerm}, #handler{state = #state{receive_pid = Self, last_res = LastRes, filter = FilterFun} = State} = H) -> + {reply, [], H#pi{state = State#state{last_res = []}}}; +proc({publish, _, BinTerm}, #pi{state = #state{receive_pid = Self, last_res = LastRes, filter = FilterFun} = State} = H) -> case ?MODULE:FilterFun(Term = binary_to_term(BinTerm), State) of send -> write_log([Term]), Self ! Term; _ -> skip end, - {reply, [], H#'handler'{state = State#state{last_res = [Term | LastRes]}}}; -proc(_Term, #handler{state = #state{mqttc = {error, _} = Err}} = H) -> + {reply, [], H#pi{state = State#state{last_res = [Term | LastRes]}}}; +proc(_Term, #pi{state = #state{mqttc = {error, _} = Err}} = H) -> roster:info("mqttc error: ~p", [Err]), {reply, [], H}; -proc({callback, CallbackFun}, #handler{state = State} = H) -> +proc({callback, CallbackFun}, #pi{state = State} = H) -> State2 = CallbackFun(State), - {reply, [], H#handler{state = State2}}; -proc(Term, #handler{state = #state{mqttc = C}} = H) -> + {reply, [], H#pi{state = State2}}; +proc(Term, #pi{state = #state{mqttc = C}} = H) -> roster:send_event(C, <<>>, <<>>, Term), {reply, [], H}. @@ -206,7 +206,7 @@ wait_for_last_res(ClientId, Count) -> Res -> Res end. send(ClientId, Term) -> write_log([Term]), - n2o_async:send(system, ClientId, Term), timer:sleep(50). + n2o_pi:send(system, ClientId, Term), timer:sleep(50). send_last(ClientId, ResultLen) -> send_last(ClientId, ResultLen, [], 5, 100). diff --git a/apps/roster/src/roster_data.erl b/apps/roster/src/roster_data.erl index a03632729..6022c9c35 100644 --- a/apps/roster/src/roster_data.erl +++ b/apps/roster/src/roster_data.erl @@ -131,7 +131,7 @@ friend_test_rand(N) when is_integer(N) -> friend_test_rand(RosterIds) -> try Rosters = [case R of #'Roster'{} -> R; _-> element(2, kvs:get('Roster', R)) end||R<-RosterIds], - Counter = length(Rosters), +%% Counter = length(Rosters), %% Data = [{APhoneId, AClientId, AToken}, {BPhoneId, BClientId, BToken}] = start_rosters(Rosters), [APhoneId, BPhoneId] = [roster:phone_id(P, RosterId)||#'Roster'{phone = P, id = RosterId}<-Rosters], roster_client:test_info(roster_friend, #'Friend'{phone_id = APhoneId, friend_id = BPhoneId, status = request}, roster:phone(APhoneId)), @@ -143,7 +143,7 @@ friend_test_rand(RosterIds) -> %% roster_client:set_filer([AClientId, BClientId], filter), %% lists:map(fun roster_client:stop_client/1, ClientIds), ok catch Err:Rea -> - n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]), ok + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]), ok end. get_roster_ids() -> @@ -190,7 +190,7 @@ create_room(RosterIds, Room, PageMembCount, Type) -> [roster_client:test_info(roster_room, #'Room'{status = add, id = Room, members = Mmbrs}, AdmPhone)|| Mmbrs <-Mmbrs2, Mmbrs /= []] %% roster_client:stop_client(AClientId) catch Err:Rea -> - n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]) + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]) end, Room. create_channel() -> diff --git a/apps/roster/src/roster_db.erl b/apps/roster/src/roster_db.erl index 3ec8f2b36..afcbd1995 100644 --- a/apps/roster/src/roster_db.erl +++ b/apps/roster/src/roster_db.erl @@ -1,4 +1,5 @@ -module(roster_db). +-dialyzer({nowarn_function, [fold/5,get_room_stats/1,bin_to_atom_type_msg/0,fix_msg/1,fix_jobs/0]}). -compile(export_all). -include("roster.hrl"). @@ -53,7 +54,7 @@ fix_empty_desc_ids() -> find_invalid_rooms(Id) when is_integer(Id) -> find_invalid_rooms(Id, []). find_invalid_rooms(#'Roster'{roomlist = Rooms} = Roster, N) -> lists:flatten([case catch roster:room(Roster, R2) of - {'EXIT', _} -> false = R2; + {'EXIT', _} -> throw(R2); Room -> Room end || R2 = #'Room'{} <- case N of [] -> Rooms;_ -> roster:last_rooms(Rooms, 100) end]); @@ -450,7 +451,7 @@ fix_msgs() -> upd_msgs(fix_msg). fix_jobs() -> [opt_put(J#'Job'{settings = case S of #'Feature'{} -> [S]; _-> S end}, J) - || J = #'Job'{settings = S}<-kvs:all('Job')], ok. + || J = #'Job'{settings = S }<-kvs:all('Job')], ok. find_msg_by_text(Text) when is_binary(Text) -> [M||M=#'Message'{files = Descs}<-kvs:all('Message'), #'Desc'{mime = <<"text">>, payload = <>} <- Descs]; @@ -615,11 +616,11 @@ restore(File, Node, SkipTbs) -> case mnesia:restore(File, [{skip_tables, SkipTbs}]) of {aborted, {no_exists, Tab}} -> restore(File, Node, [Tab | SkipTbs]); {aborted, Reason} -> roster:info(?MODULE, "aborted backup restore from ~s by reason ~p", [File, Reason]), - {error, Reason}; + {error, Reason}; {atomic, Tabs} -> application:start(bpe), - roster:restart_module(roster_bpe), - {ok, Tabs}; - E -> E end. + roster:restart_module(roster_bpe), + {ok, Tabs} +end. remigrate_default_contact_settings() -> kvs:delete(schema_migrations, 20181008144317), diff --git a/apps/roster/src/roster_export.erl b/apps/roster/src/roster_export.erl deleted file mode 100644 index 926c11ec8..000000000 --- a/apps/roster/src/roster_export.erl +++ /dev/null @@ -1,37 +0,0 @@ --module(roster_export). --include("roster.hrl"). --include("micro.hrl"). - --compile(export_all). --compile({parse_transform, exprecs}). --export_records(['Profile', 'Roster', 'Service', 'Feature', - 'Contact', 'Room', 'ExtendedStar', 'Tag', - 'Desc', 'Star', 'Message', p2p, muc, 'Member', 'LinkRoster', 'LinkProfile']). - -to_file(Table, File) -> - file:write_file(File, to_json(Table)). - -json(Rec, Acc) -> Acc++[to_json(Rec)]. - -to_json(Table, Fun, Acc) when is_atom(Table) -> - iolist_to_binary(mochijson2:encode(roster_db:fold(Fun, Acc, Table))). -to_json(Table, Id) -> - case kvs:get(Table, Id) of {ok, Rec} -> to_json(Rec); Err -> Err end. -to_json(#'Roster'{surnames = [_|_] = Surname} = R) -> - to_json(R#'Roster'{surnames = iolist_to_binary(Surname)}); -to_json(#'Roster'{names = [_|_] = Name} = R) -> - to_json(R#'Roster'{names = iolist_to_binary(Name)}); -to_json(#'Roster'{nick = [_|_] = Nick} = R) -> - to_json(R#'Roster'{nick = iolist_to_binary(Nick)}); -to_json(#'Roster'{favorite = [_|_]} = R) -> - to_json(R#'Roster'{favorite = []}); -to_json(#'LinkProfile'{id = <<_:128>> = Id} = LP) -> - to_json(LP#'LinkProfile'{id = micro:norm_uuid(Id)}); -to_json(#'LinkRoster'{id = <<_:128>> = Id} = LP) -> - to_json(LP#'LinkRoster'{id = micro:norm_uuid(Id)}); -to_json(Table) when is_atom(Table) -> - to_json(Table, fun json/2, []); -to_json(Rec) when is_tuple(Rec), is_atom(element(1, Rec)) -> - json_rec:to_json(Rec, ?MODULE). - - diff --git a/apps/roster/src/roster_validator.erl b/apps/roster/src/roster_validator.erl deleted file mode 100644 index ea5d1c818..000000000 --- a/apps/roster/src/roster_validator.erl +++ /dev/null @@ -1,982 +0,0 @@ --module(roster_validator). --include_lib("bpe/include/bpe.hrl"). --include_lib("emqttd/include/emqttd.hrl"). --include_lib("kvs/include/feed.hrl"). --include_lib("kvs/include/group.hrl"). --include_lib("kvs/include/kvs.hrl"). --include_lib("kvs/include/metainfo.hrl"). --include_lib("kvs/include/user.hrl"). --include_lib("n2o/include/n2o.hrl"). --include_lib("roster/include/roster.hrl"). --include_lib("roster/include/static_auth.hrl"). --compile(export_all). - -custom_validate(_Obj) -> []. -validate(Obj) -> validate(Obj, [], application:get_env(bert, custom_validate, {?MODULE, custom_validate})). -validate(Obj, Acc, _) when is_atom(Obj) -> Acc; -validate(Obj, Acc, _) when is_integer(Obj) -> Acc; -validate(Obj, Acc, _) when is_binary(Obj) -> Acc; - -validate(D = #'writer'{id = Id, count = Count, cache = Cache, args = Args, first = First}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - {cache,_} when Cache==[] orelse is_tuple(Cache) -> Acc2; - {args,_} -> Acc2; - {first,_} when First==[] orelse is_tuple(First) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'writer'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'reader'{id = Id, pos = Pos, cache = Cache, args = Args, feed = Feed, dir = Dir}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} -> Acc2; - {pos,_} when Pos==[] orelse is_integer(Pos) -> Acc2; - {cache,_} when Cache==[] orelse is_integer(Cache) -> Acc2; - {args,_} -> Acc2; - {feed,_} -> Acc2; - {dir,_} when Dir==0 orelse Dir==1 -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'reader'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'cur'{id = Id, top = Top, bot = Bot, dir = Dir, reader = Reader, writer = Writer, args = Args}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {bot,_} when Bot==[] orelse is_integer(Bot) -> Acc2; - {dir,_} when Dir==0 orelse Dir==1 -> Acc2; - {reader,_} when Reader==[] orelse is_tuple(Reader) -> Acc2; - {writer,_} when Writer==[] orelse is_tuple(Writer) -> Acc2; - {args,_} when is_list(Args) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) orelse is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{args, D}|Acc3] end, Acc2, Args); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'cur'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'iter'{id = Id, container = Container, feed = Feed, next = Next, prev = Prev}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed,_} -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'iter'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'container'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'container'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'iterator'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'iterator'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'log'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'log'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'operation'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'operation'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'feed'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'feed'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'task'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'task'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'userTask'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'userTask'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'serviceTask'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'serviceTask'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'receiveTask'{name = Name, module = Module, prompt = Prompt, roles = Roles}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {roles,_} when is_binary(Roles) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'receiveTask'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'messageEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when is_binary(Payload) -> Acc2; - {timeout,_} when is_tuple(Timeout) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'messageEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'boundaryEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout, timeDate = TimeDate, timeDuration = TimeDuration, timeCycle = TimeCycle}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when is_binary(Payload) -> Acc2; - {timeout,_} when is_tuple(Timeout) -> Acc2; - {timeDate,_} when is_binary(TimeDate) -> Acc2; - {timeDuration,_} when is_binary(TimeDuration) -> Acc2; - {timeCycle,_} when is_binary(TimeCycle) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'boundaryEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'timeoutEvent'{name = Name, module = Module, prompt = Prompt, payload = Payload, timeout = Timeout, timeDate = TimeDate, timeDuration = TimeDuration, timeCycle = TimeCycle}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - {timeout,_} when Timeout==[] orelse is_tuple(Timeout) -> Acc2; - {timeDate,_} when TimeDate==[] orelse is_binary(TimeDate) -> Acc2; - {timeDuration,_} when TimeDuration==[] orelse is_binary(TimeDuration) -> Acc2; - {timeCycle,_} when TimeCycle==[] orelse is_binary(TimeCycle) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'timeoutEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'beginEvent'{name = Name, module = Module, prompt = Prompt}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'beginEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'endEvent'{name = Name, module = Module, prompt = Prompt}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_atom(Name) -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {prompt,_} when is_list(Prompt) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{prompt, D}|Acc3] end, Acc2, Prompt); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'endEvent'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'sequenceFlow'{source = Source, target = Target}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {source,_} when Source==[] orelse is_atom(Source) -> Acc2; - {target,_} when Target==[] orelse is_atom(Target) orelse is_list(Target) -> - lists:foldl(fun(Tmp, Acc3) when is_atom(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{target, D}|Acc3] end, Acc2, Target); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'sequenceFlow'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'hist'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, name = Name, task = Task, docs = Docs, time = Time}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {task,_} when is_atom(Task) -> Acc2; - {docs,_} when is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - {time,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'hist'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'process'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, name = Name, roles = Roles, tasks = Tasks, events = Events, hist = Hist, flows = Flows, rules = Rules, docs = Docs, options = Options, task = Task, timer = Timer, notifications = Notifications, result = Result, started = Started, beginEvent = BeginEvent, endEvent = EndEvent}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {roles,_} when is_list(Roles) -> []; - {tasks,_} when is_list(Tasks) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'task') orelse is_record(Tmp,'serviceTask') orelse is_record(Tmp,'userTask') orelse is_record(Tmp,'receiveTask') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{tasks, D}|Acc3] end, Acc2, Tasks); - {events,_} when is_list(Events) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'messageEvent') orelse is_record(Tmp,'boundaryEvent') orelse is_record(Tmp,'timeoutEvent') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{events, D}|Acc3] end, Acc2, Events); - - {flows,_} when is_list(Flows) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'sequenceFlow') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{flows, D}|Acc3] end, Acc2, Flows); - - {docs,_} when is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - {options,_} -> Acc2; - {task,_} when Task==[] orelse is_atom(Task) -> Acc2; - {timer,_} when Timer==[] orelse is_binary(Timer) -> Acc2; - {notifications,_} when Notifications==[] orelse true -> Acc2; - {result,_} when Result==[] orelse is_binary(Result) -> Acc2; - {started,_} when Started==[] orelse is_tuple(Started) -> Acc2; - {beginEvent,_} when BeginEvent==[] orelse is_atom(BeginEvent) -> Acc2; - {endEvent,_} when EndEvent==[] orelse is_atom(EndEvent) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'process'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'complete'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'complete'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'proc'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'proc'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'load'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'load'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'histo'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'histo'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'create'{proc = Proc, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {proc,_} when Proc==[] orelse is_record(Proc,'process') orelse is_binary(Proc) -> Acc2; - {docs,_} when Docs==[] orelse is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'create'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'amend'{id = Id, docs = Docs}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {docs,_} when Docs==[] orelse is_list(Docs) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{docs, D}|Acc3] end, Acc2, Docs); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'amend'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'chain'{id = Id, top = Top, rear = Rear, count = Count}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {top,_} when Top==[] orelse is_integer(Top) -> Acc2; - {rear,_} when Rear==[] orelse is_integer(Rear) -> Acc2; - {count,_} when is_integer(Count) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'chain'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'push'{model = Model, type = Type, title = Title, alert = Alert, badge = Badge, sound = Sound}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {model,_} when Model==[] orelse true -> Acc2; - {type,_} when Type==[] orelse is_binary(Type) -> Acc2; - {title,_} when Title==[] orelse is_binary(Title) -> Acc2; - {alert,_} when Alert==[] orelse is_binary(Alert) -> Acc2; - {badge,_} when Badge==[] orelse is_integer(Badge) -> Acc2; - {sound,_} when Sound==[] orelse is_binary(Sound) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'push'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Search'{id = Id, ref = Ref, field = Field, type = Type, value = Value, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when is_integer(Id) orelse is_binary(Id) -> Acc2; - {ref,_} when is_binary(Ref) -> Acc2; - {field,_} when is_binary(Field) -> Acc2; - {type,_} when Type=='==' orelse Type=='!=' orelse Type=='like' -> Acc2; - {value,_} when is_list(Value) -> - lists:foldl(fun(Tmp, Acc3) when true orelse is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{value, D}|Acc3] end, Acc2, Value); - {status,_} when Status=='profile' orelse Status=='roster' orelse Status=='contact' orelse Status=='member' orelse Status=='room' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Search'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'p2p'{from = From, to = To}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {from,_} when is_binary(From) -> Acc2; - {to,_} when is_binary(To) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'p2p'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'muc'{name = Name}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when is_binary(Name) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'muc'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqi'{feed_id = Feed_id, query = Query, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {feed_id, #'muc'{}} -> Acc2; - {query,_} when Query==[] orelse is_binary(Query) -> Acc2; - {status,_} when Status==[] orelse Status=='admin' orelse Status=='member' orelse Status=='removed' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqi'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Feature'{id = Id, key = Key, value = Value, group = Group}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {key,_} when is_binary(Key) -> Acc2; - {value,_} when is_binary(Value) -> Acc2; - {group,_} when is_binary(Group) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Feature'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Service'{id = Id, type = Type, data = Data, login = Login, password = Password, expiration = Expiration, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {type,_} when Type=='email' orelse Type=='vox' orelse Type=='aws' orelse Type=='wallet' -> Acc2; - {data,_} -> Acc2; - {login,_} when Login==[] orelse is_binary(Login) -> Acc2; - {password,_} when Password==[] orelse is_binary(Password) -> Acc2; - {expiration,_} when Expiration==[] orelse is_integer(Expiration) -> Acc2; - {status,_} when Status==[] orelse Status=='verified' orelse Status=='added' orelse Status=='add' orelse Status=='remove' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Service'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Member'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, phone_id = Phone_id, avatar = Avatar, names = Names, surnames = Surnames, alias = Alias, reader = Reader, update = Update, settings = Settings, services = Services, presence = Presence, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when Container=='chain' orelse Container=='cur' orelse Container==[] -> Acc2; - {feed_id,_} when is_record(Feed_id,'muc') orelse is_record(Feed_id,'p2p') orelse Feed_id==[] -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {phone_id,_} when Phone_id==[] orelse is_binary(Phone_id) -> Acc2; - {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; - {names,_} when Names==[] orelse is_binary(Names) -> Acc2; - {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; - {alias,_} when Alias==[] orelse is_binary(Alias) -> Acc2; - {reader,_} when Reader==[] orelse is_integer(Reader) -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {services,_} when Services==[] orelse is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {presence,_} when Presence==[] orelse Presence=='online' orelse Presence=='offline' -> Acc2; - {status,_} when Status==[] orelse Status=='admin' orelse Status=='member' orelse Status=='removed' orelse Status=='patch' orelse Status=='owner' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Member'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Desc'{id = Id, mime = Mime, payload = Payload, parentid = Parentid, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {mime,_} when Mime==[] orelse is_binary(Mime) -> Acc2; - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - {parentid,_} when Parentid==[] orelse is_binary(Parentid) -> Acc2; - {data,_} when is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Desc'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'StickerPack'{id = Id, name = Name, keywords = Keywords, description = Description, author = Author, stickers = Stickers, created = Created, updated = Updated, downloaded = Downloaded}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {keywords,_} when is_list(Keywords) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{keywords, D}|Acc3] end, Acc2, Keywords); - {description,_} when Description==[] orelse is_binary(Description) -> Acc2; - {author,_} when Author==[] orelse is_binary(Author) -> Acc2; - {stickers,_} when is_list(Stickers) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Desc') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{stickers, D}|Acc3] end, Acc2, Stickers); - {created,_} when is_integer(Created) -> Acc2; - {updated,_} when is_integer(Updated) -> Acc2; - {downloaded,_} when is_integer(Downloaded) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'StickerPack'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Message'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, msg_id = Msg_id, from = From, to = To, created = Created, files = Files, type = Type, link = Link, seenby = Seenby, repliedby = Repliedby, mentioned = Mentioned, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when Container=='chain' orelse Container=='cur' orelse Container==[] -> Acc2; - {feed_id,_} when is_record(Feed_id,'muc') orelse is_record(Feed_id,'p2p') -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {msg_id,_} when Msg_id==[] orelse is_binary(Msg_id) -> Acc2; - {from,_} when From==[] orelse is_binary(From) -> Acc2; - {to,_} when To==[] orelse is_binary(To) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {files,_} when is_list(Files) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Desc') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{files, D}|Acc3] end, Acc2, Files); - {type,_} when is_list(Type) -> - lists:foldl(fun(Tmp, Acc3) when Tmp=='sys' orelse Tmp=='reply' orelse Tmp=='forward' orelse Tmp=='read' orelse Tmp=='edited' orelse Tmp=='cursor' orelse Tmp=='draft' -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{type, D}|Acc3] end, Acc2, Type); - {link,_} when Link==[] orelse is_integer(Link) orelse is_record(Link,'Message') -> Acc2; - {seenby,_} when Seenby==[] orelse is_list(Seenby) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) orelse is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{seenby, D}|Acc3] end, Acc2, Seenby); - {repliedby,_} when Repliedby==[] orelse is_list(Repliedby) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{repliedby, D}|Acc3] end, Acc2, Repliedby); - {mentioned,_} when Mentioned==[] orelse is_list(Mentioned) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{mentioned, D}|Acc3] end, Acc2, Mentioned); - {status,_} when Status==[] orelse Status=='async' orelse Status=='delete' orelse Status=='clear' orelse Status=='update' orelse Status=='edit' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Message'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Link'{id = Id, name = Name, room_id = Room_id, created = Created, type = Type, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {room_id,_} when Room_id==[] orelse is_binary(Room_id) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {type,_} when Type==[] orelse Type=='group' orelse Type=='channel' -> Acc2; - {status,_} when Status==[] orelse Status=='gen' orelse Status=='check' orelse Status=='add' orelse Status=='get' orelse Status=='join' orelse Status=='update' orelse Status=='delete' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Link'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Room'{id = Id, name = Name, links = Links, description = Description, settings = Settings, members = Members, admins = Admins, data = Data, type = Type, tos = Tos, tos_update = Tos_update, unread = Unread, mentions = Mentions, readers = Readers, last_msg = Last_msg, update = Update, created = Created, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {links,_} when Links==[] orelse is_list(Links) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Link') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{links, D}|Acc3] end, Acc2, Links); - {description,_} when Description==[] orelse is_binary(Description) -> Acc2; - {settings,_} when is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {members,_} when is_list(Members) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Member') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{members, D}|Acc3] end, Acc2, Members); - {admins,_} when is_list(Admins) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Member') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{admins, D}|Acc3] end, Acc2, Admins); - {data,_} when is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Desc') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {type,_} when Type==[] orelse Type=='group' orelse Type=='channel' orelse Type=='call' -> Acc2; - {tos,_} when Tos==[] orelse is_binary(Tos) -> Acc2; - {tos_update,_} when Tos_update==[] orelse is_integer(Tos_update) -> Acc2; - {unread,_} when Unread==[] orelse is_integer(Unread) -> Acc2; - {mentions,_} when is_list(Mentions) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{mentions, D}|Acc3] end, Acc2, Mentions); - {readers,_} when is_list(Readers) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{readers, D}|Acc3] end, Acc2, Readers); - {last_msg,_} when Last_msg==[] orelse is_integer(Last_msg) orelse is_record(Last_msg,'Message') -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {status,_} when Status==[] orelse Status=='create' orelse Status=='leave' orelse Status=='add' orelse Status=='remove' orelse Status=='removed' orelse Status=='join' orelse Status=='joined' orelse Status=='info' orelse Status=='patch' orelse Status=='get' orelse Status=='delete' orelse Status=='last_msg' orelse Status=='mute' orelse Status=='unmute' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Room'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Tag'{roster_id = Roster_id, name = Name, color = Color, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {roster_id,_} when Roster_id==[] orelse is_binary(Roster_id) -> Acc2; - {name,_} when is_binary(Name) -> Acc2; - {color,_} when is_binary(Color) -> Acc2; - {status,_} when Status==[] orelse Status=='create' orelse Status=='remove' orelse Status=='edit' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Tag'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Star'{id = Id, client_id = Client_id, roster_id = Roster_id, message = Message, tags = Tags, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {client_id,_} when Client_id==[] orelse is_binary(Client_id) -> Acc2; - {roster_id,_} when Roster_id==[] orelse is_integer(Roster_id) -> Acc2; - {message,_} when Message==[] orelse is_record(Message,'Message') -> Acc2; - {tags,_} when is_list(Tags) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Tag') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{tags, D}|Acc3] end, Acc2, Tags); - {status,_} when Status==[] orelse Status=='add' orelse Status=='remove' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Star'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Typing'{phone_id = Phone_id, comments = Comments}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone_id,_} when is_binary(Phone_id) -> Acc2; - {comments,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Typing'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Contact'{phone_id = Phone_id, avatar = Avatar, names = Names, surnames = Surnames, nick = Nick, reader = Reader, unread = Unread, last_msg = Last_msg, update = Update, created = Created, settings = Settings, services = Services, presence = Presence, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone_id,_} when Phone_id==[] orelse is_binary(Phone_id) -> Acc2; - {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; - {names,_} when Names==[] orelse is_binary(Names) -> Acc2; - {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; - {nick,_} when Nick==[] orelse is_binary(Nick) -> Acc2; - {reader,_} when Reader==[] orelse is_integer(Reader) orelse is_list(Reader) -> - lists:foldl(fun(Tmp, Acc3) when is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{reader, D}|Acc3] end, Acc2, Reader); - {unread,_} when Unread==[] orelse is_integer(Unread) -> Acc2; - {last_msg,_} when Last_msg==[] orelse is_record(Last_msg,'Message') -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {settings,_} when is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {services,_} when is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {presence,_} when Presence==[] orelse Presence=='online' orelse Presence=='offline' orelse is_binary(Presence) -> Acc2; - {status,_} when Status==[] orelse Status=='request' orelse Status=='authorization' orelse Status=='ignore' orelse Status=='internal' orelse Status=='friend' orelse Status=='last_msg' orelse Status=='ban' orelse Status=='banned' orelse Status=='deleted' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Contact'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'ExtendedStar'{star = Star, from = From}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {star,_} when is_record(Star,'Star') orelse Star==[] -> Acc2; - {from,_} when is_record(From,'Contact') orelse is_record(From,'Room') orelse From==[] -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'ExtendedStar'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Auth'{client_id = Client_id, dev_key = Dev_key, user_id = User_id, phone = Phone, token = Token, type = Type, sms_code = Sms_code, attempts = Attempts, services = Services, settings = Settings, push = Push, os = Os, created = Created, last_online = Last_online}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {client_id,_} when Client_id==[] orelse is_binary(Client_id) -> Acc2; - {dev_key,_} when Dev_key==[] orelse is_binary(Dev_key) -> Acc2; - {user_id,_} when User_id==[] orelse is_binary(User_id) -> Acc2; - {phone,_} when Phone==[] orelse is_binary(Phone) orelse is_tuple(Phone) -> Acc2; - {token,_} when Token==[] orelse is_binary(Token) -> Acc2; - {type,_} when Type==[] orelse is_atom(Type) -> Acc2; - {sms_code,_} when Sms_code==[] orelse is_binary(Sms_code) -> Acc2; - {attempts,_} when Attempts==[] orelse is_integer(Attempts) -> Acc2; - {services,_} when is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {push,_} when Push==[] orelse is_binary(Push) -> Acc2; - {os,_} when Os==[] orelse Os=='ios' orelse Os=='android' orelse Os=='web' -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - {last_online,_} when Last_online==[] orelse is_integer(Last_online) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Auth'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Roster'{id = Id, names = Names, surnames = Surnames, email = Email, nick = Nick, userlist = Userlist, roomlist = Roomlist, favorite = Favorite, tags = Tags, phone = Phone, avatar = Avatar, update = Update, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_binary(Id) orelse is_integer(Id) -> Acc2; - {names,_} when Names==[] orelse is_binary(Names) -> Acc2; - {surnames,_} when Surnames==[] orelse is_binary(Surnames) -> Acc2; - {email,_} when Email==[] orelse is_binary(Email) -> Acc2; - {nick,_} when Nick==[] orelse is_binary(Nick) -> Acc2; - {userlist,_} when is_list(Userlist) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Contact') orelse is_integer(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{userlist, D}|Acc3] end, Acc2, Userlist); - {roomlist,_} when is_list(Roomlist) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Room') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{roomlist, D}|Acc3] end, Acc2, Roomlist); - {favorite,_} when is_list(Favorite) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Star') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{favorite, D}|Acc3] end, Acc2, Favorite); - {tags,_} when is_list(Tags) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Tag') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{tags, D}|Acc3] end, Acc2, Tags); - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {avatar,_} when Avatar==[] orelse is_binary(Avatar) -> Acc2; - {update,_} when Update==[] orelse is_integer(Update) -> Acc2; - {status,_} when Status==[] orelse Status=='get' orelse Status=='create' orelse Status=='del' orelse Status=='remove' orelse Status=='nick' orelse Status=='add' orelse Status=='update' orelse Status=='list' orelse Status=='patch' orelse Status=='last_msg' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Roster'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Profile'{phone = Phone, services = Services, rosters = Rosters, settings = Settings, update = Update, balance = Balance, presence = Presence, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {services,_} when Services==[] orelse is_list(Services) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Service') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{services, D}|Acc3] end, Acc2, Services); - {rosters,_} when Rosters==[] orelse is_list(Rosters) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Roster') orelse is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{rosters, D}|Acc3] end, Acc2, Rosters); - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {update,_} when is_integer(Update) -> Acc2; - {balance,_} when is_integer(Balance) -> Acc2; - {presence,_} when Presence==[] orelse Presence=='offline' orelse Presence=='online' orelse is_binary(Presence) -> Acc2; - {status,_} when Status==[] orelse Status=='remove' orelse Status=='get' orelse Status=='patch' orelse Status=='update' orelse Status=='delete' orelse Status=='create' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Profile'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Presence'{uid = Uid, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {uid,_} when is_binary(Uid) -> Acc2; - {status,_} when Status==[] orelse Status=='offline' orelse Status=='online' orelse is_binary(Status) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Presence'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Friend'{phone_id = Phone_id, friend_id = Friend_id, settings = Settings, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone_id,_} when is_binary(Phone_id) -> Acc2; - {friend_id,_} when is_binary(Friend_id) -> Acc2; - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {status,_} when Status=='ban' orelse Status=='unban' orelse Status=='request' orelse Status=='confirm' orelse Status=='update' orelse Status=='ignore' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Friend'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'act'{name = Name, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when Name==[] orelse is_binary(Name) -> Acc2; - {data,_} when is_binary(Data) orelse is_integer(Data) orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'act'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Job'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, context = Context, proc = Proc, time = Time, data = Data, events = Events, settings = Settings, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when Container=='chain' orelse Container==[] -> Acc2; - {feed_id, #'act'{}} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {context,_} when Context==[] orelse is_integer(Context) orelse is_binary(Context) -> Acc2; - {proc,_} when Proc==[] orelse is_integer(Proc) orelse is_record(Proc,'process') -> Acc2; - {time,_} when Time==[] orelse is_integer(Time) -> Acc2; - {data,_} when Data==[] orelse is_binary(Data) orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when true orelse is_record(Tmp,'Message') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {events,_} when Events==[] orelse is_list(Events) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'messageEvent') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{events, D}|Acc3] end, Acc2, Events); - {settings,_} when Settings==[] orelse is_list(Settings) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Feature') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{settings, D}|Acc3] end, Acc2, Settings); - {status,_} when Status==[] orelse Status=='init' orelse Status=='update' orelse Status=='delete' orelse Status=='pending' orelse Status=='stop' orelse Status=='complete' orelse Status=='restart' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Job'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'History'{roster_id = Roster_id, feed = Feed, size = Size, entity_id = Entity_id, data = Data, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {roster_id,_} when is_binary(Roster_id) -> Acc2; - {feed,_} when is_record(Feed,'p2p') orelse is_record(Feed,'muc') orelse is_record(Feed,'act') orelse is_record(Feed,'StickerPack') orelse Feed==[] -> Acc2; - {size,_} when Size==[] orelse is_integer(Size) -> Acc2; - {entity_id,_} when Entity_id==[] orelse is_integer(Entity_id) -> Acc2; - {data,_} when Data==[] orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'Message') orelse is_record(Tmp,'Job') orelse is_record(Tmp,'StickerPack') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {status,_} when Status=='updated' orelse Status=='get' orelse Status=='update' orelse Status=='last_loaded' orelse Status=='last_msg' orelse Status=='get_reply' orelse Status=='double_get' orelse Status=='delete' orelse Status=='image' orelse Status=='video' orelse Status=='file' orelse Status=='link' orelse Status=='audio' orelse Status=='contact' orelse Status=='location' orelse Status=='text' orelse Status=='draft' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'History'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Schedule'{id = Id, proc = Proc, data = Data, state = State}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) orelse is_tuple(Id) -> Acc2; - {proc,_} when Proc==[] orelse is_integer(Proc) orelse is_binary(Proc) -> Acc2; - {data,_} when is_binary(Data) orelse is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {state,_} when State==[] orelse true -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Schedule'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Index'{id = Id, roster = Roster}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse true -> Acc2; - {roster,_} when is_list(Roster) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{roster, D}|Acc3] end, Acc2, Roster); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Index'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Whitelist'{phone = Phone, created = Created}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Whitelist'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'error'{code = Code}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_atom(Code) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'error'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'ok'{code = Code}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_binary(Code) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'ok'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'error2'{code = Code, src = Src}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_atom(Code) -> Acc2; - {src,_} when Src==[] orelse is_binary(Src) orelse is_integer(Src) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'error2'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'ok2'{code = Code, src = Src}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_atom(Code) -> Acc2; - {src,_} when Src==[] orelse is_tuple(Src) orelse is_binary(Src) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'ok2'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'io'{code = Code, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_record(Code,'ok') orelse is_record(Code,'error') orelse is_record(Code,'ok2') orelse is_record(Code,'error2') orelse Code=='transcribe' -> Acc2; - {data,_} when Data==[] orelse is_binary(Data) orelse is_record(Data,'Roster') orelse is_tuple(Data) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'io'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Ack'{table = Table, id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {table,_} when is_atom(Table) -> Acc2; - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Ack'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'errors'{code = Code, data = Data}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {code,_} when Code==[] orelse is_list(Code) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{code, D}|Acc3] end, Acc2, Code); - {data,_} when Data==[] orelse true -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'errors'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'PushService'{recipients = Recipients, id = Id, ttl = Ttl, module = Module, priority = Priority, payload = Payload}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {recipients,_} when is_list(Recipients) -> - lists:foldl(fun(Tmp, Acc3) when is_binary(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{recipients, D}|Acc3] end, Acc2, Recipients); - {id,_} when Id==[] orelse is_binary(Id) -> Acc2; - {ttl,_} when Ttl==[] orelse is_integer(Ttl) -> Acc2; - {module,_} when Module==[] orelse is_binary(Module) -> Acc2; - {priority,_} when Priority==[] orelse is_binary(Priority) -> Acc2; - {payload,_} when Payload==[] orelse is_binary(Payload) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'PushService'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'PublishService'{message = Message, topic = Topic, qos = Qos}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {message,_} when Message==[] orelse is_binary(Message) -> Acc2; - {topic,_} when Topic==[] orelse is_binary(Topic) -> Acc2; - {qos,_} when Qos==[] orelse is_integer(Qos) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'PublishService'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'FakeNumbers'{phone = Phone, created = Created}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {phone,_} when Phone==[] orelse is_binary(Phone) -> Acc2; - {created,_} when Created==[] orelse is_integer(Created) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'FakeNumbers'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'Draft'{data = Data, status = Status}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {data,_} when is_list(Data) -> - lists:foldl(fun(Tmp, Acc3) when true -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{data, D}|Acc3] end, Acc2, Data); - {status,_} when Status=='update' orelse Status=='get' orelse Status=='delete' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'Draft'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'handler'{name = Name, module = Module, class = Class, group = Group, config = Config, state = State, seq = Seq}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when is_atom(Name) -> Acc2; - {module,_} when is_atom(Module) -> Acc2; - {class,_} -> Acc2; - {group,_} when is_atom(Group) -> Acc2; - {config,_} -> Acc2; - {state,_} -> Acc2; - {seq,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'handler'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'pi'{name = Name, sup = Sup, module = Module, state = State}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {name,_} when is_atom(Name) -> Acc2; - {sup,_} when is_atom(Sup) -> Acc2; - {module,_} when is_atom(Module) -> Acc2; - {state,_} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'pi'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'cx'{handlers = Handlers, actions = Actions, req = Req, module = Module, lang = Lang, path = Path, session = Session, formatter = Formatter, params = Params, node = Node, client_pid = Client_pid, state = State, from = From, vsn = Vsn}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {handlers,_} when is_list(Handlers) -> - lists:foldl(fun(Tmp, Acc3) when is_record(Tmp,'handler') -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{handlers, D}|Acc3] end, Acc2, Handlers); - {actions,_} when is_list(Actions) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{actions, D}|Acc3] end, Acc2, Actions); - {req,_} when Req==[] orelse true -> Acc2; - {module,_} when Module==[] orelse is_atom(Module) -> Acc2; - {lang,_} when Lang==[] orelse is_atom(Lang) -> Acc2; - {path,_} when Path==[] orelse is_binary(Path) -> Acc2; - {session,_} when Session==[] orelse is_binary(Session) -> Acc2; - {formatter,_} when Formatter=='bert' orelse Formatter=='json' -> Acc2; - {params,_} when Params==[] orelse is_list(Params) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{params, D}|Acc3] end, Acc2, Params); - {node,_} when Node==[] orelse is_atom(Node) -> Acc2; - {client_pid,_} when Client_pid==[] orelse true -> Acc2; - {state,_} when State==[] orelse true -> Acc2; - {from,_} when From==[] orelse is_binary(From) -> Acc2; - {vsn,_} when Vsn==[] orelse is_binary(Vsn) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'cx'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'user'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds, email = Email}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - {email,_} when Email==[] orelse is_binary(Email) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'user'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'group'{id = Id, container = Container, feed_id = Feed_id, prev = Prev, next = Next, feeds = Feeds}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when Id==[] orelse is_integer(Id) -> Acc2; - {container,_} when is_atom(Container) -> Acc2; - {feed_id,_} -> Acc2; - {prev,_} when Prev==[] orelse is_integer(Prev) -> Acc2; - {next,_} when Next==[] orelse is_integer(Next) -> Acc2; - {feeds,_} when is_list(Feeds) -> []; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'group'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_topic'{topic = Topic, flags = Flags}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {topic,_} when is_binary(Topic) -> Acc2; - {flags,_} when is_list(Flags) -> - lists:foldl(fun(Tmp, Acc3) when Tmp=='retained' orelse Tmp=='static' -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{flags, D}|Acc3] end, Acc2, Flags); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_topic'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_client'{client_id = Client_id, client_pid = Client_pid, username = Username, peername = Peername, clean_sess = Clean_sess, proto_ver = Proto_ver, will_topic = Will_topic, ws_initial_headers = Ws_initial_headers}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {client_id,_} when is_binary(Client_id) orelse Client_id=='undefined' -> Acc2; - - {username,_} when is_binary(Username) orelse Username=='undefined' -> Acc2; - {peername,_} when is_tuple(Peername) -> Acc2; - - {proto_ver,_} when Proto_ver==3 orelse Proto_ver==4 -> Acc2; - {will_topic,_} when Will_topic=='undefined' orelse is_binary(Will_topic) -> Acc2; - {ws_initial_headers,_} when is_list(Ws_initial_headers) -> - lists:foldl(fun(Tmp, Acc3) when is_tuple(Tmp) -> validate(Tmp, Acc3, CM); (Tmp, Acc3) -> [{ws_initial_headers, D}|Acc3] end, Acc2, Ws_initial_headers); - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_client'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_session'{client_id = Client_id, sess_pid = Sess_pid, clean_sess = Clean_sess}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {client_id,_} when is_binary(Client_id) -> Acc2; - - - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_session'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_message'{id = Id}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when is_binary(Id) orelse Id=='undefined' -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_message'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_delivery'{sender = Sender, message = Message}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - - {message, #'mqtt_message'{}} -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_delivery'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_route'{topic = Topic, node = Node}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {topic,_} when is_binary(Topic) -> Acc2; - - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_route'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end; -validate(D = #'mqtt_alarm'{id = Id, severity = Severity, title = Title, summary = Summary}, Acc, {CustomValidateModule, ValidateFun} = CM) -> - ErrFields = lists:foldl(fun ({RecField, F}, Acc2) -> - case {RecField, F} of - {id,_} when is_binary(Id) -> Acc2; - {severity,_} when Severity=='warning' orelse Severity=='error' orelse Severity=='critical' -> Acc2; - {title,_} when is_list(Title) orelse is_binary(Title) -> Acc2; - {summary,_} when is_list(Summary) orelse is_binary(Summary) -> Acc2; - _ -> [{RecField, D}|Acc2] - end end, Acc, lists:zip(record_info(fields, 'mqtt_alarm'), tl(tuple_to_list(D)))), - ErrFields++case ErrFields of [] -> CustomValidateModule:ValidateFun(D); _ -> [] end. \ No newline at end of file diff --git a/apps/roster/src/test/friend_test.erl b/apps/roster/src/test/friend_test.erl index 232bf39b5..192023d6c 100644 --- a/apps/roster/src/test/friend_test.erl +++ b/apps/roster/src/test/friend_test.erl @@ -4,14 +4,16 @@ -export([make_friends/2]). -send_friend_request(User1PhoneId, User2PhoneId) -> +send_friend_request(_User1PhoneId, _User2PhoneId) -> ok. -confirm_friend_request(User1PhoneId, User2PhoneId) -> +confirm_friend_request(_User1PhoneId, _User2PhoneId) -> ok. make_friends(User1PhoneId, User2PhoneId) -> %% Steps %% 1 - User1 - send friend request %% 2 - User2 - confirm friend request + ok = send_friend_request(User1PhoneId, User2PhoneId), + ok = confirm_friend_request(User1PhoneId, User2PhoneId), ok. \ No newline at end of file diff --git a/apps/roster/src/test/main_test.erl b/apps/roster/src/test/main_test.erl index d9d3166d2..11451d5e6 100644 --- a/apps/roster/src/test/main_test.erl +++ b/apps/roster/src/test/main_test.erl @@ -19,7 +19,7 @@ remove_fake_users_data() -> muc_msgs() -> RoomName = Room = <<"test_room_777">>, - Phones = [{APhone = <<"73777">>, admin}, {<<"79773">>, admin}, {<<"173737">>, member}, {<<"273747">>, member}], + Phones = [{_APhone = <<"73777">>, admin}, {<<"79773">>, admin}, {<<"173737">>, member}, {<<"273747">>, member}], %% Room2 = get_room_id(APhone, RoomName), Counter = length(Phones), roster:purge_room(Room), @@ -33,7 +33,6 @@ muc_msgs() -> Member = #'Member'{presence = online, feed_id = Feed, phone_id = PhoneId, status = Aff}, {PhoneId, ClientId, Member} end || {Phone, Aff} <- Phones], - _ = [ClientId || {_, ClientId, _, _} <- PCs], {Admins, Members} = roster:split_members([M || {_, _, M} <- TPCs]), roster_client:set_filer([AClientId, CClientId], filter_friend), roster_client:send_receive(AClientId, 2, #'Friend'{phone_id = APhoneId, friend_id = CPhoneId, status = request}), @@ -76,7 +75,7 @@ muc_msgs() -> [#'Message'{id = BFid, type = [read]}, #'Room'{}] = roster_client:send_receive(DClientId, last_res), %% Edit with msg_id - #'Message'{files = F} = roster_client:send_receive(BClientId, Counter, #'Message'{id=BFid, msg_id = <>, feed_id=#muc{name = Room}, + #'Message'{files = _F} = roster_client:send_receive(BClientId, Counter, #'Message'{id=BFid, msg_id = <>, feed_id=#muc{name = Room}, from=BPhoneId, files = [#'Desc'{id= <<"7">>, payload = <<"Edited by B!">>}], status = edit}), #'Ack'{} = roster_client:send_receive(BClientId, #'Message'{id=BFid, msg_id = <>, feed_id=#muc{name = Room}, diff --git a/apps/roster/src/test/room_test.erl b/apps/roster/src/test/room_test.erl index 2f8f7315e..1b85a50f9 100644 --- a/apps/roster/src/test/room_test.erl +++ b/apps/roster/src/test/room_test.erl @@ -7,7 +7,8 @@ check_alias_increment/0, add_many_members/0, link/0, - test_joinlink/0 + test_joinlink/0, + suite/0 ]). -define(BLANK_LINK, <<"UNDEFINED">>). diff --git a/apps/roster/src/test/roster_test.erl b/apps/roster/src/test/roster_test.erl index c307d4e32..a4f366b3c 100644 --- a/apps/roster/src/test/roster_test.erl +++ b/apps/roster/src/test/roster_test.erl @@ -6,6 +6,36 @@ -include("roster.hrl"). -include("micro.hrl"). -include("roster_test.hrl"). +-dialyzer({nowarn_function, + [ + test_roster/0, + test_update_contacts/0, + misc_test_roster/1, + test_reg/0, + test_reg/1, + test_reg_jwt/0, + test_friend_multi/0, + test_muc/0, + test_muc_msgs/0, + test_descs/0, + test_multi_muc/0, + test_room/0, + clear_room_msg_test/0, + myself_chat_test/0, + delete_p2p_history_test/0, + patch_nick_test/0, + transcribe_test/0, + p2p_reader_test/0, + clear_test_only_admin/0, + reply_history_test/0, + history_update_test/0, + muc_remove_test/0, + test_call_room/0, + pagination_test/0, + event_securty_test/0, + test_search/0 + ] +}). -define(MAX_ATTEMPTS, 3). @@ -441,8 +471,8 @@ test_roster() -> roster_client:stop_client([BClientId, AClientId]), ok. -test_huge_messages2(M, N) -> - spawn(fun() -> [roster_client:test_huge_messages(N) || _ <- lists:seq(1, M)] end). +% test_huge_messages2(M, N) -> + % spawn(fun() -> [roster_client:test_huge_messages(N) || _ <- lists:seq(1, M)] end). test_huge_messages(N) -> Phones = [PhoneA, PhoneB] = [integer_to_binary(rand:uniform(99999999)) || _ <- [1, 2]], Counter = length(Phones), @@ -462,12 +492,12 @@ test_huge_messages(N) -> roster_client:receive_drop(), Created = roster:now_msec(), FeedId = roster:feed_key(p2p, From, To), - Msg = kvs:add(#'Message'{feed_id = FeedId, created = Created, status = []}), + {ok, Msg} = kvs:add(#'Message'{feed_id = FeedId, created = Created, status = []}), [begin - kvs:add(Msg#'Message'{id = kvs:next_id('Message', 1), + kvs:add(Msg#'Message'{id = kvs:next_id('Message', 1), from = From, to = To, files = [#'Desc'{id = <<"7">>, payload = <<"TestA!">>}], status = []}), timer:sleep(1), - kvs:add(Msg#'Message'{id = kvs:next_id('Message', 1), + kvs:add(Msg#'Message'{id = kvs:next_id('Message', 1), from = To, to = From, files = [#'Desc'{id = <<"7">>, payload = <<"TestB!">>}], status = []}) end || _ <- lists:seq(1, N)], roster_client:stop_client(AClientId), roster_client:stop_client(BClientId). @@ -647,7 +677,7 @@ test_update_contacts() -> PhoneA = <<"357">>, AClientId = roster_client:gen_name(PhoneA), Phones = [<<"53533">>, <<"53774">>], - length(Phones), + % length(Phones), [roster:purge_user(Phone) || Phone <- [PhoneA | Phones]], PCs = [{B, BClientId, _}, {C, CClientId, TC}, {From, AClientId, TA}] = [begin {ClientId, Token} = roster_client:reg_fake_user(Phone), @@ -1571,9 +1601,15 @@ suite() -> % test_messages() ]. -check() -> case lists:all(fun(X) -> X == ok end, suite()) of - true -> roster:info("ALL TESTS PASSED", []), true; - false -> roster:info("TEST ERRORS", []), false end. +check() -> roster:check(?MODULE). + +test_modules()-> [roster_test, micto_test]. +test_all()-> + + + + Result = lists:flatten([erlang:apply(roster,check, [TestModule]) || TestModule <- test_modules()]), + lists:all(fun(X) -> X == ok end, Result). limit('Message', _) -> 2000000. forbid('Message') -> 20. @@ -1604,7 +1640,7 @@ test_migrate() -> Res -> roster:info(?MODULE, "~p = migresia:check(roster)", [Res]), {error, test_migration} end catch Err:Rea -> - n2o:error(?MODULE, "Catch:~p~n", [n2o:stack_trace(Err, Rea)]), + roster:error(?MODULE, "Catch:~p~n", [{Err, Rea}]), throw({error, migrate}) after catch kvs:delete('schema_migrations', 30171023145947), file:delete(TestFile2) end. diff --git a/apps/service/rebar.config b/apps/service/rebar.config index 3af62d09d..acd1ea7e9 100644 --- a/apps/service/rebar.config +++ b/apps/service/rebar.config @@ -1 +1 @@ -{deps,[{bert, ".*", {git, "git://github.com/synrc/bert",[]}}]}. \ No newline at end of file +{deps,[]}. \ No newline at end of file diff --git a/priv/protobuf/service_auth/Auth.proto b/priv/protobuf/service_auth/Auth.proto deleted file mode 100644 index f5c0b18ec..000000000 --- a/priv/protobuf/service_auth/Auth.proto +++ /dev/null @@ -1,30 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Auth.grpc"; -option java_outer_classname = "AuthCls"; -import public "authOs.proto"; -import public "Feature.proto"; -import public "authType.proto"; -import public "Service.proto"; - -message Auth { - string client_id = 1; - string dev_key = 2; - string user_id = 3; - string token = 4; - string data = 5; - authType type = 6; - int64 attempts = 7; - repeated Feature settings = 8; - repeated Service services = 9; - string push = 10; - authOs os = 11; - int64 created = 12; - int64 last_online = 13; -} diff --git a/priv/protobuf/service_auth/Desc.proto b/priv/protobuf/service_auth/Desc.proto deleted file mode 100644 index a1bdff122..000000000 --- a/priv/protobuf/service_auth/Desc.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Desc.grpc"; -option java_outer_classname = "DescCls"; -import public "Feature.proto"; - -message Desc { - string id = 1; - string mime = 2; - string payload = 3; - string parentid = 4; - repeated Feature data = 5; -} diff --git a/priv/protobuf/service_auth/Service.proto b/priv/protobuf/service_auth/Service.proto deleted file mode 100644 index 5255c1138..000000000 --- a/priv/protobuf/service_auth/Service.proto +++ /dev/null @@ -1,22 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Service.grpc"; -option java_outer_classname = "ServiceCls"; -import public "Feature.proto"; -import public "serverType.proto"; -import public "serverStatus.proto"; - -message Service { - string id = 1; - string data = 2; - serverType type = 3; - repeated Feature setting = 4; - int64 expiration = 5; - serverStatus service_status = 6; -} diff --git a/priv/protobuf/service_auth/Tag.proto b/priv/protobuf/service_auth/Tag.proto deleted file mode 100644 index fb29d81cb..000000000 --- a/priv/protobuf/service_auth/Tag.proto +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Tag.grpc"; -option java_outer_classname = "TagCls"; -import public "tagType.proto"; - -message Tag { - int64 roster_id = 1; - string name = 2; - string color = 3; - tagType tag_status = 4; -} diff --git a/priv/protobuf/service_auth/authOs.proto b/priv/protobuf/service_auth/authOs.proto deleted file mode 100644 index 4308091b1..000000000 --- a/priv/protobuf/service_auth/authOs.proto +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "authOs.grpc"; -option java_outer_classname = "authOsCls"; - -enum authOs { - ios = 0; - android = 1; - web = 2; -} - diff --git a/priv/protobuf/service_auth/presence.proto b/priv/protobuf/service_auth/presence.proto deleted file mode 100644 index 00f79c3f1..000000000 --- a/priv/protobuf/service_auth/presence.proto +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "presence.grpc"; -option java_outer_classname = "presenceCls"; - -enum presence { - online = 0; - offline = 1; -} - diff --git a/priv/protobuf/service_auth/serverType.proto b/priv/protobuf/service_auth/serverType.proto deleted file mode 100644 index 56279a322..000000000 --- a/priv/protobuf/service_auth/serverType.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_auth; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "serverType.grpc"; -option java_outer_classname = "serverTypeCls"; - -enum serverType { - email = 0; - wallet = 1; - google_type = 2; - fb = 3; - phone = 4; -} - diff --git a/priv/protobuf/service_friend/Desc.proto b/priv/protobuf/service_friend/Desc.proto deleted file mode 100644 index cfc8b92b4..000000000 --- a/priv/protobuf/service_friend/Desc.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_friend; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Desc.grpc"; -option java_outer_classname = "DescCls"; -import public "Feature.proto"; - -message Desc { - string id = 1; - string mime = 2; - string payload = 3; - string parentid = 4; - repeated Feature data = 5; -} diff --git a/priv/protobuf/service_friend/Feature.proto b/priv/protobuf/service_friend/Feature.proto deleted file mode 100644 index 21240771b..000000000 --- a/priv/protobuf/service_friend/Feature.proto +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_friend; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Feature.grpc"; -option java_outer_classname = "FeatureCls"; - -message Feature { - string id = 1; - string key = 2; - string value = 3; - string group = 4; -} diff --git a/priv/protobuf/service_message/Feature.proto b/priv/protobuf/service_message/Feature.proto deleted file mode 100644 index c525cc914..000000000 --- a/priv/protobuf/service_message/Feature.proto +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_message; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Feature.grpc"; -option java_outer_classname = "FeatureCls"; - -message Feature { - string id = 1; - string key = 2; - string value = 3; - string group = 4; -} diff --git a/priv/protobuf/service_message/Service.proto b/priv/protobuf/service_message/Service.proto deleted file mode 100644 index fd98188cc..000000000 --- a/priv/protobuf/service_message/Service.proto +++ /dev/null @@ -1,22 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_message; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Service.grpc"; -option java_outer_classname = "ServiceCls"; -import public "Feature.proto"; -import public "serverType.proto"; -import public "serverStatus.proto"; - -message Service { - string id = 1; - string data = 2; - serverType type = 3; - repeated Feature setting = 4; - int64 expiration = 5; - serverStatus service_status = 6; -} diff --git a/priv/protobuf/service_message/Tag.proto b/priv/protobuf/service_message/Tag.proto deleted file mode 100644 index 9a1632c0d..000000000 --- a/priv/protobuf/service_message/Tag.proto +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_message; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Tag.grpc"; -option java_outer_classname = "TagCls"; -import public "tagType.proto"; - -message Tag { - int64 roster_id = 1; - string name = 2; - string color = 3; - tagType tag_status = 4; -} diff --git a/priv/protobuf/service_message/p2p.proto b/priv/protobuf/service_message/p2p.proto deleted file mode 100644 index 3290d9526..000000000 --- a/priv/protobuf/service_message/p2p.proto +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_message; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "p2p.grpc"; -option java_outer_classname = "p2pCls"; - -message p2p { - string from = 1; - string to = 2; -} diff --git a/priv/protobuf/service_profile/Desc.proto b/priv/protobuf/service_profile/Desc.proto deleted file mode 100644 index 9a5a2dd16..000000000 --- a/priv/protobuf/service_profile/Desc.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_profile; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Desc.grpc"; -option java_outer_classname = "DescCls"; -import public "Feature.proto"; - -message Desc { - string id = 1; - string mime = 2; - string payload = 3; - string parentid = 4; - repeated Feature data = 5; -} diff --git a/priv/protobuf/service_profile/Tag.proto b/priv/protobuf/service_profile/Tag.proto deleted file mode 100644 index db4d5d5b4..000000000 --- a/priv/protobuf/service_profile/Tag.proto +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_profile; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Tag.grpc"; -option java_outer_classname = "TagCls"; -import public "tagType.proto"; - -message Tag { - int64 roster_id = 1; - string name = 2; - string color = 3; - tagType tag_status = 4; -} diff --git a/priv/protobuf/service_roster/Desc.proto b/priv/protobuf/service_roster/Desc.proto deleted file mode 100644 index 99c421db4..000000000 --- a/priv/protobuf/service_roster/Desc.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_roster; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Desc.grpc"; -option java_outer_classname = "DescCls"; -import public "Feature.proto"; - -message Desc { - string id = 1; - string mime = 2; - string payload = 3; - string parentid = 4; - repeated Feature data = 5; -} diff --git a/priv/protobuf/service_roster/Service.proto b/priv/protobuf/service_roster/Service.proto deleted file mode 100644 index 180788cd3..000000000 --- a/priv/protobuf/service_roster/Service.proto +++ /dev/null @@ -1,22 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_roster; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "Service.grpc"; -option java_outer_classname = "ServiceCls"; -import public "Feature.proto"; -import public "serverType.proto"; -import public "serverStatus.proto"; - -message Service { - string id = 1; - string data = 2; - serverType type = 3; - repeated Feature setting = 4; - int64 expiration = 5; - serverStatus service_status = 6; -} diff --git a/priv/protobuf/service_roster/serverType.proto b/priv/protobuf/service_roster/serverType.proto deleted file mode 100644 index 7ca622a89..000000000 --- a/priv/protobuf/service_roster/serverType.proto +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_roster; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "serverType.grpc"; -option java_outer_classname = "serverTypeCls"; - -enum serverType { - email = 0; - wallet = 1; - google_type = 2; - fb = 3; - phone = 4; -} - diff --git a/priv/protobuf/service_roster/tagType.proto b/priv/protobuf/service_roster/tagType.proto deleted file mode 100644 index 73981ba16..000000000 --- a/priv/protobuf/service_roster/tagType.proto +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by https://github.com/synrc/bert -// DO NOT EDIT - -syntax = "proto3"; -package service_roster; - -option java_generic_services = true; -option java_multiple_files = true; -option java_package = "tagType.grpc"; -option java_outer_classname = "tagTypeCls"; - -enum tagType { - tag_create = 0; - tag_remove = 1; - tag_edit = 2; -} - diff --git a/rebar.config b/rebar.config index 98ab06150..182379cd1 100644 --- a/rebar.config +++ b/rebar.config @@ -2,39 +2,39 @@ {lib_dirs,["apps","deps"]}. {deps_dir,"deps"}. {deps, [ - {bert, ".*", {git, "git://github.com/synrc/bert",{tag,"2.4"}}}, - {active, ".*", {git, "git://github.com/synrc/active",{tag,"master"}}}, + {active, ".*", {git, "https://github.com/synrc/active",{branch,"master"}}}, {esockd, ".*", {git, "https://github.com/voxoz/esockd",{ref, "a80634b961c315ffe5f020d73236473b53ae5dc9"}}}, - {bpe, ".*", {git, "git://github.com/synrc/bpe", {tag,"4.4"}}}, - {emqttd, ".*", {git, "git://github.com/synrc/emqttd",{tag,"master"}}}, - {n2o, ".*", {git, "git://github.com/synrc/n2o", {tag,"6.4"}}}, - {emqttc, ".*", {git, "git://github.com/voxoz/emqttc",{tag,"master"}}}, - {rest, ".*", {git, "git://github.com/synrc/rest",{tag,"5.10"}}}, - {gen_smtp, ".*", {git, "git://github.com/voxoz/gen_smtp",{tag,"master"}}}, - {emq_dashboard, ".*", {git, "https://github.com/synrc/emq_dashboard",{tag,"master"}}}, + {bpe, ".*", {git, "https://github.com/synrc/bpe", {tag,"v4.4"}}}, + {emqttd, ".*", {git, "https://github.com/synrc/emqttd",{branch,"master"}}}, + {emqttc, ".*", {git, "https://github.com/voxoz/emqttc",{branch,"master"}}}, + {rest, ".*", {git, "https://github.com/synrc/rest",{tag,"5.10"}}}, + {gen_smtp, ".*", {git, "https://github.com/voxoz/gen_smtp",{branch,"master"}}}, + {emq_dashboard, ".*", {git, "https://github.com/synrc/emq_dashboard",{branch,"master"}}}, {'opencensus-erlang', ".*", {git, "https://github.com/voxoz/opencensus-erlang",{tag, "v0.4.0"}}}, - {libphonenumber_erlang, ".*", {git, "https://github.com/marinakr/libphonenumber_erlang.git",{tag,"master"}}}, - {gproc, ".*", {git, "https://github.com/uwiger/gproc","0.6.1"}}, - {erlydtl, ".*", {git, "git://github.com/voxoz/erlydtl",{tag,"master"}}}, - {mini_s3, ".*", {git, "https://github.com/chef/mini_s3.git",{tag,"master"}}}, + {libphonenumber_erlang, ".*", {git, "https://github.com/marinakr/libphonenumber_erlang.git",{branch,"master"}}}, + {gproc, ".*", {git, "https://github.com/uwiger/gproc", {tag,"0.6.1"}}}, + {erlydtl, ".*", {git, "https://github.com/voxoz/erlydtl",{branch,"master"}}}, + {mini_s3, ".*", {git, "https://github.com/chef/mini_s3.git",{branch,"master"}}}, {jwt, ".*", {git, "https://github.com/artemeff/jwt.git",{tag, "0.1.8"}}}, - {jsx, ".*", {git, "https://github.com/talentdeficit/jsx.git","v2.9.0"}}, - {base64url, ".*", {git, "https://github.com/dvv/base64url.git","v1.0"}}, - {migresia, ".*", {git, "https://github.com/yoonka/migresia.git",{tag,"master"}}}, + {jsx, ".*", {git, "https://github.com/talentdeficit/jsx.git", {tag,"v2.9.0"}}}, + {base64url, ".*", {git, "https://github.com/dvv/base64url.git", {tag,"v1.0"}}}, + {migresia, ".*", {git, "https://github.com/yoonka/migresia.git",{branch,"master"}}}, {counters, ".*", {git, "https://github.com/deadtrickster/counters.erl.git", {tag, "v0.2.0"}}}, - {ctx, ".*", {git, "https://github.com/tsloughter/ctx.git", []}}, - {wts, ".*", {git, "https://github.com/tsloughter/wts.git", []}}, + {ctx, ".*", {git, "https://github.com/tsloughter/ctx.git", {branch,"master"}}}, + {wts, ".*", {git, "https://github.com/tsloughter/wts.git", {branch,"master"}}}, {rfc3339, ".*", {git, "https://github.com/talentdeficit/rfc3339",{tag,"0.2.2"}}}, - {locus, ".*", {git, "https://github.com/g-andrade/locus.git",{tag,"master"}}}, - {prometheus, ".*", {git, "https://github.com/deadtrickster/prometheus.erl",{tag,"master"}}}, - {cowboy, ".*", {git, "git://github.com/voxoz/cowboy", {tag,"master"}}}, - {'jose-erlang', ".*", {git, "https://github.com/manifest/jose-erlang.git", {tag,"master"}}}, + {locus, ".*", {git, "https://github.com/g-andrade/locus.git",{branch,"master"}}}, {json_rec, ".*", {git, "https://github.com/justinkirby/json_rec.git", {tag,"master"}}}, - {'erlang-uuid', ".*", {git, "https://github.com/avtobiff/erlang-uuid.git",{tag,"master"}}}, + {prometheus, ".*", {git, "https://github.com/deadtrickster/prometheus.erl",{branch,"master"}}}, + {cowboy, ".*", {git, "https://github.com/voxoz/cowboy", {branch,"master"}}}, + % ===> Dependency failure: source for jose-erlang does not contain a recognizable project and can not be built + % {'jose-erlang', ".*", {git, "https://github.com/manifest/jose-erlang.git", {branch,"master"}}}, + {'erlang-uuid', ".*", {git, "https://github.com/avtobiff/erlang-uuid.git",{branch,"master"}}}, {enenra, ".*", {git, "https://github.com/nlfiedler/enenra", {tag, "0.3.0"}}}, {'qdate', ".*", {git, "https://github.com/enterprizing/qdate.git",{ref,"fba988fc54214bb37a3ce11d5c5a3cc68752c3ce"}}} ]}. -{erl_opts, [{parse_transform,lager_transform},{parse_transform, oc_transform},debug_info]}. + +{erl_opts, [{parse_transform,lager_transform},{parse_transform, oc_transform},debug_info,nowarn_deprecated_function,nowarn_export_all]}. {relx, [{release, {server, "1.0.0"}, [roster, service]}, {sys_config, "./sys.config"}, @@ -49,3 +49,6 @@ {include_erts, true}]} ]} ]}. +{dialyzer, [ + {warnings, [underspecs, no_return]} +]}. \ No newline at end of file diff --git a/rebar.config.script b/rebar.config.script new file mode 100644 index 000000000..bd3898f78 --- /dev/null +++ b/rebar.config.script @@ -0,0 +1,10 @@ +OSENV = os:getenv("REBAR_DEPS"). +SetAppEnv = fun(App,Config)-> [ application:set_env(App,Key,Value) || {Key,Value} <- proplists:get_value(App,Config)] end. +{ok,[SysConf]}=file:consult('sys.config'). +SetAppEnv(bert,SysConf). +%% io:format("Disallowed: ~p~n",[application:get_env(bert,disallowed,[])]). +case OSENV of + false -> CONFIG; % env var not defined + [] -> CONFIG; % env var set to empty string + Dir ->lists:keystore(deps_dir, 1, CONFIG, {deps_dir, Dir}) +end. diff --git a/rebar.lock b/rebar.lock deleted file mode 100644 index f641a2fbb..000000000 --- a/rebar.lock +++ /dev/null @@ -1,164 +0,0 @@ -{"1.1.0", -[{<<"base64url">>, - {git,"https://github.com/dvv/base64url.git", - {ref,"f2c64ed8b9bebc536fad37ad97243452b674b837"}}, - 0}, - {<<"bert">>, - {git,"git://github.com/synrc/bert", - {ref,"6cde41b32448e85ecd48225221d6f978943a1bad"}}, - 0}, - {<<"bpe">>, - {git,"git://github.com/synrc/bpe", - {ref,"356c9e621c38e927a8611ecac592bcdc8d689026"}}, - 0}, - {<<"certifi">>,{pkg,<<"certifi">>,<<"2.4.2">>},1}, - {<<"counters">>, - {git,"https://github.com/deadtrickster/counters.erl.git", - {ref,"c3f4aa3acdf71c3db0a4b3fc1343aa45de2c5df0"}}, - 0}, - {<<"cowboy">>, - {git,"git://github.com/voxoz/cowboy", - {ref,"c1cfbfa5dc6b5f6ecd9591ad5bf642b6a107a7f5"}}, - 0}, - {<<"cowlib">>, - {git,"git://github.com/voxoz/cowlib", - {ref,"5cc0038d0a3ae6a829646ddfff998d8c491969ca"}}, - 1}, - {<<"ctx">>, - {git,"https://github.com/tsloughter/ctx.git", - {ref,"a5a6b0948708e02bc7b9cb6248807c9ff8327940"}}, - 0}, - {<<"emq_dashboard">>, - {git,"https://github.com/synrc/emq_dashboard", - {ref,"f711e8d2b0a992f5540123f3504eebabc324a684"}}, - 0}, - {<<"emqttc">>, - {git,"git://github.com/voxoz/emqttc", - {ref,"141fd2e925be854321d22005313762adb1195f48"}}, - 0}, - {<<"emqttd">>, - {git,"git://github.com/synrc/emqttd", - {ref,"c3d0b7b092fffe7bebe27af27dbbfe1714757d1c"}}, - 0}, - {<<"envy">>, - {git,"https://github.com/markan/envy.git", - {ref,"0148fb4b7ed0e188511578e98b42d6e7dde0ebd1"}}, - 1}, - {<<"erlang-uuid">>, - {git,"https://github.com/avtobiff/erlang-uuid.git", - {ref,"cb02a2039a9b29dd2eef0446039c9c6e164df9ef"}}, - 0}, - {<<"erlydtl">>, - {git,"git://github.com/voxoz/erlydtl", - {ref,"bdebe6f87d8f989018facbbf8dc6320936ffe98f"}}, - 0}, - {<<"esockd">>, - {git,"https://github.com/voxoz/esockd", - {ref,"a80634b961c315ffe5f020d73236473b53ae5dc9"}}, - 0}, - {<<"forms">>, - {git,"git://github.com/synrc/forms", - {ref,"845feb45a46dfc2e0e9a156da9c01c218d8fd6cc"}}, - 1}, - {<<"gen_logger">>, - {git,"git://github.com/voxoz/gen_logger", - {ref,"5b14530363feb0b049c4f5c7c606f815aec781d2"}}, - 1}, - {<<"gen_smtp">>, - {git,"git://github.com/voxoz/gen_smtp", - {ref,"89eb26f8a81b0dce76aedae5695a923c8ac98695"}}, - 0}, - {<<"goldrush">>, - {git,"git://github.com/voxoz/goldrush.git", - {ref,"9e92405985827fabd2508b92bdc8b28b9e17b668"}}, - 2}, - {<<"gproc">>, - {git,"https://github.com/uwiger/gproc", - {ref,"1d16f5e6d7cf616eec4395f2385e3a680a4ffc9f"}}, - 0}, - {<<"ibrowse">>, - {git,"git://github.com/cmullaparthi/ibrowse.git", - {ref,"c97136cfb61fcc6f39d4e7da47372a64f7fca04e"}}, - 1}, - {<<"jsx">>, - {git,"https://github.com/talentdeficit/jsx.git", - {ref,"fc2a001073f2300ba38427c23e83d5673c020542"}}, - 0}, - {<<"jwt">>, - {git,"https://github.com/artemeff/jwt.git", - {ref,"6fd754fec1cd2e4577a5d7121233371900aa44e7"}}, - 0}, - {<<"kvs">>, - {git,"git://github.com/synrc/kvs", - {ref,"c0f9bd4766c2751e8f7b1752f8eb949d17f01b87"}}, - 1}, - {<<"lager">>, - {git,"git://github.com/voxoz/lager", - {ref,"1ecf4c17e9e39dd7a1943140477f632d17518f0c"}}, - 1}, - {<<"libphonenumber_erlang">>, - {git,"https://github.com/marinakr/libphonenumber_erlang.git", - {ref,"3a6be75ef4f6fdd40fa8afee2a7fc5cf2ddb8601"}}, - 0}, - {<<"locus">>, - {git,"https://github.com/g-andrade/locus.git", - {ref,"0ea9079ce5686573e0e70e2b1311343dd25feef8"}}, - 0}, - {<<"migresia">>, - {git,"https://github.com/yoonka/migresia.git", - {ref,"40e11825e01502d045e87bf8b5d7dc5a9d6e3f73"}}, - 0}, - {<<"mini_s3">>, - {git,"https://github.com/chef/mini_s3.git", - {ref,"df0c68ea901343b8e0c647142d88d7f3aae27e7b"}}, - 0}, - {<<"mochiweb">>, - {git,"git://github.com/voxoz/mochiweb", - {ref,"c53540557dba6d79c347209fc9980e97dcf3dd3f"}}, - 1}, - {<<"n2o">>, - {git,"git://github.com/synrc/n2o", - {ref,"f59f997d1432515403f505b382ce6717454abaa3"}}, - 0}, - {<<"nitro">>, - {git,"git://github.com/synrc/nitro", - {ref,"1aeb421c332f94b135563f8e855b139c1b067f59"}}, - 1}, - {<<"opencensus-erlang">>, - {git,"https://github.com/voxoz/opencensus-erlang", - {ref,"8dc9ae86f5c1ef69593fe37b49e649afed6bd201"}}, - 0}, - {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},2}, - {<<"prometheus">>, - {git,"https://github.com/deadtrickster/prometheus.erl", - {ref,"46ea4b487baf4f6cc44495eae07582808e0369d4"}}, - 0}, - {<<"ranch">>, - {git,"git://github.com/voxoz/ranch", - {ref,"1a75038c82ede22efec46a7dca192b8ce26309e0"}}, - 1}, - {<<"rest">>, - {git,"git://github.com/synrc/rest", - {ref,"9a4e21d50a96b06649944c9a88ad595114db6c31"}}, - 0}, - {<<"rfc3339">>, - {git,"https://github.com/talentdeficit/rfc3339", - {ref,"90effc078c5e673d025b2c1269a153ad4748d3df"}}, - 0}, - {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.4">>},1}, - {<<"stacktrace_compat">>,{pkg,<<"stacktrace_compat">>,<<"1.0.2">>},1}, - {<<"syn">>, - {git,"git://github.com/ostinelli/syn", - {ref,"9964eb8969b6e1e712249d3aed4f3dfafd3aaac3"}}, - 1}, - {<<"wts">>, - {git,"https://github.com/tsloughter/wts.git", - {ref,"5613b6c4354867fd2b02fde5ef15bf80190b8586"}}, - 0}]}. -[ -{pkg_hash,[ - {<<"certifi">>, <<"75424FF0F3BAACCFD34B1214184B6EF616D89E420B258BB0A5EA7D7BC628F7F0">>}, - {<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>}, - {<<"ssl_verify_fun">>, <<"F0EAFFF810D2041E93F915EF59899C923F4568F4585904D010387ED74988E77B">>}, - {<<"stacktrace_compat">>, <<"8AD31C32C9A0EADB1EB298F04DC8B0C8D79BCC6233A638B02791FFCA4F331275">>}]} -]. diff --git a/sys.config b/sys.config index 06133854f..2951883be 100644 --- a/sys.config +++ b/sys.config @@ -3,8 +3,7 @@ {bert,[{js,"apps/roster/priv/macbert/"}, {erl,"apps/roster/src"}, {google,"apps/service/priv/"}, - {disallowed,['feed', 'Whitelist', 'FakeNumbers','Schedule','Index','process']}, - {allowed_hrl, ["roster"]}, + {disallowed,['feed', 'Whitelist', 'FakeNumbers','Schedule','Index','process','cx']}, %% TODO remove the 'cx' record / bring imprevement for bert_validator {custom_validate, {roster, validate}}, {swift,"apps/roster/priv/macbert/"}]}, {roster,[ @@ -66,13 +65,15 @@ {n2o, [{port,8000}, {upload,"./storage"}, {app,review}, - {tables,[ cookies, file, caching, ring, async, nick, names, surnames, system]}, + {tables,[ cookies, file, caching, ring, mqtt, ws, async, nick, names, surnames, system]}, {pickler,nitro_pickle}, {formatter,n2o_bert}, + {mqtt_server,true}, {auth_ttl, 86400}, %% 24 h {protocols,[n2o_nitro,n2o_ftp,roster_proto]}, {log_modules,[roster, n2o_vnode]}, {log_level,roster}, + {mqtt_server,true}, {vnode, {roster, get_vnode}}, {validate, {roster, validate}} ]}, -- GitLab