Dynamic Linking
Erstellt nun Dynamic links anstelle von normalen links
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
var push = require('../push/push');
 | 
			
		||||
var axios = require('axios')
 | 
			
		||||
const {
 | 
			
		||||
    query,
 | 
			
		||||
    nonQuery
 | 
			
		||||
@@ -452,13 +453,37 @@ async function verifyInvite(link, user_id) {
 | 
			
		||||
 | 
			
		||||
async function createInvite(sl_id) {
 | 
			
		||||
    try {
 | 
			
		||||
        let link = generateInviteLink();
 | 
			
		||||
        await nonQuery('UPDATE "Shoppinglist" SET invitelink = $1 WHERE sl_id = $2;', [link, sl_id]);
 | 
			
		||||
        let output = generateInviteLink(sl_id);
 | 
			
		||||
         var link;
 | 
			
		||||
         axios({
 | 
			
		||||
                 method: 'POST',
 | 
			
		||||
                 url: 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw',
 | 
			
		||||
                 data: {
 | 
			
		||||
                     "dynamicLinkInfo": {
 | 
			
		||||
                         "domainUriPrefix": "https://invite.dergeorg.at/invite",
 | 
			
		||||
                         "link": "https://smartshopper.cf/invite/" + output+"?slid="+sl_id,
 | 
			
		||||
                         "androidInfo": {
 | 
			
		||||
                             "androidPackageName": "at.smartshopper.smartshopperapp"
 | 
			
		||||
                         }
 | 
			
		||||
                     }
 | 
			
		||||
                 }
 | 
			
		||||
             })
 | 
			
		||||
             .then(async function(result) {
 | 
			
		||||
                 console.log("ShortLink: ", result.data.shortLink);
 | 
			
		||||
                 link = result.data.shortLink;
 | 
			
		||||
                 link= link.replace("https://invite.dergeorg.at/invite/", "");
 | 
			
		||||
                  console.log("generated link: ", link, " \nSL_id ", sl_id)
 | 
			
		||||
                  await nonQuery('UPDATE "Shoppinglist" SET invitelink = $1, dynamiclink = $2 WHERE sl_id = $3;', [output, link, sl_id]);
 | 
			
		||||
                  return result.data.shortLink;
 | 
			
		||||
             })
 | 
			
		||||
             .catch(err => console.error(err));
 | 
			
		||||
       
 | 
			
		||||
    } catch (error) {
 | 
			
		||||
        console.error(error);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//User manuell einladen
 | 
			
		||||
async function manInvite(sl_id, uid) {
 | 
			
		||||
    try {
 | 
			
		||||
@@ -555,16 +580,15 @@ function items_in_groups(groups, items, sl_id, sl_admin, sl_members, name, descr
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Create invite link for your own shoppinglist
 | 
			
		||||
function generateInviteLink() {
 | 
			
		||||
//Create invite link for your own shoppinglist 
 | 
			
		||||
function generateInviteLink(actsl_id) {
 | 
			
		||||
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
 | 
			
		||||
    var output = "";
 | 
			
		||||
 | 
			
		||||
    for (let i = 0; i < 50; i++) {
 | 
			
		||||
        output += possible.charAt(Math.floor(Math.random() * possible.length));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return output;
 | 
			
		||||
   return output
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function users_to_array(admin, members) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user