beamsocial 0.16.1 → 0.16.2
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/lib/models/comments.d.ts +1 -1
- package/lib/models/comments.js +3 -3
- package/lib/models/posts.d.ts +1 -1
- package/lib/models/posts.js +35 -2
- package/package.json +1 -1
package/lib/models/comments.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class Comment {
|
|
|
20
20
|
__load(data: RawComment, __session?: Session, __url?: string): void;
|
|
21
21
|
like(): Promise<void>;
|
|
22
22
|
unlike(): Promise<void>;
|
|
23
|
-
add_answer(
|
|
23
|
+
add_answer(content: string, visibility: RawComment["visibility"]): Promise<void>;
|
|
24
24
|
report(): Promise<void>;
|
|
25
25
|
delete(): Promise<void>;
|
|
26
26
|
}
|
package/lib/models/comments.js
CHANGED
|
@@ -110,7 +110,7 @@ export class Comment {
|
|
|
110
110
|
}*/
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
add_answer(
|
|
113
|
+
add_answer(content, visibility) {
|
|
114
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
115
|
var _a;
|
|
116
116
|
if (!this.post) {
|
|
@@ -118,8 +118,8 @@ export class Comment {
|
|
|
118
118
|
}
|
|
119
119
|
try {
|
|
120
120
|
const res = yield axios.post(((_a = this.__url) === null || _a === void 0 ? void 0 : _a.replace(`/comments/${this.id}`, '/posts/' + this.post.id)) + `/answers`, {
|
|
121
|
-
content:
|
|
122
|
-
visibility:
|
|
121
|
+
content: content,
|
|
122
|
+
visibility: visibility,
|
|
123
123
|
answers_to: this.id,
|
|
124
124
|
post_id: this.post.id
|
|
125
125
|
}, {
|
package/lib/models/posts.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare class Post {
|
|
|
22
22
|
unlike(): Promise<void>;
|
|
23
23
|
repost(): Promise<void>;
|
|
24
24
|
undo_repost(): Promise<void>;
|
|
25
|
-
add_comment(
|
|
25
|
+
add_comment(content: string, visibility: RawComment["visibility"]): Promise<void>;
|
|
26
26
|
remove_comment(id: string): Promise<void>;
|
|
27
27
|
report(): Promise<void>;
|
|
28
28
|
delete(): Promise<void>;
|
package/lib/models/posts.js
CHANGED
|
@@ -110,8 +110,41 @@ export class Post {
|
|
|
110
110
|
undo_repost() {
|
|
111
111
|
return __awaiter(this, void 0, void 0, function* () { });
|
|
112
112
|
}
|
|
113
|
-
add_comment(
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
add_comment(content, visibility) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
var _a;
|
|
116
|
+
try {
|
|
117
|
+
const res = yield axios.post(((_a = this.__url) === null || _a === void 0 ? void 0 : _a.replace(`/posts/${this.id}`, '')) + `/comments/new`, {
|
|
118
|
+
content: content,
|
|
119
|
+
visibility: visibility,
|
|
120
|
+
post_id: this.id
|
|
121
|
+
}, {
|
|
122
|
+
withCredentials: true
|
|
123
|
+
});
|
|
124
|
+
this.comments += 1;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
if (axios.isAxiosError(err) && err.response) {
|
|
129
|
+
const res = err.response;
|
|
130
|
+
if (res.status == 401) {
|
|
131
|
+
throw new Error('NotLoggedIn');
|
|
132
|
+
}
|
|
133
|
+
else if (res.status == 403) {
|
|
134
|
+
throw new Error('PrivatePost');
|
|
135
|
+
}
|
|
136
|
+
else if (res.status == 404) {
|
|
137
|
+
throw new Error('PostNotFound');
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
throw new Error('Error');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
throw err;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
115
148
|
}
|
|
116
149
|
remove_comment(id) {
|
|
117
150
|
return __awaiter(this, void 0, void 0, function* () { });
|