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

Adding an anonymous feature to allow users to post anonymously #30

Open
wants to merge 120 commits into
base: f24
Choose a base branch
from

Conversation

Hakaabi
Copy link

@Hakaabi Hakaabi commented Sep 25, 2024

(sprint 1)
Initially the original milestone was to implement user story 2 feature 3 (enhancing search tool). However due to dependency issues (feature 2 of user tory 2 is not yet completed) we decided it would be better to start with user story 3 feature 2. This is reflected in the commit messages under this pull request. Goals are not yet met for this specific feature due to time constraint, but are planned to be met by the beginning of next week. So far, Refracted code in 2 files. src/post/create.js and src/topics/posts.js. this aims to resolve issue #19


(sprint 2)

Files edited and why:

-Front-end and back-end communication:

1.node_modules/../compser.js
Introduced logic to handle anonymous posts by adding an isAnonymous parameter to the pushData object in composer.newTopic. This ensures that when a user selects the anonymous option, it gets properly included in the topic creation request.
In the post() function, I added code to capture the state of the anonymous checkbox (#anonymousPostCheckbox). This checks if the user selected to post anonymously and passes the value to the back-end when the topic is submitted.

2.src/topics/index.js
Updated the logic in the topic loop to check if a topic is marked as anonymous (topic.isAnonymous). If topic.isAnonymous is set to 'true', the topic's user object is replaced with an anonymous display (i.e., username: 'Anonymous', displayname: 'Anonymous').

The modifications made to these file aimed to gap the communication between front-end and back-end implementations of the Anonymous feature. Aims to resolve issue #48.

-Main implementation of feature:

4.src/topic/posts.js
Modified the logic to handle the anonymous option when creating a new post by adding an isAnonymous property to the post creation loop 'postData.forEach((postObj, i)' and added an if statement, that ensures when 'isAnonymous' is true, the post's user information is overridden with a Anonymous user. this was done by changing the username and displayname to 'anonymous'.

Having worked on this feature from start to end, I think this file contains the main back-end logic of this feature. this aims to resolve issue #19.

-Database and schema modification:

5.src/posts/create.js
modified the data structure in the create function to include the isAnonymous field and standardized the 'isAnonymous' field as a Boolean for consistent handling of anonymous posts. I also added 'isAnonymous' in postData.

6.src/topics/create.js
Added 'isAnonymous' field to the topic creation process(database). this allows for the creation of anonymous topics by allowing users to specify whether their identity should be hidden during topic creation. (this was added after debugging topics/index.js)

7.public/../schemas/topicobject.yaml
Modified the topic schema to reflect the changes in the database, ensuring that the isAnonymous field is now part of the schema definition.

8.public/../schemas/postobject.yaml
Updated the post schema to include the isAnonymous field, aligning it with the database structure (src/posts/create.js).

The modifications made to these files aimed to resolve issue #49

-Screenshots of the console logs written to verify the implementation and manual testing of the Anonymous feature:
When an Anonymous post is made

Screenshot 2024-10-16 at 19 33 46

When a Non-anonymous post is made
Screenshot 2024-10-16 at 19 34 33

@Hakaabi Hakaabi self-assigned this Sep 25, 2024
@Hakaabi Hakaabi added this to the Sprint 1 milestone Sep 25, 2024
@rmmahmou rmmahmou self-requested a review September 25, 2024 14:00
@galishaq galishaq requested review from galishaq and removed request for galishaq September 26, 2024 14:45
@Hakaabi Hakaabi added enhancement New feature or request back-end labels Sep 26, 2024
@Hakaabi Hakaabi modified the milestones: Sprint 1 , Sprint 2 Sep 26, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11331092765

Details

  • 23 of 30 (76.67%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.008%) to 82.741%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/topics/posts.js 9 12 75.0%
src/topics/index.js 9 13 69.23%
Totals Coverage Status
Change from base Build 11059941294: -0.008%
Covered Lines: 22376
Relevant Lines: 25627

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants