@amityco/ts-sdk 7.29.1-0cb2e19.0 → 7.29.1-3be7ca5e.0
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/@types/core/errors.d.ts +2 -1
- package/dist/@types/core/errors.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +64 -0
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/index.cjs.js +315 -73
- package/dist/index.esm.js +317 -75
- package/dist/index.umd.js +2 -2
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/postRepository/api/tests/integration/setup.d.ts +3 -3
- package/dist/report/api/isReportedByMe.d.ts.map +1 -1
- package/dist/userRepository/api/flagUser.d.ts.map +1 -1
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts +26 -4
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts.map +1 -1
- package/dist/userRepository/api/queryBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/api/unflagUser.d.ts +26 -4
- package/dist/userRepository/api/unflagUser.d.ts.map +1 -1
- package/dist/userRepository/api/updateUser.d.ts.map +1 -1
- package/dist/userRepository/internalApi/getFlagsByMe.d.ts +21 -0
- package/dist/userRepository/internalApi/getFlagsByMe.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts +2 -2
- package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockingUsers/LiveCollectionController.d.ts +1 -1
- package/dist/userRepository/observers/getBlockingUsers/LiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/observers/getUsers/UserLiveCollectionController.d.ts +2 -2
- package/dist/userRepository/observers/getUsers/UserLiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/observers/searchUserByDisplayName/SearchUserLiveCollectionController.d.ts +2 -2
- package/dist/userRepository/observers/searchUserByDisplayName/SearchUserLiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/utils/submitUserReport.d.ts.map +1 -1
- package/dist/userRepository/utils/userReport.d.ts +16 -1
- package/dist/userRepository/utils/userReport.d.ts.map +1 -1
- package/dist/utils/bloomFilter.d.ts +9 -0
- package/dist/utils/bloomFilter.d.ts.map +1 -0
- package/dist/utils/linkedObject/tests/userLinkedObject.test.d.ts +2 -0
- package/dist/utils/linkedObject/tests/userLinkedObject.test.d.ts.map +1 -0
- package/dist/utils/linkedObject/userLinkedObject.d.ts.map +1 -1
- package/dist/utils/tests/bloomFilter.test.d.ts +2 -0
- package/dist/utils/tests/bloomFilter.test.d.ts.map +1 -0
- package/dist/utils/tests/client.d.ts +1 -1
- package/dist/utils/tests/client.d.ts.map +1 -1
- package/dist/utils/tests/dummy/channel.d.ts +9 -9
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/dist/utils/tests/dummy/community.d.ts +3 -3
- package/dist/utils/tests/dummy/message.d.ts +1 -1
- package/dist/utils/tests/dummy/token.d.ts +1 -1
- package/dist/utils/tests/dummy/user.d.ts +10 -12
- package/dist/utils/tests/dummy/user.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -28,7 +28,8 @@ declare global {
|
|
|
28
28
|
VISITOR_USAGE_LIMIT_EXCEEDED = 400323,
|
|
29
29
|
FEED_SNAPSHOT_EXPIRED = 400322,
|
|
30
30
|
MAX_BLOCKED_USERS_REACHED = 400324,
|
|
31
|
-
MODULE_NOT_ENTITLED = 400325
|
|
31
|
+
MODULE_NOT_ENTITLED = 400325,
|
|
32
|
+
VISITOR_REPORT_DENIED = 488999
|
|
32
33
|
}
|
|
33
34
|
const enum ClientError {
|
|
34
35
|
UNKNOWN_ERROR = 800000,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/@types/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,UAAU;YACnB,KAAK,UAAU;YACf,KAAK,UAAU;SAChB;QAED,WAAW,WAAW;YACpB,WAAW,SAAS;YACpB,YAAY,SAAS;YACrB,iBAAiB,SAAS;YAC1B,cAAc,SAAS;YACvB,QAAQ,SAAS;YACjB,SAAS,SAAS;YAClB,aAAa,SAAS;YACtB,gBAAgB,SAAS;YACzB,WAAW,SAAS;YACpB,UAAU,SAAS;YACnB,WAAW,SAAS;YACpB,cAAc,SAAS;YACvB,0BAA0B,SAAS;YACnC,uBAAuB,SAAS;YAChC,cAAc,SAAS;YACvB,gBAAgB,SAAS;YACzB,cAAc,SAAS;YACvB,yBAAyB,SAAS;YAClC,qBAAqB,SAAS;YAC9B,4BAA4B,SAAS;YACrC,qBAAqB,SAAS;YAC9B,yBAAyB,SAAS;YAClC,mBAAmB,SAAS;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/@types/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,UAAU;YACnB,KAAK,UAAU;YACf,KAAK,UAAU;SAChB;QAED,WAAW,WAAW;YACpB,WAAW,SAAS;YACpB,YAAY,SAAS;YACrB,iBAAiB,SAAS;YAC1B,cAAc,SAAS;YACvB,QAAQ,SAAS;YACjB,SAAS,SAAS;YAClB,aAAa,SAAS;YACtB,gBAAgB,SAAS;YACzB,WAAW,SAAS;YACpB,UAAU,SAAS;YACnB,WAAW,SAAS;YACpB,cAAc,SAAS;YACvB,0BAA0B,SAAS;YACnC,uBAAuB,SAAS;YAChC,cAAc,SAAS;YACvB,gBAAgB,SAAS;YACzB,cAAc,SAAS;YACvB,yBAAyB,SAAS;YAClC,qBAAqB,SAAS;YAC9B,4BAA4B,SAAS;YACrC,qBAAqB,SAAS;YAC9B,yBAAyB,SAAS;YAClC,mBAAmB,SAAS;YAE5B,qBAAqB,SAAS;SAC/B;QAED,WAAW,WAAW;YACpB,aAAa,SAAS;YACtB,kBAAkB,SAAS;YAC3B,iBAAiB,SAAS;YAC1B,gBAAgB,SAAS;YACzB,YAAY,SAAS;YACrB,aAAa,SAAS;YACtB,wBAAwB,SAAS;SAClC;QAED,KAAK,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;KAC5C;CACF"}
|
|
@@ -27,6 +27,20 @@ export declare enum UserProfileFieldEnum {
|
|
|
27
27
|
DESCRIPTION = "description",
|
|
28
28
|
AVATAR = "avatarFileId"
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Selects which of the caller's reports `UserRepository.unflagUser` withdraws, sent as the
|
|
32
|
+
* `reportType` query parameter. The four typed members are the backend `reportType` wire
|
|
33
|
+
* values and match `UserReportTypeEnum`. `UNTYPED` selects the typeless (legacy) report,
|
|
34
|
+
* which `isUserFlaggedByMe` returns as `reportType: null`; it is a selector only, never
|
|
35
|
+
* stored, and the flag endpoint refuses it.
|
|
36
|
+
*/
|
|
37
|
+
export declare enum UserReportTypeFilterEnum {
|
|
38
|
+
DISPLAY_NAME = "displayName",
|
|
39
|
+
DESCRIPTION = "description",
|
|
40
|
+
AVATAR = "avatarFileId",
|
|
41
|
+
BEHAVIOR = "behavior",
|
|
42
|
+
UNTYPED = "untyped"
|
|
43
|
+
}
|
|
30
44
|
export {};
|
|
31
45
|
declare global {
|
|
32
46
|
namespace Amity {
|
|
@@ -70,6 +84,36 @@ declare global {
|
|
|
70
84
|
reason: ContentFlagReasonEnum;
|
|
71
85
|
comment?: string;
|
|
72
86
|
};
|
|
87
|
+
type UserReportTypeFilter = `${UserReportTypeFilterEnum}`;
|
|
88
|
+
/**
|
|
89
|
+
* Options of `UserRepository.unflagUser`. Omit `reportType` to withdraw every report
|
|
90
|
+
* the caller filed on the user; pass one to withdraw only that report.
|
|
91
|
+
*/
|
|
92
|
+
type UserReportTypeFilterOptions = {
|
|
93
|
+
reportType?: Amity.UserReportTypeFilter;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* One of the caller's own reports on a user, as the backend returns it in
|
|
97
|
+
* `UserRepository.isUserFlaggedByMe`. Every field is always present; a field the
|
|
98
|
+
* report does not carry is `null`. `reportType: null` is the typeless report (withdrawn
|
|
99
|
+
* with `UserReportTypeFilterEnum.UNTYPED`) and `createdAt: null` marks a report filed
|
|
100
|
+
* before report types existed.
|
|
101
|
+
*/
|
|
102
|
+
type UserFlag = {
|
|
103
|
+
reportType: `${UserReportTypeEnum}` | null;
|
|
104
|
+
reason: string | null;
|
|
105
|
+
comment: string | null;
|
|
106
|
+
createdAt: string | null;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Result of `UserRepository.isUserFlaggedByMe`: the `GET /api/v4/users/:userId/isFlagByMe`
|
|
110
|
+
* payload as is. `isFlagByMe` says whether the caller holds any report on the user;
|
|
111
|
+
* `flags` lists the caller's own reports. Other users' reports are never included.
|
|
112
|
+
*/
|
|
113
|
+
type UserFlagByMe = {
|
|
114
|
+
isFlagByMe: boolean;
|
|
115
|
+
flags: Amity.UserFlag[];
|
|
116
|
+
};
|
|
73
117
|
type RawUser = {
|
|
74
118
|
_id: string;
|
|
75
119
|
userId: string;
|
|
@@ -87,6 +131,26 @@ declare global {
|
|
|
87
131
|
} & Amity.Metadata & Amity.Taggable & Amity.Flaggable & Amity.Accredited & Amity.Timestamps & Amity.SoftDelete & Amity.Subscribable;
|
|
88
132
|
type User = Amity.InternalUser & {
|
|
89
133
|
avatar?: Amity.File<'image'> | null;
|
|
134
|
+
/**
|
|
135
|
+
* Whether the current user has probably flagged this user, computed locally from
|
|
136
|
+
* `hashFlag` (a Bloom filter of reporter ids) with no request. `false` is exact; `true`
|
|
137
|
+
* may be a false positive, and it says nothing about the report type. For the exact,
|
|
138
|
+
* per-type answer call `getUserFlagsByMe()`.
|
|
139
|
+
*
|
|
140
|
+
* It reflects this object as of its last update. A user object is a snapshot: an instance
|
|
141
|
+
* you already hold does not change after a flag or unflag. Observe the user with
|
|
142
|
+
* `UserRepository.getUser(userId, callback)` and read `isFlaggedByMe` from each
|
|
143
|
+
* notification to keep a badge current; a report filed on another device shows once the
|
|
144
|
+
* user is refreshed.
|
|
145
|
+
*/
|
|
146
|
+
readonly isFlaggedByMe: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* The current user's own reports on this user, from `GET /api/v4/users/:userId/isFlagByMe`.
|
|
149
|
+
* When `isFlaggedByMe` is `false` (exact, as of this user object's last update) it resolves
|
|
150
|
+
* `{ isFlagByMe: false, flags: [] }` without a request; otherwise it reads the server and
|
|
151
|
+
* returns the payload as is, including `isFlagByMe: false` after a Bloom false positive.
|
|
152
|
+
*/
|
|
153
|
+
getUserFlagsByMe: () => Promise<Amity.UserFlagByMe>;
|
|
90
154
|
};
|
|
91
155
|
type QueryUsers = {
|
|
92
156
|
filter?: 'all' | 'flagged';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,0BAAkB,YAAY;IAC5B,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,GAAG,QAAQ;CACZ;AAED,oBAAY,iBAAiB;IAC3B,YAAY,gBAAgB;IAC5B,cAAc,kBAAkB;IAChC,OAAO,WAAW;CACnB;AAED,oBAAY,kBAAkB;IAC5B,YAAY,gBAAgB;IAC5B,WAAW,gBAAgB;IAC3B,MAAM,iBAAiB;IACvB,QAAQ,aAAa;CACtB;AAED;;;;;GAKG;AACH,oBAAY,oBAAoB;IAC9B,YAAY,gBAAgB;IAC5B,WAAW,gBAAgB;IAC3B,MAAM,iBAAiB;CACxB;AAED,OAAO,EAAE,CAAC;AAE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AQ,CAAC,CACvC,CAAC;QAEF,KAAK,wBAAwB,GAAG,KAAK,CAAC,wBAAwB,CAAC;QAE/D,KAAK,uBAAuB,GAAG,KAAK,CAAC,mBAAmB,CACtD,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,EAC5B,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CACzB,CAAC;KACH;CACF"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -70,6 +70,21 @@ exports.UserProfileFieldEnum = void 0;
|
|
|
70
70
|
UserProfileFieldEnum["DESCRIPTION"] = "description";
|
|
71
71
|
UserProfileFieldEnum["AVATAR"] = "avatarFileId";
|
|
72
72
|
})(exports.UserProfileFieldEnum || (exports.UserProfileFieldEnum = {}));
|
|
73
|
+
/**
|
|
74
|
+
* Selects which of the caller's reports `UserRepository.unflagUser` withdraws, sent as the
|
|
75
|
+
* `reportType` query parameter. The four typed members are the backend `reportType` wire
|
|
76
|
+
* values and match `UserReportTypeEnum`. `UNTYPED` selects the typeless (legacy) report,
|
|
77
|
+
* which `isUserFlaggedByMe` returns as `reportType: null`; it is a selector only, never
|
|
78
|
+
* stored, and the flag endpoint refuses it.
|
|
79
|
+
*/
|
|
80
|
+
exports.UserReportTypeFilterEnum = void 0;
|
|
81
|
+
(function (UserReportTypeFilterEnum) {
|
|
82
|
+
UserReportTypeFilterEnum["DISPLAY_NAME"] = "displayName";
|
|
83
|
+
UserReportTypeFilterEnum["DESCRIPTION"] = "description";
|
|
84
|
+
UserReportTypeFilterEnum["AVATAR"] = "avatarFileId";
|
|
85
|
+
UserReportTypeFilterEnum["BEHAVIOR"] = "behavior";
|
|
86
|
+
UserReportTypeFilterEnum["UNTYPED"] = "untyped";
|
|
87
|
+
})(exports.UserReportTypeFilterEnum || (exports.UserReportTypeFilterEnum = {}));
|
|
73
88
|
|
|
74
89
|
const FileType = Object.freeze({
|
|
75
90
|
FILE: 'file',
|
|
@@ -1837,18 +1852,167 @@ async function modifyMqttConnection() {
|
|
|
1837
1852
|
}
|
|
1838
1853
|
}
|
|
1839
1854
|
|
|
1855
|
+
/**
|
|
1856
|
+
* ```js
|
|
1857
|
+
* import { getFlagsByMe } from '~/userRepository/internalApi/getFlagsByMe'
|
|
1858
|
+
* const { isFlagByMe, flags } = await getFlagsByMe('userId')
|
|
1859
|
+
* ```
|
|
1860
|
+
*
|
|
1861
|
+
* The v4 read behind `user.getUserFlagsByMe()` and the deprecated
|
|
1862
|
+
* `UserRepository.isUserFlaggedByMe`: `GET /api/v4/users/:userId/isFlagByMe`, returned as
|
|
1863
|
+
* received. Nothing is filtered, cached or persisted, and `hashFlag` is not consulted here.
|
|
1864
|
+
* This is the Web counterpart of iOS `ASCUserService.getFlagsByMe` and Android
|
|
1865
|
+
* `UserRepository.getFlagsByMe`, kept apart from the deprecated public function so the
|
|
1866
|
+
* user-object read does not change if that function ever does.
|
|
1867
|
+
*
|
|
1868
|
+
* @param userId The ID of the user whose reports by the caller are read
|
|
1869
|
+
* @returns the caller's {@link Amity.UserFlagByMe} on that user
|
|
1870
|
+
*
|
|
1871
|
+
* @category Private
|
|
1872
|
+
* @async
|
|
1873
|
+
*/
|
|
1874
|
+
const getFlagsByMe = async (userId) => {
|
|
1875
|
+
const client = getActiveClient();
|
|
1876
|
+
client.log('user/getFlagsByMe', userId);
|
|
1877
|
+
const { data } = await client.http.get(`/api/v4/users/${encodeURIComponent(userId)}/isFlagByMe`);
|
|
1878
|
+
return data;
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
/* eslint-disable no-bitwise */
|
|
1882
|
+
/**
|
|
1883
|
+
* Client-side test of the `hashFlag` Bloom filter the backend attaches to flaggable objects.
|
|
1884
|
+
*
|
|
1885
|
+
* The filter holds the ids of every user who flagged the object: `bits` is its size, `hashes`
|
|
1886
|
+
* the number of hash functions per id and `hash` the bit array, base64-encoded. This is a port
|
|
1887
|
+
* of the test iOS (`_BloomFilter`) and Android (`EkoBloomFilter`) already run: FNV-1a 32-bit
|
|
1888
|
+
* over the UTF-8 bytes of the id with seeds `0` and `1576284489`, combined by double hashing
|
|
1889
|
+
* (`(a + i·b) mod bits`). A Bloom filter has no false negatives, so `false` is exact; `true`
|
|
1890
|
+
* means "probably", because another id's hashes may have set the same bits. The filter knows
|
|
1891
|
+
* nothing about report types.
|
|
1892
|
+
*/
|
|
1893
|
+
const FNV_OFFSET_BASIS = 0x811c9dc5;
|
|
1894
|
+
const FNV_PRIME = 16777619;
|
|
1895
|
+
const SECOND_SEED = 1576284489;
|
|
1896
|
+
/** FNV-1a with the same mixing step and signed-byte handling as the native SDKs. */
|
|
1897
|
+
const fnv1a = (bytes, seed) => {
|
|
1898
|
+
let a = (FNV_OFFSET_BASIS ^ seed) >>> 0;
|
|
1899
|
+
for (let i = 0; i < bytes.length; i += 1) {
|
|
1900
|
+
// Bytes are `char` on iOS and `byte` on Android: both signed, so 0x80..0xff sign-extend.
|
|
1901
|
+
const byte = bytes[i] > 127 ? bytes[i] - 256 : bytes[i];
|
|
1902
|
+
a = Math.imul((a ^ byte) >>> 0, FNV_PRIME) >>> 0;
|
|
1903
|
+
}
|
|
1904
|
+
a = (a + (a << 13)) >>> 0;
|
|
1905
|
+
a = (a ^ (a >>> 7)) >>> 0;
|
|
1906
|
+
a = (a + (a << 3)) >>> 0;
|
|
1907
|
+
a = (a ^ (a >>> 17)) >>> 0;
|
|
1908
|
+
a = (a + (a << 5)) >>> 0;
|
|
1909
|
+
return a;
|
|
1910
|
+
};
|
|
1911
|
+
/** Bit positions for `value`, reproducing the native SDKs' signed 32-bit arithmetic. */
|
|
1912
|
+
const locationsFor = (value, bits, hashes) => {
|
|
1913
|
+
const bytes = jsBase64.toUint8Array(jsBase64.encode(value)); // UTF-8 bytes of the id
|
|
1914
|
+
const a = fnv1a(bytes, 0) | 0;
|
|
1915
|
+
const b = fnv1a(bytes, SECOND_SEED) | 0;
|
|
1916
|
+
const locations = [];
|
|
1917
|
+
let x = a % bits;
|
|
1918
|
+
for (let i = 0; i < hashes; i += 1) {
|
|
1919
|
+
locations.push(x < 0 ? x + bits : x);
|
|
1920
|
+
x = ((x + b) | 0) % bits;
|
|
1921
|
+
}
|
|
1922
|
+
return locations;
|
|
1923
|
+
};
|
|
1924
|
+
/**
|
|
1925
|
+
* Whether `value` is probably in the filter. `false` is exact; `true` may be a false positive.
|
|
1926
|
+
* A missing filter (`null`, the server's value when nobody has flagged the object), a missing
|
|
1927
|
+
* value or a malformed filter all answer `false`.
|
|
1928
|
+
*/
|
|
1929
|
+
const testBloomFilter = (hashFlag, value) => {
|
|
1930
|
+
if (!hashFlag || !value)
|
|
1931
|
+
return false;
|
|
1932
|
+
const { bits, hashes, hash } = hashFlag;
|
|
1933
|
+
if (!(bits > 0) || !(hashes > 0) || typeof hash !== 'string')
|
|
1934
|
+
return false;
|
|
1935
|
+
let buckets;
|
|
1936
|
+
try {
|
|
1937
|
+
buckets = jsBase64.toUint8Array(hash);
|
|
1938
|
+
}
|
|
1939
|
+
catch (_a) {
|
|
1940
|
+
return false;
|
|
1941
|
+
}
|
|
1942
|
+
const locations = locationsFor(value, bits, hashes);
|
|
1943
|
+
for (let i = 0; i < locations.length; i += 1) {
|
|
1944
|
+
const index = Math.floor(locations[i] / 8);
|
|
1945
|
+
const bit = 1 << locations[i] % 8;
|
|
1946
|
+
if (index >= buckets.length || (buckets[index] & bit) === 0)
|
|
1947
|
+
return false;
|
|
1948
|
+
}
|
|
1949
|
+
return true;
|
|
1950
|
+
};
|
|
1951
|
+
|
|
1952
|
+
/** The current user's id, or `undefined` when there is no active client (the getter never throws). */
|
|
1953
|
+
const currentUserId = () => {
|
|
1954
|
+
try {
|
|
1955
|
+
return getActiveClient().userId;
|
|
1956
|
+
}
|
|
1957
|
+
catch (_a) {
|
|
1958
|
+
return undefined;
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
/**
|
|
1962
|
+
* One `getUserFlagsByMe` closure per userId, remembering the newest user object linked for
|
|
1963
|
+
* that id. Live objects and collections compare snapshots with `isEqual`, which compares
|
|
1964
|
+
* functions by reference: a fresh closure on every linked object would make two reads of the
|
|
1965
|
+
* same user unequal and re-dispatch snapshots that did not change.
|
|
1966
|
+
*/
|
|
1967
|
+
const flagsByMeEntries = new Map();
|
|
1968
|
+
/**
|
|
1969
|
+
* A Bloom filter has no false negatives, so `isFlaggedByMe === false` is exact and the request
|
|
1970
|
+
* can be skipped (REQ-012). The newest user object linked for that id is tested, as of its last
|
|
1971
|
+
* update. Without a filter to test, or without a current user, the server is asked.
|
|
1972
|
+
*/
|
|
1973
|
+
const knownNotFlaggedByMe = (userId) => {
|
|
1974
|
+
var _a;
|
|
1975
|
+
const me = currentUserId();
|
|
1976
|
+
const user = (_a = flagsByMeEntries.get(userId)) === null || _a === void 0 ? void 0 : _a.latest;
|
|
1977
|
+
if (!me || !user || user.hashFlag === undefined)
|
|
1978
|
+
return false;
|
|
1979
|
+
return !testBloomFilter(user.hashFlag, me);
|
|
1980
|
+
};
|
|
1981
|
+
const getUserFlagsByMeFor = (user) => {
|
|
1982
|
+
let entry = flagsByMeEntries.get(user.userId);
|
|
1983
|
+
if (!entry) {
|
|
1984
|
+
entry = {
|
|
1985
|
+
latest: user,
|
|
1986
|
+
getUserFlagsByMe: async () => {
|
|
1987
|
+
if (knownNotFlaggedByMe(user.userId))
|
|
1988
|
+
return { isFlagByMe: false, flags: [] };
|
|
1989
|
+
return getFlagsByMe(user.userId);
|
|
1990
|
+
},
|
|
1991
|
+
};
|
|
1992
|
+
flagsByMeEntries.set(user.userId, entry);
|
|
1993
|
+
}
|
|
1994
|
+
entry.latest = user;
|
|
1995
|
+
return entry.getUserFlagsByMe;
|
|
1996
|
+
};
|
|
1840
1997
|
const userLinkedObject = (user) => {
|
|
1841
1998
|
return Object.assign(Object.assign({}, user), { get avatar() {
|
|
1842
1999
|
var _a;
|
|
1843
2000
|
if (!user.avatarFileId)
|
|
1844
|
-
return
|
|
1845
|
-
const avatar = (_a = pullFromCache([
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
`${user.avatarFileId}`,
|
|
1849
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
2001
|
+
return null;
|
|
2002
|
+
const avatar = (_a = pullFromCache(['file', 'get', user.avatarFileId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
2003
|
+
if (!avatar)
|
|
2004
|
+
return null;
|
|
1850
2005
|
return avatar;
|
|
1851
|
-
}
|
|
2006
|
+
},
|
|
2007
|
+
get isFlaggedByMe() {
|
|
2008
|
+
// Local Bloom-filter test on this object's own hashFlag: exact when false, "probably"
|
|
2009
|
+
// when true, type-blind, no request. getUserFlagsByMe() gives the exact, per-type answer.
|
|
2010
|
+
return testBloomFilter(user.hashFlag, currentUserId());
|
|
2011
|
+
},
|
|
2012
|
+
/* begin_public_function
|
|
2013
|
+
id: user.get_flags_by_me
|
|
2014
|
+
*/
|
|
2015
|
+
getUserFlagsByMe: getUserFlagsByMeFor(user) });
|
|
1852
2016
|
};
|
|
1853
2017
|
|
|
1854
2018
|
/* begin_public_function
|
|
@@ -3097,12 +3261,19 @@ const getSubChannelMessagePreview = (subChannelId) => {
|
|
|
3097
3261
|
};
|
|
3098
3262
|
|
|
3099
3263
|
const getSubChannelMessagePreviewWithUser = (subChannel) => {
|
|
3100
|
-
var _a;
|
|
3101
3264
|
const messagePreview = subChannel.messagePreviewId
|
|
3102
3265
|
? getSubChannelMessagePreview(subChannel.subChannelId)
|
|
3103
3266
|
: null;
|
|
3104
3267
|
const messagePreviewWithUser = messagePreview
|
|
3105
|
-
? Object.assign(Object.assign({}, messagePreview), { user: (
|
|
3268
|
+
? Object.assign(Object.assign({}, messagePreview), { user: (() => {
|
|
3269
|
+
var _a;
|
|
3270
|
+
const internalUser = (_a = pullFromCache([
|
|
3271
|
+
'user',
|
|
3272
|
+
'get',
|
|
3273
|
+
messagePreview === null || messagePreview === void 0 ? void 0 : messagePreview.creatorId,
|
|
3274
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
3275
|
+
return internalUser ? userLinkedObject(internalUser) : undefined;
|
|
3276
|
+
})() }) : null;
|
|
3106
3277
|
return Object.assign(Object.assign({}, subChannel), { messagePreview: messagePreviewWithUser });
|
|
3107
3278
|
};
|
|
3108
3279
|
|
|
@@ -15407,7 +15578,7 @@ const updateUser = async (userId, patch) => {
|
|
|
15407
15578
|
ingestInCache(payload, { cachedAt });
|
|
15408
15579
|
fireEvent('user.updated', data);
|
|
15409
15580
|
return {
|
|
15410
|
-
data: payload.users.find(user => user.userId === userId),
|
|
15581
|
+
data: userLinkedObject(payload.users.find(user => user.userId === userId)),
|
|
15411
15582
|
cachedAt,
|
|
15412
15583
|
};
|
|
15413
15584
|
};
|
|
@@ -15459,7 +15630,7 @@ const flagUser = async (userId, options) => {
|
|
|
15459
15630
|
ingestInCache(payload);
|
|
15460
15631
|
}
|
|
15461
15632
|
fireEvent('user.flagged', data);
|
|
15462
|
-
return (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
|
|
15633
|
+
return userLinkedObject((_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0]);
|
|
15463
15634
|
};
|
|
15464
15635
|
/* end_public_function */
|
|
15465
15636
|
|
|
@@ -15480,13 +15651,14 @@ const submitUserReport = async (apiName, userId, body) => {
|
|
|
15480
15651
|
ingestInCache(payload);
|
|
15481
15652
|
}
|
|
15482
15653
|
fireEvent('user.flagged', data);
|
|
15483
|
-
return (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
|
|
15654
|
+
return userLinkedObject((_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0]);
|
|
15484
15655
|
};
|
|
15485
15656
|
|
|
15486
15657
|
/** Maximum `comment` length, in string length units, after trimming. */
|
|
15487
15658
|
const USER_REPORT_COMMENT_MAX_LENGTH = 300;
|
|
15488
15659
|
const PROFILE_FIELDS = Object.values(exports.UserProfileFieldEnum);
|
|
15489
15660
|
const BEHAVIOR_REASONS = Object.values(exports.ContentFlagReasonEnum);
|
|
15661
|
+
const REPORT_TYPE_FILTERS = Object.values(exports.UserReportTypeFilterEnum);
|
|
15490
15662
|
const assertOptionsObject = (apiName, options, shape) => {
|
|
15491
15663
|
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
|
|
15492
15664
|
throw new ASCInvalidParameterError(`${apiName}: expected an options object \`${shape}\``);
|
|
@@ -15546,6 +15718,28 @@ const toUserBehaviorReportBody = (options) => {
|
|
|
15546
15718
|
}
|
|
15547
15719
|
return withComment({ reportType: 'behavior', reason }, normalizeUserReportComment(apiName, comment));
|
|
15548
15720
|
};
|
|
15721
|
+
/**
|
|
15722
|
+
* Validates the optional `{ reportType? }` of `unflagUser` and builds its query parameters.
|
|
15723
|
+
* Returns `undefined` when no `reportType` is given, so the request carries no query string
|
|
15724
|
+
* and withdraws every report the caller filed on the user. The server validates the value
|
|
15725
|
+
* too (422); this local check only saves the round-trip for the string alias, which admits
|
|
15726
|
+
* raw strings. Untyped callers can pass anything at runtime, so nothing is trusted from the
|
|
15727
|
+
* declared type.
|
|
15728
|
+
*
|
|
15729
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed or `reportType` is unknown
|
|
15730
|
+
*/
|
|
15731
|
+
const toUserReportTypeFilter = (options) => {
|
|
15732
|
+
if (options === undefined)
|
|
15733
|
+
return undefined;
|
|
15734
|
+
const apiName = 'unflagUser';
|
|
15735
|
+
const { reportType } = assertOptionsObject(apiName, options, '{ reportType? }');
|
|
15736
|
+
if (reportType === undefined)
|
|
15737
|
+
return undefined;
|
|
15738
|
+
if (typeof reportType !== 'string' || !REPORT_TYPE_FILTERS.includes(reportType)) {
|
|
15739
|
+
throw new ASCInvalidParameterError(`${apiName}: \`reportType\` must be a \`UserReportTypeFilterEnum\` value`);
|
|
15740
|
+
}
|
|
15741
|
+
return { reportType: reportType };
|
|
15742
|
+
};
|
|
15549
15743
|
|
|
15550
15744
|
/* begin_public_function
|
|
15551
15745
|
id: user.flag_profile
|
|
@@ -15618,20 +15812,46 @@ const flagUserBehavior = async (userId, options) => submitUserReport('flagUserBe
|
|
|
15618
15812
|
*/
|
|
15619
15813
|
/**
|
|
15620
15814
|
* ```js
|
|
15621
|
-
* import { UserRepository } from '@amityco/ts-sdk'
|
|
15622
|
-
*
|
|
15815
|
+
* import { UserRepository, UserReportTypeFilterEnum } from '@amityco/ts-sdk'
|
|
15816
|
+
*
|
|
15817
|
+
* // Withdraw every report I filed on the user.
|
|
15818
|
+
* const unflagged = await UserRepository.unflagUser('userId')
|
|
15819
|
+
*
|
|
15820
|
+
* // Withdraw only my behavior report; my other reports on the user stay.
|
|
15821
|
+
* await UserRepository.unflagUser('userId', { reportType: UserReportTypeFilterEnum.BEHAVIOR })
|
|
15822
|
+
*
|
|
15823
|
+
* // Withdraw only my typeless (legacy) report.
|
|
15824
|
+
* await UserRepository.unflagUser('userId', { reportType: UserReportTypeFilterEnum.UNTYPED })
|
|
15623
15825
|
* ```
|
|
15624
15826
|
*
|
|
15827
|
+
* Withdraws the caller's reports on a user. Without `reportType` every report the caller
|
|
15828
|
+
* filed on that user is withdrawn, as before. With `reportType` only the caller's report
|
|
15829
|
+
* of that type is withdrawn; the caller's other reports and other users' reports are
|
|
15830
|
+
* untouched. Withdrawing a report that does not exist succeeds and changes nothing.
|
|
15831
|
+
*
|
|
15832
|
+
* The returned user is persisted to the cache, so its `hashFlag` says whether the caller
|
|
15833
|
+
* still holds any report on the user. Do not flip a local "flagged by me" flag to `false`
|
|
15834
|
+
* after a per-type withdrawal; read the fresh user, or call `isUserFlaggedByMe` for the
|
|
15835
|
+
* remaining per-type state (`flags`).
|
|
15836
|
+
*
|
|
15837
|
+
* Sends `DELETE /api/v4/me/flags/:userId`, with `?reportType=<type>` when one is given.
|
|
15838
|
+
*
|
|
15625
15839
|
* @param userId The ID of the user to unflag
|
|
15626
|
-
* @
|
|
15840
|
+
* @param options Optional; `reportType` selects a single report to withdraw. For a report that `isUserFlaggedByMe` lists with `reportType: null`, pass `UserReportTypeFilterEnum.UNTYPED`
|
|
15841
|
+
* @returns `true` once the server has processed the withdrawal
|
|
15842
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `reportType` is not a `UserReportTypeFilterEnum` value, before any request is made
|
|
15627
15843
|
*
|
|
15628
15844
|
* @category User API
|
|
15629
15845
|
* @async
|
|
15630
15846
|
* */
|
|
15631
|
-
const unflagUser = async (userId) => {
|
|
15632
|
-
const client = getActiveClient();
|
|
15633
|
-
client.log('user/unflag', userId);
|
|
15634
|
-
const
|
|
15847
|
+
const unflagUser = async (userId, options) => {
|
|
15848
|
+
const client = getActiveClient();
|
|
15849
|
+
client.log('user/unflag', { userId, options });
|
|
15850
|
+
const params = toUserReportTypeFilter(options);
|
|
15851
|
+
const url = `/api/v4/me/flags/${encodeURIComponent(userId)}`;
|
|
15852
|
+
const { data } = params
|
|
15853
|
+
? await client.http.delete(url, { params })
|
|
15854
|
+
: await client.http.delete(url);
|
|
15635
15855
|
const payload = prepareUserPayload(data);
|
|
15636
15856
|
if (client.cache) {
|
|
15637
15857
|
ingestInCache(payload);
|
|
@@ -15647,11 +15867,33 @@ const unflagUser = async (userId) => {
|
|
|
15647
15867
|
/**
|
|
15648
15868
|
* ```js
|
|
15649
15869
|
* import { UserRepository } from '@amityco/ts-sdk'
|
|
15650
|
-
*
|
|
15870
|
+
*
|
|
15871
|
+
* const { isFlagByMe, flags } = await UserRepository.isUserFlaggedByMe('userId')
|
|
15872
|
+
*
|
|
15873
|
+
* // Grey out the report options already used; null marks the typeless report.
|
|
15874
|
+
* const used = new Set(flags.map(flag => flag.reportType))
|
|
15651
15875
|
* ```
|
|
15652
15876
|
*
|
|
15653
|
-
*
|
|
15654
|
-
*
|
|
15877
|
+
* Returns whether the caller has reported a user, with each of the caller's own reports
|
|
15878
|
+
* on that user, exactly as `GET /api/v4/users/:userId/isFlagByMe` answers. Each report
|
|
15879
|
+
* carries `reportType`, `reason`, `comment` and `createdAt`; a field the report does not
|
|
15880
|
+
* have is `null`. `reportType: null` is the typeless (legacy) report, which `unflagUser`
|
|
15881
|
+
* withdraws with `UserReportTypeFilterEnum.UNTYPED`. Only the caller's reports come back.
|
|
15882
|
+
*
|
|
15883
|
+
* This is the only source of per-type state. Nothing is filtered, cached or persisted:
|
|
15884
|
+
* the call reads the server every time and does not consult `hashFlag`, which is a
|
|
15885
|
+
* type-blind bloom filter. Call it again after a flag or unflag when the UI needs the
|
|
15886
|
+
* updated per-type state.
|
|
15887
|
+
*
|
|
15888
|
+
* Breaking change: earlier versions returned a boolean from the v3 endpoint, which the
|
|
15889
|
+
* backend has deprecated. Read `isFlagByMe` on the result for the same answer.
|
|
15890
|
+
*
|
|
15891
|
+
* @deprecated On an {@link Amity.User} you already hold, read `user.isFlaggedByMe` for a
|
|
15892
|
+
* request-free badge and call `user.getUserFlagsByMe()` for the reports; it skips the request
|
|
15893
|
+
* when the Bloom test says the user is not flagged. This function remains the underlying request.
|
|
15894
|
+
*
|
|
15895
|
+
* @param userId The ID of the user to check
|
|
15896
|
+
* @returns the caller's {@link Amity.UserFlagByMe} on that user
|
|
15655
15897
|
*
|
|
15656
15898
|
* @category Report API
|
|
15657
15899
|
* @async
|
|
@@ -15659,8 +15901,7 @@ const unflagUser = async (userId) => {
|
|
|
15659
15901
|
const isUserFlaggedByMe = async (userId) => {
|
|
15660
15902
|
const client = getActiveClient();
|
|
15661
15903
|
client.log('user/isUserFlaggedByMe', userId);
|
|
15662
|
-
|
|
15663
|
-
return isFlagByMe;
|
|
15904
|
+
return getFlagsByMe(userId);
|
|
15664
15905
|
};
|
|
15665
15906
|
/* end_public_function */
|
|
15666
15907
|
|
|
@@ -15910,16 +16151,14 @@ const getUser = (userId, callback) => {
|
|
|
15910
16151
|
};
|
|
15911
16152
|
/* end_public_function */
|
|
15912
16153
|
|
|
15913
|
-
|
|
15914
|
-
|
|
15915
|
-
|
|
15916
|
-
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
15921
|
-
}
|
|
15922
|
-
}
|
|
16154
|
+
var EnumUserActions;
|
|
16155
|
+
(function (EnumUserActions) {
|
|
16156
|
+
EnumUserActions["OnUserDeleted"] = "onUserDeleted";
|
|
16157
|
+
EnumUserActions["OnUserUpdated"] = "onUserUpdated";
|
|
16158
|
+
EnumUserActions["OnUserFlagged"] = "onUserFlagged";
|
|
16159
|
+
EnumUserActions["OnUserUnflagged"] = "onUserUnflagged";
|
|
16160
|
+
EnumUserActions["OnUserFlagCleared"] = "onUserFlagCleared";
|
|
16161
|
+
})(EnumUserActions || (EnumUserActions = {}));
|
|
15923
16162
|
|
|
15924
16163
|
class UserQueryStreamController extends QueryStreamController {
|
|
15925
16164
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
@@ -15967,14 +16206,16 @@ class UserQueryStreamController extends QueryStreamController {
|
|
|
15967
16206
|
}
|
|
15968
16207
|
}
|
|
15969
16208
|
|
|
15970
|
-
|
|
15971
|
-
(
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
16209
|
+
class UserPaginationController extends PaginationController {
|
|
16210
|
+
async getRequest(queryParams, token) {
|
|
16211
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
16212
|
+
const options = token ? { token } : { limit };
|
|
16213
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
|
|
16214
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
16215
|
+
});
|
|
16216
|
+
return queryResponse;
|
|
16217
|
+
}
|
|
16218
|
+
}
|
|
15978
16219
|
|
|
15979
16220
|
class UserLiveCollectionController extends LiveCollectionController {
|
|
15980
16221
|
constructor(query, callback) {
|
|
@@ -16091,16 +16332,17 @@ const getUsers = (params, callback, config) => {
|
|
|
16091
16332
|
};
|
|
16092
16333
|
/* end_public_function */
|
|
16093
16334
|
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
const { data: queryResponse } = await this.http.get('/api/v4/me/user-blocks', {
|
|
16099
|
-
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
16100
|
-
});
|
|
16101
|
-
return queryResponse;
|
|
16335
|
+
const convertEventPayload = (eventHandler, sourceModelProp, destinationDomain) => (callback) => eventHandler(sourceModel => {
|
|
16336
|
+
var _a;
|
|
16337
|
+
if (!sourceModel) {
|
|
16338
|
+
return sourceModel;
|
|
16102
16339
|
}
|
|
16103
|
-
}
|
|
16340
|
+
const cacheKey = [destinationDomain, 'get', `${sourceModel[sourceModelProp]}`];
|
|
16341
|
+
const model = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
16342
|
+
if (!model)
|
|
16343
|
+
return;
|
|
16344
|
+
return callback(model);
|
|
16345
|
+
});
|
|
16104
16346
|
|
|
16105
16347
|
var EnumBlockActions;
|
|
16106
16348
|
(function (EnumBlockActions) {
|
|
@@ -16156,17 +16398,16 @@ class BlockedUserQueryStreamController extends QueryStreamController {
|
|
|
16156
16398
|
}
|
|
16157
16399
|
}
|
|
16158
16400
|
|
|
16159
|
-
|
|
16160
|
-
|
|
16161
|
-
|
|
16162
|
-
|
|
16401
|
+
class BlockedUserPaginationController extends PaginationController {
|
|
16402
|
+
async getRequest(queryParams, token) {
|
|
16403
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
16404
|
+
const options = token ? { token } : { limit };
|
|
16405
|
+
const { data: queryResponse } = await this.http.get('/api/v4/me/user-blocks', {
|
|
16406
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
16407
|
+
});
|
|
16408
|
+
return queryResponse;
|
|
16163
16409
|
}
|
|
16164
|
-
|
|
16165
|
-
const model = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
16166
|
-
if (!model)
|
|
16167
|
-
return;
|
|
16168
|
-
return callback(model);
|
|
16169
|
-
});
|
|
16410
|
+
}
|
|
16170
16411
|
|
|
16171
16412
|
class BlockedUserLiveCollectionController extends LiveCollectionController {
|
|
16172
16413
|
constructor(query, callback) {
|
|
@@ -16476,17 +16717,6 @@ const getBlockingUsers = (callback) => {
|
|
|
16476
16717
|
};
|
|
16477
16718
|
/* end_public_function */
|
|
16478
16719
|
|
|
16479
|
-
class SearchUserPaginationController extends PaginationController {
|
|
16480
|
-
async getRequest(queryParams, token) {
|
|
16481
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, displayName } = queryParams, params = __rest(queryParams, ["limit", "displayName"]);
|
|
16482
|
-
const options = token ? { token } : { limit };
|
|
16483
|
-
const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
|
|
16484
|
-
params: Object.assign(Object.assign({}, params), { keyword: displayName, options, isDeleted: false }),
|
|
16485
|
-
});
|
|
16486
|
-
return queryResponse;
|
|
16487
|
-
}
|
|
16488
|
-
}
|
|
16489
|
-
|
|
16490
16720
|
class SearchUserQueryStreamController extends QueryStreamController {
|
|
16491
16721
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
16492
16722
|
super(query, cacheKey);
|
|
@@ -16533,6 +16763,17 @@ class SearchUserQueryStreamController extends QueryStreamController {
|
|
|
16533
16763
|
}
|
|
16534
16764
|
}
|
|
16535
16765
|
|
|
16766
|
+
class SearchUserPaginationController extends PaginationController {
|
|
16767
|
+
async getRequest(queryParams, token) {
|
|
16768
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, displayName } = queryParams, params = __rest(queryParams, ["limit", "displayName"]);
|
|
16769
|
+
const options = token ? { token } : { limit };
|
|
16770
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
|
|
16771
|
+
params: Object.assign(Object.assign({}, params), { keyword: displayName, options, isDeleted: false }),
|
|
16772
|
+
});
|
|
16773
|
+
return queryResponse;
|
|
16774
|
+
}
|
|
16775
|
+
}
|
|
16776
|
+
|
|
16536
16777
|
class SearchUserLiveCollectionController extends LiveCollectionController {
|
|
16537
16778
|
constructor(query, callback) {
|
|
16538
16779
|
var _a;
|
|
@@ -19210,7 +19451,8 @@ const getPostReport = async ({ client, referenceId, }) => {
|
|
|
19210
19451
|
};
|
|
19211
19452
|
const getUserReport = async ({ client, referenceId, }) => {
|
|
19212
19453
|
var _a;
|
|
19213
|
-
|
|
19454
|
+
// v3 isFlagByMe is deprecated by the backend; v4 answers the same boolean plus the caller's flags.
|
|
19455
|
+
const { data } = await client.http.get(`/api/v4/users/${encodeURIComponent(referenceId)}/isFlagByMe`);
|
|
19214
19456
|
const { result, isFlagByMe } = data !== null && data !== void 0 ? data : {};
|
|
19215
19457
|
return (_a = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _a !== void 0 ? _a : false;
|
|
19216
19458
|
};
|