@nmshd/consumption 1.0.9 → 1.0.10
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.
- package/dist/buildInformation.js +4 -4
- package/dist/modules/relationships/RelationshipInfoController.js +13 -5
- package/dist/modules/relationships/RelationshipInfoController.js.map +1 -1
- package/dist/modules/relationships/RelationshipInfoUtil.js +60 -33
- package/dist/modules/relationships/RelationshipInfoUtil.js.map +1 -1
- package/lib-web/nmshd.consumption.js +77 -42
- package/lib-web/nmshd.consumption.js.map +1 -1
- package/lib-web/nmshd.consumption.min.js +1 -1
- package/lib-web/nmshd.consumption.min.js.map +1 -1
- package/package.json +1 -1
package/dist/buildInformation.js
CHANGED
|
@@ -6,10 +6,10 @@ const content_1 = require("@nmshd/content");
|
|
|
6
6
|
const crypto_1 = require("@nmshd/crypto");
|
|
7
7
|
const transport_1 = require("@nmshd/transport");
|
|
8
8
|
exports.buildInformation = {
|
|
9
|
-
version: "1.0.
|
|
10
|
-
build: "
|
|
11
|
-
date: "2021-12-
|
|
12
|
-
commit: "
|
|
9
|
+
version: "1.0.10",
|
|
10
|
+
build: "12",
|
|
11
|
+
date: "2021-12-23T16:26:55+00:00",
|
|
12
|
+
commit: "d6f4641d66742bf72bc0399783a432af36ef8efc",
|
|
13
13
|
dependencies: {},
|
|
14
14
|
libraries: {
|
|
15
15
|
transport: transport_1.buildInformation,
|
|
@@ -18,13 +18,21 @@ class RelationshipInfoController extends consumption_1.ConsumptionBaseController
|
|
|
18
18
|
return result ? await RelationshipInfo_1.RelationshipInfo.from(result) : undefined;
|
|
19
19
|
}
|
|
20
20
|
async getRelationshipInfoByRelationship(relationshipId) {
|
|
21
|
-
const result = await this.relationshipInfo.findOne({ relationshipId: relationshipId.toString() });
|
|
22
|
-
if (result) {
|
|
23
|
-
return await RelationshipInfo_1.RelationshipInfo.from(result);
|
|
24
|
-
}
|
|
25
21
|
const info = await new RelationshipInfoUtil_1.RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(relationshipId);
|
|
26
|
-
await this.relationshipInfo.create(info);
|
|
27
22
|
return info;
|
|
23
|
+
/*
|
|
24
|
+
// So far, do not store the relationshipInfo, as they wouldn't be updated correctly
|
|
25
|
+
|
|
26
|
+
const result = await this.relationshipInfo.findOne({ relationshipId: relationshipId.toString() })
|
|
27
|
+
|
|
28
|
+
if (result) {
|
|
29
|
+
return await RelationshipInfo.from(result)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const info = await new RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(relationshipId)
|
|
33
|
+
await this.relationshipInfo.create(info)
|
|
34
|
+
return info
|
|
35
|
+
*/
|
|
28
36
|
}
|
|
29
37
|
async getRelationshipInfos(query) {
|
|
30
38
|
const items = await this.relationshipInfo.find(query);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipInfoController.js","sourceRoot":"","sources":["../../../src/modules/relationships/RelationshipInfoController.ts"],"names":[],"mappings":";;;AACA,mDAA2G;AAE3G,+DAA2D;AAC3D,iEAA6D;AAE7D,MAAa,0BAA2B,SAAQ,uCAAyB;IAGrE,YAAmB,MAA6B;QAC5C,KAAK,CAAC,uCAAyB,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAA;IACvE,CAAC;IAEM,KAAK,CAAC,IAAI;QACb,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAElB,IAAI,CAAC,gBAAgB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,CAAA;QACzG,OAAO,IAAI,CAAA;IACf,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,EAAU;QACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC9D,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,mCAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACnE,CAAC;IAEM,KAAK,CAAC,iCAAiC,CAAC,cAAsB;QACjE,MAAM,
|
|
1
|
+
{"version":3,"file":"RelationshipInfoController.js","sourceRoot":"","sources":["../../../src/modules/relationships/RelationshipInfoController.ts"],"names":[],"mappings":";;;AACA,mDAA2G;AAE3G,+DAA2D;AAC3D,iEAA6D;AAE7D,MAAa,0BAA2B,SAAQ,uCAAyB;IAGrE,YAAmB,MAA6B;QAC5C,KAAK,CAAC,uCAAyB,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAA;IACvE,CAAC;IAEM,KAAK,CAAC,IAAI;QACb,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAElB,IAAI,CAAC,gBAAgB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,CAAA;QACzG,OAAO,IAAI,CAAA;IACf,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,EAAU;QACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC9D,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,mCAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACnE,CAAC;IAEM,KAAK,CAAC,iCAAiC,CAAC,cAAsB;QACjE,MAAM,IAAI,GAAG,MAAM,IAAI,2CAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,6BAA6B,CAAC,cAAc,CAAC,CAAA;QACtG,OAAO,IAAI,CAAA;QACX;;;;;;;;;;;;UAYE;IACN,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,KAAW;QACzC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrD,OAAO,MAAM,IAAI,CAAC,UAAU,CAAmB,KAAK,EAAE,mCAAgB,CAAC,CAAA;IAC3E,CAAC;IAEM,KAAK,CAAC,sBAAsB,CAAC,gBAAkC;QAClE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAA;QACtG,IAAI,MAAM,EAAE;YACR,MAAM,+BAAiB,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAA;SAC9G;QAED,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;QACpD,OAAO,gBAAgB,CAAA;IAC3B,CAAC;IAEM,KAAK,CAAC,sBAAsB,CAAC,gBAAkC;QAClE,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC5F,IAAI,CAAC,mBAAmB,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAChD;QACD,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAA;IAC7E,CAAC;IAEM,KAAK,CAAC,sBAAsB,CAAC,gBAAkC;QAClE,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxD,CAAC;CACJ;AA/DD,gEA+DC"}
|
|
@@ -62,14 +62,14 @@ class RelationshipInfoUtil {
|
|
|
62
62
|
async createRelationshipInfo(relationship) {
|
|
63
63
|
const peerAddress = relationship.peer.address;
|
|
64
64
|
const truncatedAddress = peerAddress.address.substring(3, 9);
|
|
65
|
-
|
|
65
|
+
const info = await RelationshipInfo_1.RelationshipInfo.from({
|
|
66
66
|
attributes: [],
|
|
67
67
|
id: await consumption_1.ConsumptionIds.relationshipInfo.generate(),
|
|
68
68
|
isPinned: false,
|
|
69
69
|
relationshipId: relationship.id,
|
|
70
70
|
title: truncatedAddress
|
|
71
71
|
});
|
|
72
|
-
info = await this.parent.relationshipInfo.createRelationshipInfo(info)
|
|
72
|
+
// info = await this.parent.relationshipInfo.createRelationshipInfo(info)
|
|
73
73
|
const items = await this.parent.sharedItems.getSharedItems({
|
|
74
74
|
sharedBy: relationship.peer.address.toString()
|
|
75
75
|
});
|
|
@@ -89,15 +89,15 @@ class RelationshipInfoUtil {
|
|
|
89
89
|
info.attributes = attributes;
|
|
90
90
|
const title = this.getTitle(relationship, attributeMap);
|
|
91
91
|
info.title = title;
|
|
92
|
-
await this.parent.relationshipInfo.updateRelationshipInfo(info)
|
|
92
|
+
// await this.parent.relationshipInfo.updateRelationshipInfo(info)
|
|
93
93
|
return info;
|
|
94
94
|
}
|
|
95
95
|
async parseTemplateBody(relationship, template) {
|
|
96
96
|
if (!template.cache) {
|
|
97
97
|
throw transport_1.TransportErrors.general.cacheEmpty(transport_1.RelationshipTemplate, template.id.toString()).logWith(this._log);
|
|
98
98
|
}
|
|
99
|
-
const isTemplator = this.parent.accountController.identity.isMe(template.cache.createdBy);
|
|
100
99
|
if (template.cache.content instanceof content_1.RelationshipTemplateBody) {
|
|
100
|
+
const isTemplator = this.parent.accountController.identity.isMe(template.cache.createdBy);
|
|
101
101
|
const body = template.cache.content;
|
|
102
102
|
const attributes = body.sharedAttributes;
|
|
103
103
|
if (attributes) {
|
|
@@ -108,33 +108,46 @@ class RelationshipInfoUtil {
|
|
|
108
108
|
const sharedWith = isTemplator
|
|
109
109
|
? relationship.peer.address
|
|
110
110
|
: this.parent.accountController.identity.address;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
const sharedItemsWithSameReference = await this.parent.sharedItems.getSharedItems({
|
|
112
|
+
reference: template.id.toString()
|
|
113
|
+
});
|
|
114
|
+
if (sharedItemsWithSameReference.length !== attributes.length) {
|
|
115
|
+
const missingItems = [];
|
|
116
|
+
attributes.forEach((attribute) => {
|
|
117
|
+
if (!sharedItemsWithSameReference.find(function (item) {
|
|
118
|
+
const content = item.content;
|
|
119
|
+
return content.name === attribute.name;
|
|
120
|
+
})) {
|
|
121
|
+
missingItems.push(attribute);
|
|
122
|
+
}
|
|
120
123
|
});
|
|
121
|
-
|
|
124
|
+
for (const attribute of missingItems) {
|
|
125
|
+
const sharedItem = await SharedItem_1.SharedItem.from({
|
|
126
|
+
id: await consumption_1.ConsumptionIds.sharedItem.generate(),
|
|
127
|
+
content: attribute,
|
|
128
|
+
sharedAt: sharedAt,
|
|
129
|
+
sharedBy: sharedBy,
|
|
130
|
+
sharedWith: sharedWith,
|
|
131
|
+
reference: template.id,
|
|
132
|
+
expiresAt: attribute.validTo
|
|
133
|
+
});
|
|
134
|
+
await this.parent.sharedItems.createSharedItem(sharedItem);
|
|
135
|
+
}
|
|
122
136
|
}
|
|
123
137
|
}
|
|
124
138
|
}
|
|
139
|
+
else {
|
|
140
|
+
// do nothing, we don't know the content
|
|
141
|
+
}
|
|
125
142
|
}
|
|
126
143
|
async parseCreationRequest(relationship) {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
const error = new Error("error.consumption.noRequestContent");
|
|
130
|
-
this._log.error(error);
|
|
131
|
-
throw error;
|
|
132
|
-
}
|
|
133
|
-
const isRequestor = this.parent.accountController.identity.isMe(request.createdBy);
|
|
144
|
+
const change = relationship.cache.creationChange;
|
|
145
|
+
const request = change.request;
|
|
134
146
|
if (request.content instanceof content_1.RelationshipCreationChangeRequestBody) {
|
|
147
|
+
const isRequestor = this.parent.accountController.identity.isMe(request.createdBy);
|
|
135
148
|
const body = request.content;
|
|
136
149
|
const attributes = body.sharedAttributes;
|
|
137
|
-
if (attributes) {
|
|
150
|
+
if (attributes && attributes.length > 0) {
|
|
138
151
|
const sharedAt = request.createdAt;
|
|
139
152
|
const sharedBy = isRequestor
|
|
140
153
|
? this.parent.accountController.identity.address
|
|
@@ -142,22 +155,36 @@ class RelationshipInfoUtil {
|
|
|
142
155
|
const sharedWith = isRequestor
|
|
143
156
|
? relationship.peer.address
|
|
144
157
|
: this.parent.accountController.identity.address;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
158
|
+
const sharedItemsWithSameReference = await this.parent.sharedItems.getSharedItems({
|
|
159
|
+
reference: change.id.toString()
|
|
160
|
+
});
|
|
161
|
+
if (sharedItemsWithSameReference.length !== attributes.length) {
|
|
162
|
+
const missingItems = [];
|
|
163
|
+
attributes.forEach((attribute) => {
|
|
164
|
+
if (!sharedItemsWithSameReference.find(function (item) {
|
|
165
|
+
const content = item.content;
|
|
166
|
+
return content.name === attribute.name;
|
|
167
|
+
})) {
|
|
168
|
+
missingItems.push(attribute);
|
|
169
|
+
}
|
|
154
170
|
});
|
|
155
|
-
|
|
171
|
+
for (const attribute of missingItems) {
|
|
172
|
+
const sharedItem = await SharedItem_1.SharedItem.from({
|
|
173
|
+
id: await consumption_1.ConsumptionIds.sharedItem.generate(),
|
|
174
|
+
content: attribute,
|
|
175
|
+
sharedAt: sharedAt,
|
|
176
|
+
sharedBy: sharedBy,
|
|
177
|
+
sharedWith: sharedWith,
|
|
178
|
+
reference: change.id,
|
|
179
|
+
expiresAt: attribute.validTo
|
|
180
|
+
});
|
|
181
|
+
await this.parent.sharedItems.createSharedItem(sharedItem);
|
|
182
|
+
}
|
|
156
183
|
}
|
|
157
184
|
}
|
|
158
185
|
}
|
|
159
186
|
else {
|
|
160
|
-
|
|
187
|
+
// do nothing, we don't know the content
|
|
161
188
|
}
|
|
162
189
|
}
|
|
163
190
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipInfoUtil.js","sourceRoot":"","sources":["../../../src/mod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O,CAAC,CAAC,SAAS,EAAE,EAAE;wBAC7B,IACI,CAAC,4BAA4B,CAAC,IAAI,CAAC,UAAU,IAAI;4BAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAoB,CAAA;4BACzC,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAA;wBAC1C,CAAC,CAAC,EACJ;4BACE,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;yBAC/B;oBACL,CAAC,CAAC,CAAA;oBACF,KAAK,MAAM,SAAS,IAAI,YAAY,EAAE;wBAClC,MAAM,UAAU,GAAG,MAAM,uBAAU,CAAC,IAAI,CAAC;4BACrC,EAAE,EAAE,MAAM,4BAAc,CAAC,UAAU,CAAC,QAAQ,EAAE;4BAC9C,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,QAAQ;4BAClB,QAAQ,EAAE,QAAQ;4BAClB,UAAU,EAAE,UAAU;4BACtB,SAAS,EAAE,MAAM,CAAC,EAAE;4BACpB,SAAS,EAAE,SAAS,CAAC,OAAO;yBAC/B,CAAC,CAAA;wBACF,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAA;qBAC7D;iBACJ;aACJ;SACJ;aAAM;YACH,wCAAwC;SAC3C;IACL,CAAC;CACJ;AAvMD,oDAuMC"}
|
|
@@ -17,10 +17,10 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
17
17
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
18
18
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
19
19
|
exports.buildInformation = {
|
|
20
|
-
version: "1.0.
|
|
21
|
-
build: "
|
|
22
|
-
date: "2021-12-
|
|
23
|
-
commit: "
|
|
20
|
+
version: "1.0.10",
|
|
21
|
+
build: "12",
|
|
22
|
+
date: "2021-12-23T16:26:55+00:00",
|
|
23
|
+
commit: "d6f4641d66742bf72bc0399783a432af36ef8efc",
|
|
24
24
|
dependencies: {},
|
|
25
25
|
libraries: {
|
|
26
26
|
transport: transport_1.buildInformation,
|
|
@@ -700,13 +700,21 @@ class RelationshipInfoController extends consumption_1.ConsumptionBaseController
|
|
|
700
700
|
return result ? await RelationshipInfo_1.RelationshipInfo.from(result) : undefined;
|
|
701
701
|
}
|
|
702
702
|
async getRelationshipInfoByRelationship(relationshipId) {
|
|
703
|
-
const result = await this.relationshipInfo.findOne({ relationshipId: relationshipId.toString() });
|
|
704
|
-
if (result) {
|
|
705
|
-
return await RelationshipInfo_1.RelationshipInfo.from(result);
|
|
706
|
-
}
|
|
707
703
|
const info = await new RelationshipInfoUtil_1.RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(relationshipId);
|
|
708
|
-
await this.relationshipInfo.create(info);
|
|
709
704
|
return info;
|
|
705
|
+
/*
|
|
706
|
+
// So far, do not store the relationshipInfo, as they wouldn't be updated correctly
|
|
707
|
+
|
|
708
|
+
const result = await this.relationshipInfo.findOne({ relationshipId: relationshipId.toString() })
|
|
709
|
+
|
|
710
|
+
if (result) {
|
|
711
|
+
return await RelationshipInfo.from(result)
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
const info = await new RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(relationshipId)
|
|
715
|
+
await this.relationshipInfo.create(info)
|
|
716
|
+
return info
|
|
717
|
+
*/
|
|
710
718
|
}
|
|
711
719
|
async getRelationshipInfos(query) {
|
|
712
720
|
const items = await this.relationshipInfo.find(query);
|
|
@@ -806,14 +814,14 @@ class RelationshipInfoUtil {
|
|
|
806
814
|
async createRelationshipInfo(relationship) {
|
|
807
815
|
const peerAddress = relationship.peer.address;
|
|
808
816
|
const truncatedAddress = peerAddress.address.substring(3, 9);
|
|
809
|
-
|
|
817
|
+
const info = await RelationshipInfo_1.RelationshipInfo.from({
|
|
810
818
|
attributes: [],
|
|
811
819
|
id: await consumption_1.ConsumptionIds.relationshipInfo.generate(),
|
|
812
820
|
isPinned: false,
|
|
813
821
|
relationshipId: relationship.id,
|
|
814
822
|
title: truncatedAddress
|
|
815
823
|
});
|
|
816
|
-
info = await this.parent.relationshipInfo.createRelationshipInfo(info)
|
|
824
|
+
// info = await this.parent.relationshipInfo.createRelationshipInfo(info)
|
|
817
825
|
const items = await this.parent.sharedItems.getSharedItems({
|
|
818
826
|
sharedBy: relationship.peer.address.toString()
|
|
819
827
|
});
|
|
@@ -833,15 +841,15 @@ class RelationshipInfoUtil {
|
|
|
833
841
|
info.attributes = attributes;
|
|
834
842
|
const title = this.getTitle(relationship, attributeMap);
|
|
835
843
|
info.title = title;
|
|
836
|
-
await this.parent.relationshipInfo.updateRelationshipInfo(info)
|
|
844
|
+
// await this.parent.relationshipInfo.updateRelationshipInfo(info)
|
|
837
845
|
return info;
|
|
838
846
|
}
|
|
839
847
|
async parseTemplateBody(relationship, template) {
|
|
840
848
|
if (!template.cache) {
|
|
841
849
|
throw transport_1.TransportErrors.general.cacheEmpty(transport_1.RelationshipTemplate, template.id.toString()).logWith(this._log);
|
|
842
850
|
}
|
|
843
|
-
const isTemplator = this.parent.accountController.identity.isMe(template.cache.createdBy);
|
|
844
851
|
if (template.cache.content instanceof content_1.RelationshipTemplateBody) {
|
|
852
|
+
const isTemplator = this.parent.accountController.identity.isMe(template.cache.createdBy);
|
|
845
853
|
const body = template.cache.content;
|
|
846
854
|
const attributes = body.sharedAttributes;
|
|
847
855
|
if (attributes) {
|
|
@@ -852,33 +860,46 @@ class RelationshipInfoUtil {
|
|
|
852
860
|
const sharedWith = isTemplator
|
|
853
861
|
? relationship.peer.address
|
|
854
862
|
: this.parent.accountController.identity.address;
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
863
|
+
const sharedItemsWithSameReference = await this.parent.sharedItems.getSharedItems({
|
|
864
|
+
reference: template.id.toString()
|
|
865
|
+
});
|
|
866
|
+
if (sharedItemsWithSameReference.length !== attributes.length) {
|
|
867
|
+
const missingItems = [];
|
|
868
|
+
attributes.forEach((attribute) => {
|
|
869
|
+
if (!sharedItemsWithSameReference.find(function (item) {
|
|
870
|
+
const content = item.content;
|
|
871
|
+
return content.name === attribute.name;
|
|
872
|
+
})) {
|
|
873
|
+
missingItems.push(attribute);
|
|
874
|
+
}
|
|
864
875
|
});
|
|
865
|
-
|
|
876
|
+
for (const attribute of missingItems) {
|
|
877
|
+
const sharedItem = await SharedItem_1.SharedItem.from({
|
|
878
|
+
id: await consumption_1.ConsumptionIds.sharedItem.generate(),
|
|
879
|
+
content: attribute,
|
|
880
|
+
sharedAt: sharedAt,
|
|
881
|
+
sharedBy: sharedBy,
|
|
882
|
+
sharedWith: sharedWith,
|
|
883
|
+
reference: template.id,
|
|
884
|
+
expiresAt: attribute.validTo
|
|
885
|
+
});
|
|
886
|
+
await this.parent.sharedItems.createSharedItem(sharedItem);
|
|
887
|
+
}
|
|
866
888
|
}
|
|
867
889
|
}
|
|
868
890
|
}
|
|
891
|
+
else {
|
|
892
|
+
// do nothing, we don't know the content
|
|
893
|
+
}
|
|
869
894
|
}
|
|
870
895
|
async parseCreationRequest(relationship) {
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
const error = new Error("error.consumption.noRequestContent");
|
|
874
|
-
this._log.error(error);
|
|
875
|
-
throw error;
|
|
876
|
-
}
|
|
877
|
-
const isRequestor = this.parent.accountController.identity.isMe(request.createdBy);
|
|
896
|
+
const change = relationship.cache.creationChange;
|
|
897
|
+
const request = change.request;
|
|
878
898
|
if (request.content instanceof content_1.RelationshipCreationChangeRequestBody) {
|
|
899
|
+
const isRequestor = this.parent.accountController.identity.isMe(request.createdBy);
|
|
879
900
|
const body = request.content;
|
|
880
901
|
const attributes = body.sharedAttributes;
|
|
881
|
-
if (attributes) {
|
|
902
|
+
if (attributes && attributes.length > 0) {
|
|
882
903
|
const sharedAt = request.createdAt;
|
|
883
904
|
const sharedBy = isRequestor
|
|
884
905
|
? this.parent.accountController.identity.address
|
|
@@ -886,22 +907,36 @@ class RelationshipInfoUtil {
|
|
|
886
907
|
const sharedWith = isRequestor
|
|
887
908
|
? relationship.peer.address
|
|
888
909
|
: this.parent.accountController.identity.address;
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
910
|
+
const sharedItemsWithSameReference = await this.parent.sharedItems.getSharedItems({
|
|
911
|
+
reference: change.id.toString()
|
|
912
|
+
});
|
|
913
|
+
if (sharedItemsWithSameReference.length !== attributes.length) {
|
|
914
|
+
const missingItems = [];
|
|
915
|
+
attributes.forEach((attribute) => {
|
|
916
|
+
if (!sharedItemsWithSameReference.find(function (item) {
|
|
917
|
+
const content = item.content;
|
|
918
|
+
return content.name === attribute.name;
|
|
919
|
+
})) {
|
|
920
|
+
missingItems.push(attribute);
|
|
921
|
+
}
|
|
898
922
|
});
|
|
899
|
-
|
|
923
|
+
for (const attribute of missingItems) {
|
|
924
|
+
const sharedItem = await SharedItem_1.SharedItem.from({
|
|
925
|
+
id: await consumption_1.ConsumptionIds.sharedItem.generate(),
|
|
926
|
+
content: attribute,
|
|
927
|
+
sharedAt: sharedAt,
|
|
928
|
+
sharedBy: sharedBy,
|
|
929
|
+
sharedWith: sharedWith,
|
|
930
|
+
reference: change.id,
|
|
931
|
+
expiresAt: attribute.validTo
|
|
932
|
+
});
|
|
933
|
+
await this.parent.sharedItems.createSharedItem(sharedItem);
|
|
934
|
+
}
|
|
900
935
|
}
|
|
901
936
|
}
|
|
902
937
|
}
|
|
903
938
|
else {
|
|
904
|
-
|
|
939
|
+
// do nothing, we don't know the content
|
|
905
940
|
}
|
|
906
941
|
}
|
|
907
942
|
}
|