How to store user based questions and answers in superscript? - node.js

I am working on a chat bot where multiple users(Role:owner) can add/edit/remove their questions and answers for subordinates(Role:travelers). When a traveler questions to chat bot, chat bot should only choose answers added by his User(Role:owner).
How can I do this? I want something that I will be able to store the user id corresponding to questions/answers in main.ss file.
I am using SuperscriptJS with Keystone and mongodb
Please help.
Thanks

User based roles and permissions are not currently available in keystone, so this is not currently possible.
However, it's very much in the pipline. To show your interest in this feature, you can upvote it on product pains: https://productpains.com/post/keystonejs/role-based-admin-system

There is no need of core level role implementation for this.You can have your own Role system in your User model. For detailed study you can refer sydJS code.sydJS is developed by he keystoneJS developers.
in sydJS at modesl/User.js you can search for isAdmin and isVerified. Like that you can set Role there.
But I guess , you are not asking for role, Instead in your usecase there is a relation called owner. such that each user of role type travelers has a related User called owner. or something like that. For that You can set a owner field in User model.
role :string,
owner: { type: Types.Relationship, ref: 'User',filters: { role: 'owner' },many: false, index: true,},
Now coming to superscript, I am not expert there but, I can say that you can either create multiple SS file (if possible )per each owner. or You can try to create superscript topic per each owner.
Please feel free to contact me on skype: sachinbhika, because I am also about to start developing chatbot next week, so by heling you I am helping myself.

Related

How to model account logic?

Say, I want to create an account system. there is a user id, user name, user email and other fields.
I have the following "find_by" scenarios, so I will also have some "find_by" tables such as account_by_name, account_by_email.
When create an account, I need to check whether the name or email has already been used or not.
Considering the restrictions of batch and lwt, how to accomplish the logic above?
Try looking at the KillrVideo example project. You can look at the schema to see how the user tables were modeled, and look at the user DAO code to see how users are created using LWT. KillrVideo also has examples using other programming languages; you will find links to all the github repos on their website.

How to fire method when user enter in group?

Looking at the Telegram API documentation I can't find any hook that allow me to call a method when an user enter in a group.
Note that forma 'enter' I mean when the user open the chat, and not a join to the group.
I'm using TelegrafJS framework.
Kind regards.
As far as I know it's a security feature that you have no access to what people 'open', there is a reason that the join button is there, so that people share their info with the group when they are comfortable sharing it.
If there was, you'd have to use the same solution with a different result (I.E: new_browsed_users)
Since the Update object doesn't return it, then we can assume there isn't a way.
Telegram Bot Event When Users Join To Channel
I'm not in TelegrafJS, but should be like this:
bot.on('new_chat_members', (ctx) => ctx.reply('👍'))
See "new_chat_members" here.

Only allow user to edit own content in Graphcool permissions

I have followed the steps of setting up the Introduction Project at https://www.graph.cool/. In the permissions section for the project I can see and edit the permissions for e.g. Posts:
When clicking the row that shows that Everyone can Edit Data for a Post, a dialogue appears. There I am able to edit the permission so that only authenticated users may edit posts:
However, how can I make a rule so that users can only edit their own posts, and not posts created by other users?
Your question is perfectly timed :-) Yesterday Graphcool released a new advanced permission system based on GraphQL queries that allow you to declare arbitrary permission rules based on relations in your data.
Restricting UPDATE permissions to the owner of a post is a trivial example (code below), but i'll encourage you to take a look at the documentation and start thinking about how this feature can help you implement more complex permission rules
Restricting edits of a post to the author
query ($node_id: ID!, $user_id: ID!) {
SomePostExists(filter:{
id: $node_id,
author: {id: $user_id}
})
}
Documentation
https://www.graph.cool/blog/2017-04-25-graphql-permission-queries-oolooch8oh/
https://www.graph.cool/docs/tutorials/authorization-content-management-system-miesho4goo/

How to get my facebook bot to see what the user has "Liked" using his profile?

This is my first question at stackoverflow, so kindly excuse me if I am not following a standard format.
I have created a facebook bot using different APIs (IMDB, Goodreads, CNN etc.) using Node.js, but the conversations with the users are very precise. I was hoping if there is any way I can use my bot to see what the user has "liked" using his profile so that my bot can talk about those subjects to keep the conversation going.
Has anyone of you implemented anything like this? Kindly share your thoughts and procedure how I can achieve this.
Also, I will highly appreciate if you guys can share some ideas which I can implement in my bot.
Thanks in advance,
Sid
In order to get the (Page) likes of the user, you need to authorize the user with the user_likes permission. Without authorization, this is all you get: https://developers.facebook.com/docs/messenger-platform/user-profile

email notification on new posts to all registered users in phpbb

Am developing a forum for internal use in our company using phpbb. All users are created by admin, so there is no worry about sparm users. I want to send email notification to all registered users on each new post in a specified forum (say company announcement).
I know there is a subscribe forum functionality. But I dont think its a good way to tell all users to subscribe that forum.
Is there any way to achieve this?
in \includes\functions_user.php
FIND:
'user_notify' => 0,
REPLACE IT WITH:
'user_notify' => 1,
That will set the reply notification to default for new users.
IF you have already existent users, then run the following query via phpmyadmin:
UPDATE phpbb_users
SET user_notify = 1
WHERE user_type <> 2;
You can modify the phpbb code to automatically subscribe them to the forum in question upon registration. That way you don't have to tell the users to manually do that.
Pete
As a workaround, if you don't mind doing it, you can send a PM to all registered users every time you post there, with the same content. I'm a member of a phpbb forum where when making a forum post, there's an option to select all registered users.

Resources