Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If toggle button for anonymity is on, upload post with anonymous tag and default profile. #11

Open
mhli1260 opened this issue Sep 12, 2024 · 0 comments · May be fixed by #35
Open

If toggle button for anonymity is on, upload post with anonymous tag and default profile. #11

mhli1260 opened this issue Sep 12, 2024 · 0 comments · May be fixed by #35
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@mhli1260
Copy link

mhli1260 commented Sep 12, 2024

Dependencies:"Create a toggle button for users to select to be anonymous"

Estimated Effort: 4 hours

Acceptance criteria:

  • If the user turns the toggle button on, the post submitted will be uploaded with an anonymous tag and default profile.
  • If the user turns the toggle button off, the post submitted will be uploaded with the signed in user's tag and default profile.

2b Project Updates:
Screenshots of local environment because I could not get the new node_modules changes to work before the deadline via the new instructions:

node_modules/nodebb-plugin-composer-default/static/lib/composer.js:

Image

Issues:
I created a event handler for the action of the user turning the anonymous toggle button on. This function seems to be working based on a lot of console.log tests that I performed to make sure that the returning properties were correct (returns true is the toggle button is on).

The issue I am having is deciding where to call this function. I tried finding a location to call it in the async function post in the same file, however, non of the input data seems to be directly related to the uid, username, or displayname.

Another attempt at connecting the backend to the frontend was in the src/topcs/posts.js file. I set postObj.user.username and postObj.user.displayname to "anonymous", and that correctly displayed an anonymous username when I tried posting something on the forum. I struggled to find a way to connect these statements under and if statement that would only execute under the condition that the anonymous toggle was actually on.

2c Project Updates:

Estimated time effort: I spent over 25 hours trying to get my feature to work in the past 2 weeks for sprint 2.

During sprint 2, I made updates to the api for posts. So if you run the route 'api/v3/posts/{pid}', you will see the additional 'anonymous' attribute that I added. This attribute takes on either a value of 0 or 1, 0 for if the anonymous button is off, and 1 for if the anonymous button is on. Here is a screenshot of the api:
Image

I updated src/topics/posts.js to update the username if the anonymous attribute in a given post was 1.

In nodebb-plugin-composer-default/static/lib/composer.js, I created a handleAnonymous function that creates a boolean 'isAnonymous' variable. If the button is toggled on, the isAnonymous is true, and if the button is toggled off, the isAnonymous is false.

Issues arose when I tried to update this anonymous api attribute when the button was on. In my nodebb-plugin-composer-default/static/lib/composer.js file, I attempted to update this attribute using a 'put' method to the api endpoint, but I was running into errors regarding authorization. Running the commented out code when a topic was posted gave me 403 authorization errors in regards to the 'put' method to send new information to the API. I could not figure out the token.
Image

Ultimately, all the parts are working individually, but I had trouble connecting the backend to the frontend feature. I went to office hours to get help on my task, but did not make much progress in the backend to frontend connection.

Testing issue: There is one more issue with updating the schema. Since I updated the API, the response returns a post object with the attribute 'anonymous'. The tests that still fail, however, refer to the schema not being updated to reflect that. I attempted to update public/openapi/components/schemas/PostObject.yaml as well as public/openapi/write/posts/pid.yaml, but changes to those schema files did not help solve this issue. All other tests pass.

Image

@mhli1260 mhli1260 self-assigned this Sep 12, 2024
@mhli1260 mhli1260 added this to the Sprint 1 milestone Sep 12, 2024
@alicekang1 alicekang1 removed this from the Sprint 1 milestone Sep 25, 2024
@mhli1260 mhli1260 added this to the Sprint 1 milestone Sep 25, 2024
@mhli1260 mhli1260 modified the milestones: Sprint 1, Sprint 2 Oct 10, 2024
@jullia02 jullia02 added the enhancement New feature or request label Oct 10, 2024
@jullia02 jullia02 linked a pull request Oct 10, 2024 that will close this issue
@mhli1260 mhli1260 linked a pull request Oct 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants