Gmail Action sending mail from AppScript - google-schemas

I'm trying to include the inbox gmail action in a mail sent from an google appscript.
I log the entire body before send the mail.
This is the html
<html>
<body>
<div itemscope itemtype="http://schema.org/EmailMessage">
<meta itemprop="description" content="Approvazione richiesta da Intranet Noovle"/>
<div itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction">
<meta itemprop="name" content="Accetta"/>
<div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<link itemprop="url" href="https://www.google.com"/>
</div>
</div>
</div>
<div>
<p>Gentile
Mr X,
</p>
<p>Lorem ipsum...
</p>
...
...
</body>
</html>
If I try to send this email from a Google AppScript, without whitelisting the address but sending the mail to the sender, the button isn't displayed.
But if I try to use the Google Validator (https://developers.google.com/gmail/actions/testing-your-schema),it validates the action gmail schema and then tryies to send a real mail to the current google account logged (from the same account, like I did in the app script)
And the mail come right with the action!
Are there any App script limits?

Emails with markup need to be signed with DKIM/SPF for the actions to be rendered. Are you using a Gmail account or a Google Apps account? With the latter, if DKIM is properly configured for the domain, you should get a valid signature.

Related

Star ratings wrong on Google using Schema

I'm trying to impliment the "Review ratings" schema on my Google listings.
My "total score" structure is as follows:
<div class="span7" itemscope itemtype="http://schema.org/Place">
<div class="stars" onclick="document.location.href='http://www.chambresdhotes.org/cgi-bin/links/review.cgi?ID=65995'" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<span class="badge badge-success">5 avis</span>
<meta itemprop="bestRating" content="10" />
<meta itemprop="worstRating" content="8" />
<meta itemprop="ratingValue" content="9.2" />
<meta itemprop="ratingCount" content="5" />
</div>
</div>
Then, for each of the reviews on that page - I also have:
<div class="reviewBox" itemscope itemtype="http://schema.org/Review">
<meta itemprop="author" content="Patrice" />
<meta itemprop="itemreviewed" content="Les Collinades" />
<div class="reviewRating" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<span class="link-rating"><span class="rating-5"></span></span>
<meta itemprop="bestRating" content="5" />
<meta itemprop="ratingValue" content="5" />
</div>
</div>
This all shows up OK when doing a schema check on the Google tool here:
https://search.google.com/structured-data/testing-tool#url=http%3A%2F%2Fwww.chambresdhotes.org%2FDetailed%2F65995.html
The "overall" ranking / number of reviews etc:
...and then the individual review scores:
However, when you go here its wrong:
https://www.google.fr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=site:www.chambresdhotes.org+Detailed%2F65995.html
I'm a bit baffled as to why its doing this. What am I missing?
Thanks!
It looks like you've filled out bestRating and worstRating with the best and worst ratings your business has received. However, these are intended to be used to define the best possible and worst possible ratings.
Going from your example, I assume your customers can rate your business on a scale of 1 to 10. As such, bestRating would have to be 10 and worstRating would have to be 1.
You then have to calculate the average overall rating yourself, and put that under ratingValue

Methods in service doesn't work ok in the gsp file

I have a list with two buttons and I want that everytime that I press a button, work the code that I have associated to this button. This code is in a service, and the gsp file is a default list.gsp
To call the service from the gsp. I took this post:(How do I call a Grails service from a gsp?) to do it.
The problem is that I have two methods in the service and I don't know why, but always that I enter in the list.gsp and always that I press the button I can see display in the console of grails that the two methods are working at the same time.
This is that I can see in the console everytime I push button A or B:
2015-12-01 12:51:47,565 [http-bio-8090-exec-5]
hello
world
That I want is that if I press button A show this:
2015-12-01 12:51:47,565 [http-bio-8090-exec-5]
hello
and if I press button B show this:
2015-12-01 12:51:47,565 [http-bio-8090-exec-5]
world
And this is that I can see in the console everytime that I run and enter in the gsp.file and I want that don't run the code unless I press the button:
2015-12-01 12:51:47,565 [http-bio-8090-exec-5]
hello
world
Thanks in advance
This is my code in gsp:
<%# page import="com.app.test" %>
<%# page import="mypackage.myService" %>
<!DOCTYPE html>
<html>
<head>
<meta name="layout" content="main">
<g:set var="entityName" value="${message(code: 'licenseType.label', default: 'LicenceType')}" />
<title><g:message code="default.list.label" args="[entityName]" /></title>
</head>
<body>
<g:message code="default.link.skip.label" default="Skip to content…"/>
<div class="nav" role="navigation">
<ul>
<li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
<% def LicenceTypeService =
grailsApplication.classLoader.loadClass('mypackage.myService').newInstance()%>
<li><g:link action="list"><g:message code="Calculate Licence Type" args="[entityName]" /><span>${myService.calculate()}</span></g:link></li>
<li><g:link action="list"><g:message code="Re-Calculate Licence Type" args="[entityName]" /><span>${myService.recalculate()}</span></g:link></li>
</ul>
</div>
In the service:
class MyService {
def calculate(){
println "hello"
}
def recalculate(VoiceUser vUser){
println "world"
}
}
I'm fairly certain this is impossible; what you are asking is to send an Ajax call directly to a grails service. If you think about it, once the generated HTML has been received by the client, there is not a direct connection between the browser and back-end (grails application) so there can't be any grails magic that allows this to happen.
There is a grails tag g:remoteLink that will allow Ajax calls to a controller action, the controller is necessary at this point because all new interactions once the generated html is in place must be through standard HTTP requests and requests are handled through grails controllers.
Your best bet would be to create a controller that wraps the 2 service methods and use the actions with g:remoteLink or another Ajax request.
As to using a service within a gsp, instead of instantiating a new service, I would argue in favor of using the existing spring bean.
Replace:
<%# page import="mypackage.myService" %>
...
<% def LicenceTypeService = grailsApplication.classLoader.loadClass('mypackage.myService').newInstance()%>
With:
<g:set var="myService" bean="myService"/>

find out how request is issued

On a site it offers the option of changing your last name, to confirm this it sends a confirmation link to your email.
My question is, how do i figure out how the request is made (if it's POST or GET)? I monitored with live http headers, tamper data, fiddler and burp suite but all have shown there is 0 traffic. When i check my email, i have received the confirmation link.
Here is the html source code of the change lastname button:
<form>
<div class="m-lastname-updated">
<div class="m-h3">One more step</div><p>We have sent you a confirmation email. To change your last name click the sent link in your email!</p>
</div><div class="m-field m-lastname"><div class="m-h3">Last Name</div>
<span class="m-error"></span>
<input type="text" maxlength="100" class="m-input" name="lastname">
<p>Your last name is never shared</p></div><button style="display: inline-block;">Change</button>
</form>
Thanks to anyone who can help me understand how this request is made.
The url this is available on is in this example, http://example.com/profile/.
When a form is submitted, the request is done by default with method="GET" if the method is not specified as method="POST".
To see this, form example, if you use PHP script lastname.php as action:
<?php
echo "<pre>
\$_GET:";
print_r($_GET);
echo "</pre>";
echo "<pre>
\$_POST:";
print_r($_POST);
echo "</pre>";
?>
<form>
<div class="m-lastname-updated">
<div class="m-h3">One more step</div><p>We have sent you a confirmation email.
To change your last name click the sent link in your email!</p>
</div><div class="m-field m-lastname"><div class="m-h3">Last Name</div>
<span class="m-error"></span>
<input type="text" maxlength="100" class="m-input" name="lastname">
<p>Your last name is never shared</p></div><button style="display: inline- block;">Change</button>
</form>
You will see something like this:
$_GET:Array
(
[lastname] => mygod
)
$_POST:Array
(
)
$_GET is filled while $_POST contains no elements.

Symfony 1.4 ghost user - current user changes to different user

I have the following code to display the currently logged in user in my application. The strange thing is intermittantly on odd occasions while the user is browsing from one page to another the username of the logged in user changes to another user who is in the database. Logging out and logging back in then displays the current username.
<? if ($sf_user->isAuthenticated()){?>
<div id="welcome">
You are signed in as <strong><?php echo sfContext::getInstance()->getUser()->
getGuardUser()->getName()?></strong> Logout
</div>
<div class="clear"></div>
<? } ?>
Any ideas what could be causing thing?
I can confirm both users were logged in on the same day but at different locations.
Use $sf_user in your views instead sfContext
Like:
<? if ($sf_user->isAuthenticated()){?>
<div id="welcome">
You are signed in as <strong><?php echo $sf_user->getName()?></strong> Logout
</div>
<div class="clear"></div>
<? } ?>

Permanent URL Parameters

I have been building a fashion e-commerce app that is quite far along the development cycle. It caters for both men's and women's products. At the moment, the user selects their gender at the start, and a gender_id is then passed into the user's session. This ID is then used in many of the queries throughout the site, and it determines which gender products the user is shown.
However, for SEO purposes, it is necessary that this information is shown in the URL and not the session. I do not want to have to pass a gender parameter for every link I do, like this...
http://www.shop.com/products?category=Jeans&gender=women
Essentially what I'd like to do is input the gender into the route, and have it stay. I have seen some sites where the URL is structured as follows...
http://www.shop.com/women/products?category=Jeans
How can I achieve this second URL structure with minimal impact to my controllers? Or perhaps there is a different way I could achieve my goal? Thanks!
Put it in your routes with a scope:
scope ':gender', :constraints => {:gender => /women|men/} do
resources :products
resources :cart
# other routes here
end
You can access gender with params[:gender]. Any routes you place in that block will be scoped to a gender context.
Additionally, the gender scope will default to the current scope when generating urls. For example, if I browse to /men/products and in that view I have a link to cart, if the url is generated with cart_path the url will be /men/cart. Once the select a gender you could write redirect them to the proper scoped path. The one problem I see is that you lose the unstopped routes for product and cart with this method.
You can pass in default GET parameters to your routes. For example, the pattern below would match http://www.shop.com/women/products?category=Jeans and automatically append gender=women to your params hash.
get '/women/products' => 'Products#index', :gender => 'women'
get '/men/products' => 'Products#index', :gender => 'men'
You could also generalize this a little more by using a placeholder and a constraint in the route definition.
get '/:gender/products' => 'Products#index', :constraints => {:gender => /men|women/}
Instead of doing a HTTP-GET, you may want to take a look at HTTP-POST which doesn't pass variables in the URL. For example, here is a simple HTML-page with one HETT-GET action and one HTTP-POST action:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<title>HTTP example</title>
</head>
<body>
<h1>POST & GET example</h1>
<h2> Post form</h2>
<form method="post" action="post_get2.php">
text:<input type="text" size =40 name="name">
<input type=submit value="Submit Post">
</form>
<h2> GET form</h2>
<form method="get" action="post_get2.php">
text:<input type="text" size =40 name="name">
<input type=submit value="Submit Get" >
</form>
</body>
</html>
And here's a simple PHP-page (post_get2.php) that detects if you made a POST or GET action and prints it on the page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<title>HTTP example</title>
</head>
<body>
<h1>POST & GET example</h1>
<?
function stripFormSlashes($arr)
{
if (!is_array($arr))
{
return stripslashes($arr);
}
else
{
return array_map('stripFormSlashes', $arr);
}
}
if (get_magic_quotes_gpc())
{
$_GET = stripFormSlashes($_GET);
$_POST = stripFormSlashes($_POST);
}
echo ("<br/>");
echo ("<pre>");
echo ("POST info:\n");
print_r($_POST);
echo("</pre>");
echo ("<br/>");
echo ("<pre>");
echo ("GET info:\n");
print_r($_GET);
echo("</pre>");
if($_GET['name'])
{
$name = $_GET['name'];
}
echo($name);
?>
<p>
<a><input type="button" value="back" onclick="history.go(-1)"></a>
</p>
</body>
</html>
The great thing with POST is that it doesn't show what choices you made on your page. It just shows 'http://www.shop.com/products' all the time. Unlike GET 'http://www.shop.com/products?category=Jeans&gender=women'

Resources