@live-change/peer-connection-service 0.8.110 → 0.8.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/message.js +14 -10
  2. package/package.json +2 -2
package/message.js CHANGED
@@ -43,13 +43,16 @@ const Message = definition.model({
43
43
  property: ['to', 'timestamp']
44
44
  },*/
45
45
  },
46
- crud: {
47
- deleteTrigger: true,
48
- writeOptions: {
49
- access: (params, {client, service}) => {
50
- return client.roles.includes('admin')
51
- }
52
- }
46
+ })
47
+
48
+ definition.event({
49
+ name: "MessageCreated",
50
+ async execute({ message, data }, { client, service }) {
51
+ if(data.id) delete data.id
52
+ await Message.create({
53
+ id: message,
54
+ ...data
55
+ })
53
56
  }
54
57
  })
55
58
 
@@ -154,15 +157,16 @@ definition.action({
154
157
  if(visibilityTest) return true
155
158
  const [fromType, fromId, fromSession] = from.split(':')
156
159
  const [toType, toId, toSession] = to.split(':')
157
- console.log("POST MESSAGE", fromType, fromId, fromSession, '=>', toType, toId, toSession, "BY", client)
160
+ //console.log("POST MESSAGE", fromType, fromId, fromSession, '=>', toType, toId, toSession, "BY", client)
158
161
  if(toType !== fromType || toId !== fromId) return false // different channel
159
162
  if(client.session !== fromSession) return false
160
163
  const hasRole = await clientHasAccessRoles(client, { objectType: toType, object: toId }, writerRoles)
161
164
  return hasRole
162
165
  },
163
- queuedBy: (props) => props.to, // without this, messages order can be changed, it will block ice connection state
166
+ queuedBy: (props) => props.from+':'+props.to, // without this, messages order can be changed
167
+ // and it will block ice connection state
164
168
  async execute(props, { client, service }, emit) {
165
- throw new Error('postMessage is deprecated, use postMessages instead')
169
+ console.error('postMessage is deprecated, use postMessages instead')
166
170
  const result = postMessage(props, { client, service }, emit)
167
171
  console.log("MESSAGE POSTED!")
168
172
  return result
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/peer-connection-service",
3
- "version": "0.8.110",
3
+ "version": "0.8.112",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -11,5 +11,5 @@
11
11
  },
12
12
  "author": "Michał Łaszczewski <michal@emikse.com>",
13
13
  "license": "BSD-3-Clause",
14
- "gitHead": "8af31d640f43b00b2874f2c70fa4d4486541adfe"
14
+ "gitHead": "e0d0db33777f8f9fc9f5ebe1a977cf574b837be6"
15
15
  }