valery303 / gmail-delay-send

Automatically exported from code.google.com/p/gmail-delay-send
0 stars 0 forks source link

Fix send tomorrow #139

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
=======================================
=== PLEASE READ BEFORE FILING ISSUE:
https://code.google.com/p/gmail-delay-send/wiki/GmailDelaySendDebugging_8
=======================================

What steps will reproduce the problem?
1. I put @8am in the email.
2. I save it as a draft at 6pm
3. The mail is sent inmediatly, instead of waiting until the next day at 8pm

What is the expected output? What do you see instead?
I know that this is not a limitation of gmail-delay-send, and it's datejs' 
"Gotchas". I did some code modifications as a workaround. I also think that 
something like this could be done to solve Issue #30.

I want to state that I'm not a professional javascript developer, hence my code 
may need some polishing. Also, I haven't fully tried this. I'm publishing it 
here so the experts can take a look at it. (please tell me if it goes somewhere 
else, since I'm not familiar with google code)

Main.gs

+L88 metaData.messageDate = message_date_user_timezone;

-L95 function timeToSendMessage(messageSendDate) {
+L95 function timeToSendMessage(messageSendDate, origDate) {
+L96   // Check if the specified time is after the message was written
  if(messageSendDate <= origDate) {
    // Add a day
    messageSendDate.addDays(1);
  }

-L109 debug('Detected time to send message: ' + timeToSend + '. Send Date: ' + 
dateToStringWithoutTimezone(messageSendDate) + ' Current user date:' + 
dateToStringWithoutTimezone(user_time));

+L109 debug('Detected time to send message: ' + timeToSend + '. Send Date: ' + 
dateToStringWithoutTimezone(messageSendDate) + '. Orig. Date: ' + 
dateToStringWithoutTimezone(origDate) + ' Current user date:' + 
dateToStringWithoutTimezone(user_time));

-L155 else if(timeToSendMessage(metaObj.sendDate) && sendMessage(message, 
metaObj))

+L155   else if(timeToSendMessage(metaObj.sendDate, metaObj.messageDate) && 
sendMessage(message, metaObj))

-------------------------
I'm sorry for the "manual" changelog, but I wanted to share my findings, they 
may help somebody out.

Original issue reported on code.google.com by gdlinden...@zonedevelopments.com.ar on 22 Jan 2014 at 2:28

GoogleCodeExporter commented 8 years ago
Hello  gdlindenberg,

I really appreciate the patch and the work that you have put in checking out 
the code!

I'd love to work on how to fix this datejs gotcha, but I'm not sure this patch 
would work in all cases..

With the patch above you add 1 day if the mail composition time is before the 
'send at' date.

But what if the user would like to send at '@tuesday' but it's currently Thurs? 
 With the current state of datejs the email would be send immediately, because 
it assumes that you really wanted to send it 2 days ago (which is pretty dumb).

With this patch it would be sent on Friday?

Original comment by blairk...@gmail.com on 22 Jan 2014 at 5:28

GoogleCodeExporter commented 8 years ago
I 'designed' the patch to work with hours since it was what I needed. The main 
problem is how gmail delay send works, since it checks "If NOW is greater than 
the send time, then send", of course it's not gmail delay send's fault that de 
datejs plugin has it's faults.

I don't have the java programming skills to do it properly, but I think that 
the function that decides when to send it has to be rewritten, using some kind 
of check like I did, for example, if the mail is scheduled for Thuesday and 
today is friday, then check
1) What day was the email written? (We have access to that info as I used in my 
quick fix)
2) What day datejs says we need to send it (it will say last tuesday)
3) Is that day greater than the day the email was written?
4) If it is, then send it.

I can -try- to assist of course, but my javascript skills aren't that good, and 
my code is not even near polished

Original comment by gdlinden...@zonedevelopments.com.ar on 24 Jan 2014 at 12:38

GoogleCodeExporter commented 8 years ago

Original comment by blairk...@gmail.com on 21 Mar 2014 at 9:48