Skip to content
blog.fossasia.org
  • Home
  • Projects
    • Contribute
  • Events
    • Eventyay Platform
    • Event Sponsorships
    • Event Calendar
    • FOSSASIA Summit
    • OpenTechSummit China
    • OpenTechSummit Thailand
    • OpenTechSummit Vietnam
    • Jugaad Fest India
    • Past Events
      • FOSSASIA Summit 2022
      • FOSSASIA Summit 2021
      • FOSSASIA Summit 2020
      • FOSSASIA Summit 2019
      • FOSSASIA Summit 2018
      • FOSSASIA Summit 2017
      • FOSSASIA Summit 2016
      • FOSSASIA Summit 2015
      • FOSSASIA Summit 2014
      • FOSSASIA Summit 2012
      • FOSSASIA Summit 2011
      • FOSSASIA Summit 2010
      • GNOME.Asia 2009
      • MiniDebConf Vietnam 2010
      • Sciencehack.Asia
      • Science Hack India
  • Programs
    • Programs and Opportunities
    • Jobs Opportunities
    • Program Guidelines
    • Codeheat Contest
    • University Internship Program
    • University Student Coding Programs
    • High School Student Program
    • Advanced Developer Program
    • Become a Mentor
      • Become A University Student Mentor
      • Become A High School Student Mentor
  • Shop
  • Blog
  • About
    • Jobs
    • Membership
    • Activities
    • Background & Mission
    • Best Practices
    • Licenses
    • Team
    • Code of Conduct
  • Donate
Menu Close
  • Home
  • Projects
    • Contribute
  • Events
    • Eventyay Platform
    • Event Sponsorships
    • Event Calendar
    • FOSSASIA Summit
    • OpenTechSummit China
    • OpenTechSummit Thailand
    • OpenTechSummit Vietnam
    • Jugaad Fest India
    • Past Events
      • FOSSASIA Summit 2022
      • FOSSASIA Summit 2021
      • FOSSASIA Summit 2020
      • FOSSASIA Summit 2019
      • FOSSASIA Summit 2018
      • FOSSASIA Summit 2017
      • FOSSASIA Summit 2016
      • FOSSASIA Summit 2015
      • FOSSASIA Summit 2014
      • FOSSASIA Summit 2012
      • FOSSASIA Summit 2011
      • FOSSASIA Summit 2010
      • GNOME.Asia 2009
      • MiniDebConf Vietnam 2010
      • Sciencehack.Asia
      • Science Hack India
  • Programs
    • Programs and Opportunities
    • Jobs Opportunities
    • Program Guidelines
    • Codeheat Contest
    • University Internship Program
    • University Student Coding Programs
    • High School Student Program
    • Advanced Developer Program
    • Become a Mentor
      • Become A University Student Mentor
      • Become A High School Student Mentor
  • Shop
  • Blog
  • About
    • Jobs
    • Membership
    • Activities
    • Background & Mission
    • Best Practices
    • Licenses
    • Team
    • Code of Conduct
  • Donate

skill meta data

Adding author’s email in SUSI skill files

  • Post author:hkedia321
  • Post published:June 21, 2018
  • Post category:API/FOSSASIA/GSoC/SUSI.AI
  • Post comments:0 Comments

You can create SUSI skills by using skills.susi.ai. When you create a skill, a text file is created and stored in the server. A file can contain many skills inside it, and is thus called an “expert”. The text file contains the metadata like the author’s name, author’s url, description, etc, but it does not contains the author’s email id. Certainly, storing the author’s email along with the skill can be very useful to stuff like get skills for a particular author. But if we provide the option to the user to enter their email, it can easily be misused since they can add emails of other persons. This blog explains how the metadata in the skill file are send by the client and  interpreted by the server, and how the author’s email is added to the text file in a secured way.

Representing and storing metadata in the expert file

Let’s take a look at how the metadata is represented in the expert file. The lines containing the metadata are preceded with “::”. This lets the parser in the server to easily identify the metadata. Now, we can add a new line for the author_email. But if the user is asked to enter email themselves, they can easily add skills in the name of other authors. Thus we need to securely add this data.

::name <Skill_name>
::author <author_name>
::author_url <author_url>
::description <description> 
::dynamic_content <Yes/No>
::developer_privacy_policy <link>
::image <image_url>
::terms_of_use <link>

 

Extracting and adding the author’s email

When the user logs in, their email and access_token is stored in a “cookie”. The email id can be extracted by cookies.get(’emailId’) and the access token can be extracted by cookies.get(‘loggedIn’). Our approach will be to extract the email id, and append it at the top of the expert file.

This how the email is appended and the file is being send to the server in CreateSkill.js file:

let code = this.state.code;
code = '::author_email ' + cookies.get('emailId') + '\n' + code;
let form = new FormData();
form.append('model', 'general');
form.append('group', this.state.groupValue);
form.append('language', this.state.languageValue);
form.append('skill', this.state.expertValue.trim().replace(/\s/g,'_'));
form.append('image', this.state.file);
form.append('content', code);
form.append('image_name', this.state.imageUrl.replace('images/',''));
form.append('access_token', cookies.get('loggedIn'));

let settings = {
    'async': true,
    'crossDomain': true,
    'url': urls.API_URL + '/cms/createSkill.json',
    'method': 'POST',
    'processData': false,
    'contentType': false,
    'mimeType': 'multipart/form-data',
    'data': form
};

 

Making changes in the server to store the author’s email

Since we have just added the author_email in the text file itself similar to the other metadata, we don’t have to do much structural changes in the server side. We just have to add code to detect the ‘author_email’ metadata similar to the other metadata.

In SusiSkill.java file, we add author_email attribute where-ever the other meta data are already present.

And in SusiMind.java file, we add the following lines in the learn() function:

if(json.has("author_email"))
 skill.setAuthorEmail(json.getString("author_email"));

 

Thus, the author’s email is successfully stored in the server along with the other meta-data.

Resources

  • SUSI Skill CMS repository: https://github.com/fossasia/susi_skill_cms
  • SUSI Server repository: https://github.com/fossasia/susi_server
  • Using Jquery Ajax request: http://api.jquery.com/jquery.ajax/
Continue ReadingAdding author’s email in SUSI skill files
  • FOSSASIA
  • Blog
  • GitHub
  • Projects
  • Code of Conduct
  • About
  • Contact
Copyright - OceanWP Theme by OceanWP
 

Loading Comments...
 

You must be logged in to post a comment.