Skip to content

Commit

Permalink
Merge pull request #24 from kaylalei/f24
Browse files Browse the repository at this point in the history
add anonymous field to posts data schema
  • Loading branch information
luciafang authored Sep 28, 2024
2 parents e8c5cf0 + b5cb7e6 commit 303387d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Binary file modified dump.rdb
Binary file not shown.
6 changes: 4 additions & 2 deletions src/api/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ topicsAPI.get = async function (caller, data) {
return topic;
};

topicsAPI.create = async function (caller, data) {
topicsAPI.create = async function (caller, data, anonymous = false) {
if (!data) {
throw new Error('[[error:invalid-data]]');
}
data.anonymous = anonymous;

const payload = { ...data };
payload.tags = payload.tags || [];
Expand Down Expand Up @@ -83,10 +84,11 @@ topicsAPI.create = async function (caller, data) {
return result.topicData;
};

topicsAPI.reply = async function (caller, data) {
topicsAPI.reply = async function (caller, data, anonymous = false) {
if (!data || !data.tid || (meta.config.minimumPostLength !== 0 && !data.content)) {
throw new Error('[[error:invalid-data]]');
}
data.anonymous = anonymous;
const payload = { ...data };
apiHelpers.setDefaultPostData(caller, payload);

Expand Down
2 changes: 2 additions & 0 deletions src/posts/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = function (Posts) {
const content = data.content.toString();
const timestamp = data.timestamp || Date.now();
const isMain = data.isMain || false;
const { anonymous } = data;

if (!isMain) {
await topics.setTopicField(tid, 'resolved', true);
Expand All @@ -39,6 +40,7 @@ module.exports = function (Posts) {
tid: tid,
content: content,
timestamp: timestamp,
anonymous: anonymous,
};

if (data.toPid) {
Expand Down

0 comments on commit 303387d

Please sign in to comment.