Git Product home page Git Product logo

Comments (19)

mariojsnunes avatar mariojsnunes commented on June 26, 2024 1

Kay, here's a pull request that publishes webhooks for new questions: #3619

This has been deployed 🚀

from community-platform.

davehakkens avatar davehakkens commented on June 26, 2024 1

What does this deployment mean @pizzaisdavid?
Should notifications come in somewhere now, from dev or live?

But is it planned to support or possible to have multiple collaborators on a single Research Update?

Not planned. For now only multiple contributors on an entire research topic (like here). Not on one specific update.

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024 1

What does this deployment mean @pizzaisdavid?
Should notifications come in somewhere now, from dev or live?

It is possible I don't understand you correctly, but the next time a Question is asked on https://community.preciousplastic.com/questions there should be a corresponding bot post in the activitybot Discord channel.

Precious plastic is the only one with questions enabled, but in the future, if others projects have it enabled too, there would be notifications from them as well.

I thought about posting a test question on Precious Plastic, but I think it isn't possible to delete your own question, so I felt like it would be not nice.

Can I post a test question on production, to verify it works correctly? (or someone else can do it if they like.)

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024

I have addressed the Howto editing triggering a notification and need re-approval from admins (I think technically the notification happens only after the admin has re-approved.) #3613 the pull request is currently still open, but just so anyone else avoids doing that work.

from community-platform.

davehakkens avatar davehakkens commented on June 26, 2024

Thanks for the first part on this @pizzaisdavid !
Are you also up for doing the other bit of this?

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024

I might try but no promises.

Stop to trigger webhooks when content (map-pins + howtos) are edited

Moving the location of a pin does not trigger the need for re-approval but changing the "focus" of a profile does. And we want to disable that, correct?

In case anyone else wants to try, here is the related code: https://github.com/ONEARMY/community-platform/blob/master/src/stores/Maps/maps.store.ts#L187

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024

best_i_can_do

current state:

  • Pins of type member do not need moderation.
  • Switching type in any way (except to member) requires moderation.

What I can adjust it to:

  • NEW: Switching between different non-member types do not affect moderation status (already accepted entries stay as accepted.)
  • SLIGHT CHANGE: Switching from member to a non-member type requires moderation, already happening indirectly.
  • Pins of type member do not need moderation (same as before.)

Example: if someone switches from member to collection point, they would need moderation. If they switch back to member, they don't need moderation. But if they switch back again to collection point (or any other non-member type) they need approval again.

Summary: any time switching from member to non-member, it would require moderation.

If the wish is they really only need to be approved once ever, then a new property could be introduced (or a different approach.) But I can't estimate the complexity of that.

Also to reiterate for those reading, whenever the moderation status of a pin is changed to accepted it triggers the webhook.

Also, I could be wrong about any of this, anyone feel free to correct me.

from community-platform.

davehakkens avatar davehakkens commented on June 26, 2024

Thanks for the indepth look, very useful!
Your porposal sounds more complete then the original plan of no moderation at all.
To me this seems like a good path to take

EDIT: We might need a bit more thinking on this moderation flow so we can make it ready for the future.
Because at the moment "workspace" profiles (non members) dont have any moderation since this was not needed when introduced. So anyone can create one. Since the only way you could find them was on the map. Hence the Map moderation.

That said, features are added like comments and the Q&A etc that make it possible to discover a workspace account. In order to keep them legit we might need to bring moderation to the profile level, not map.

Will discuss with the team first to see whats the best way

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024

I see we want to push the questions module for precious plastic.. therefore, it would be good if we setup the webhook for that.

from community-platform.

davehakkens avatar davehakkens commented on June 26, 2024

I see we want to push the questions module for precious plastic.. therefore, it would be good if we setup the webhook for that.

Agree that would be a very nice/useful one

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024

Kay, here's a pull request that publishes webhooks for new questions: #3619

It depends on some refactoring I did to make development easier, so first that stuff needs to be merged 😈

Also, some technical things could be clarified but I've listed that in the pull request.

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024

Research Updates have a collaborators property, which is a list of usernames. I've only ever seen an Update written by one person, so a list of just one username.

But is it planned to support or possible to have multiple collaborators on a single Research Update?

I could build some more complicated logic in that case:

1 author:
📝 New update from [username1] in their research: ...

2 authors:
📝 New update from [username1] and [username2] in their research: ...

3 authors:
📝 New update from [username1], [username2], and [username3] in their research: ...

And so on..

Thoughts?

from community-platform.

davehakkens avatar davehakkens commented on June 26, 2024

yeh lets give it a try @pizzaisdavid! (I will delete for you)

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024

https://discord.com/channels/586676777334865928/599259846767935519/1251985417973006376

from community-platform.

davehakkens avatar davehakkens commented on June 26, 2024

Nice one! 💪
@goratt12 So what is the function of the new Discord Bot we recently setup up? -Since this seems to run on the original one.

For the archive:
afbeelding

from community-platform.

goratt12 avatar goratt12 commented on June 26, 2024

The function stayed in firebase-discord.ts

export const sendDiscordNotification = async (
payload: DiscordWebhookPayload,
) => {
await axios
.post(DISCORD_WEBHOOK_URL, payload)
.then(handleResponse, handleErr)
.catch(handleErr)
}

The testing function is also in that file

export const getDiscordMessages = async (limit = 50) => {
const res = await axios
.get(
`https://discord.com/api/channels/${DISCORD_CHANNEL_ID}/messages?limit=${limit}`,
{
headers: {
Authorization: `Bot ${DISCORD_BOT_TOKEN}`,
},
},
)
.then(handleResponse, handleErr)
.catch(handleErr)
const messages = res.data ?? []
return messages
}

We are having issues with the testing in the CircleCI environment, currently moving the PR to Draft until we will figure out a solution

from community-platform.

benfurber avatar benfurber commented on June 26, 2024

Is there a way we could check on the cypress tests that a notification has been sent?

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024

Is there a way we could check on the cypress tests that a notification has been sent?

Option 1

The ideal: the cypress tests are ran in Docker, the backend functions are ran in the emulator inside docker, and the simple "simulated-webhook-receiver" is also started-up inside Docker.

https://github.com/ONEARMY/community-platform/tree/master/packages/simulated-webhook-receiver

They are all handled via Docker Compose, then everything is happening locally (either on the devs machine or in the CI.)

There is an endpoint in there to get the requests that have been made.

Pros:

  • doesn't depend on an external service, Discord could have problems, we don't care.
  • devs can run tests without internet access
  • the tests would be more simple (compared to what I will propose next.)

Cons:

  • Docker bro.
  • Cannot be done until the backend functions for cypress tests are also ran locally.

Would be fine to implement if the tests were already running in docker.


Option 2

Achievable "today"-ish

Follow what @goratt12 has been trying to do. I guess Discord offers an API to check messages for a Discord channel.

Backend functions for cypress are configured to send to test channel.

Cypress test generates uniquely identifiable content (for example, a question with a title has is 24 random characters.)

In the assert section of the test, use their helper function posted above to check that there was a Discord message in that test channel that has the same random characters.

If static test data was used, it would pass even if it broke, due to old messages of the same static content.

Pros:

  • could be done easier than "Dockerize everything"

Cons:

  • Relies on an external service
  • Devs who want to work on webhooks would then want access to this, another thing to keep in mind.
  • A further ingraining less then ideal testing setup, but better than none, I guess?

from community-platform.

pizzaisdavid avatar pizzaisdavid commented on June 26, 2024

I have made an issue for cypress tests (#3694) and Guy's pull request should add unit tests #3636

from community-platform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.