@shaxpir/duiduidui-models 1.6.13 → 1.6.15
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/models/Profile.js +3 -3
- package/dist/models/Social.d.ts +8 -0
- package/dist/models/Social.js +24 -1
- package/package.json +1 -1
package/dist/models/Profile.js
CHANGED
|
@@ -148,15 +148,15 @@ class Profile extends Content_1.Content {
|
|
|
148
148
|
}
|
|
149
149
|
// Allow a wide range of characters for international names
|
|
150
150
|
// - Letters from any language (Unicode letters)
|
|
151
|
-
// - Spaces, hyphens, apostrophes, periods (common in names)
|
|
151
|
+
// - Spaces, hyphens, apostrophes, periods, commas (common in names)
|
|
152
152
|
// - Chinese characters (CJK Unified Ideographs)
|
|
153
153
|
// Reject control characters, emojis, and other special characters
|
|
154
|
-
const validPattern = /^[\p{L}\p{M}\s'
|
|
154
|
+
const validPattern = /^[\p{L}\p{M}\s'\-\.,]+$/u;
|
|
155
155
|
if (!validPattern.test(fullName)) {
|
|
156
156
|
return {
|
|
157
157
|
isValid: false,
|
|
158
158
|
reason: 'invalid_characters',
|
|
159
|
-
message: 'Full name contains invalid characters. Only letters, spaces, hyphens, apostrophes, and
|
|
159
|
+
message: 'Full name contains invalid characters. Only letters, spaces, hyphens, apostrophes, periods, and commas are allowed'
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
// Check for reasonable structure (not just whitespace/punctuation)
|
package/dist/models/Social.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export declare enum FriendRequestStatus {
|
|
|
8
8
|
ACCEPTED = "accepted",
|
|
9
9
|
REJECTED = "rejected"
|
|
10
10
|
}
|
|
11
|
+
export declare enum SharingLevel {
|
|
12
|
+
FRIEND = "friend",// Default sharing level - basic progress visibility
|
|
13
|
+
TEACHER = "teacher"
|
|
14
|
+
}
|
|
11
15
|
export interface SocialUser {
|
|
12
16
|
user_id: ContentId;
|
|
13
17
|
username: string;
|
|
@@ -25,6 +29,8 @@ export interface FriendRequest {
|
|
|
25
29
|
}
|
|
26
30
|
export interface Friend extends SocialUser {
|
|
27
31
|
since: CompactDateTime;
|
|
32
|
+
my_sharing_level: SharingLevel;
|
|
33
|
+
their_sharing_level: SharingLevel;
|
|
28
34
|
}
|
|
29
35
|
export interface BlockedUser extends SocialUser {
|
|
30
36
|
blocked_at: CompactDateTime;
|
|
@@ -55,6 +61,8 @@ export declare class Social extends Content {
|
|
|
55
61
|
addFriend(friend: Friend): void;
|
|
56
62
|
removeFriend(userId: ContentId): void;
|
|
57
63
|
isFriend(userId: ContentId): boolean;
|
|
64
|
+
updateMySharingLevel(userId: ContentId, sharingLevel: SharingLevel): void;
|
|
65
|
+
updateTheirSharingLevel(userId: ContentId, sharingLevel: SharingLevel): void;
|
|
58
66
|
getBlockedUsers(): BlockedUser[];
|
|
59
67
|
addBlockedUser(blockedUser: BlockedUser): void;
|
|
60
68
|
removeBlockedUser(userId: ContentId): void;
|
package/dist/models/Social.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Social = exports.FriendRequestStatus = void 0;
|
|
3
|
+
exports.Social = exports.SharingLevel = exports.FriendRequestStatus = void 0;
|
|
4
4
|
const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
|
|
5
5
|
const repo_1 = require("../repo");
|
|
6
6
|
const Content_1 = require("./Content");
|
|
@@ -12,6 +12,11 @@ var FriendRequestStatus;
|
|
|
12
12
|
FriendRequestStatus["ACCEPTED"] = "accepted";
|
|
13
13
|
FriendRequestStatus["REJECTED"] = "rejected";
|
|
14
14
|
})(FriendRequestStatus || (exports.FriendRequestStatus = FriendRequestStatus = {}));
|
|
15
|
+
var SharingLevel;
|
|
16
|
+
(function (SharingLevel) {
|
|
17
|
+
SharingLevel["FRIEND"] = "friend";
|
|
18
|
+
SharingLevel["TEACHER"] = "teacher"; // Enhanced sharing - detailed progress and learning insights
|
|
19
|
+
})(SharingLevel || (exports.SharingLevel = SharingLevel = {}));
|
|
15
20
|
class Social extends Content_1.Content {
|
|
16
21
|
static makeSocialId(userId) {
|
|
17
22
|
return shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.SOCIAL);
|
|
@@ -118,6 +123,24 @@ class Social extends Content_1.Content {
|
|
|
118
123
|
this.checkDisposed("Social.isFriend");
|
|
119
124
|
return this.payload.friends.some(f => f.user_id === userId);
|
|
120
125
|
}
|
|
126
|
+
updateMySharingLevel(userId, sharingLevel) {
|
|
127
|
+
this.checkDisposed("Social.updateMySharingLevel");
|
|
128
|
+
const index = this.payload.friends.findIndex(f => f.user_id === userId);
|
|
129
|
+
if (index !== -1) {
|
|
130
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
131
|
+
batch.setPathValue(['payload', 'friends', index, 'my_sharing_level'], sharingLevel);
|
|
132
|
+
batch.commit();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
updateTheirSharingLevel(userId, sharingLevel) {
|
|
136
|
+
this.checkDisposed("Social.updateTheirSharingLevel");
|
|
137
|
+
const index = this.payload.friends.findIndex(f => f.user_id === userId);
|
|
138
|
+
if (index !== -1) {
|
|
139
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
140
|
+
batch.setPathValue(['payload', 'friends', index, 'their_sharing_level'], sharingLevel);
|
|
141
|
+
batch.commit();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
121
144
|
// ========== Blocked Users ==========
|
|
122
145
|
getBlockedUsers() {
|
|
123
146
|
this.checkDisposed("Social.getBlockedUsers");
|