Ruby Rical Timezone problem - ruby-on-rails

I'm using Ruby Rical to basically generate an icalendar as a response to an original icalendar specifing that I'm attending (accepting) the invitation.
I can generate the response correctly but I'm having a problem with timezones, basically if I let RiCal infer the correct Timezone, it works correctly depending on the TimeZone String specified in the original file.
Let me put this in examples:
I can reply this invitation from Google Calendar without problems:
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20091226T210000Z
DTEND:20091226T220000Z
DTSTAMP:20091223T191926Z
ORGANIZER;CN=xxx xxx:mailto:x...#xxxx.com
UID:4kkcos0ovgf9cvo3su6hlql...#google.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE;CN=xxxx xxxx;X-NUM-GUESTS=0:mailto:x...#xxxx.com
CREATED:20091223T191925Z
DESCRIPTION:View your event at 4NmIxMmM1ZmJiODM4OTEx&ctz=America%2FLos_Angeles&hl=en.
LAST-MODIFIED:20091223T191925Z
LOCATION:800-292-2393 pin 1234
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test google calendar attendance response
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
But I'm getting an error (no such file to load -- tzinfo/definitions/US/Pacific) when I generate the response to an Ical (Mac Ical.app) invitation:
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
VERSION:2.0
METHOD:REQUEST
PRODID:-//Apple Inc.//iCal 4.0.1//EN
BEGIN:VTIMEZONE
TZID:US/Pacific
BEGIN:DAYLIGHT
TZOFFSETFROM:-0800
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
DTSTART:20070311T020000
TZNAME:PDT
TZOFFSETTO:-0700
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0700
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
DTSTART:20071104T020000
TZNAME:PST
TZOFFSETTO:-0800
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
ATTENDEE;CN="x...#xxxx.com";CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTI
ON;RSVP=TRUE:mailto:x...#xxxx.com
DTEND;TZID=US/Pacific:20091231T091500
As you see TZID:US/Pacific is an invalid time zone indentifier for RiCal, so in these cases.. How would you do to answer this type of icalendar using Rical and conserving the original Timezone?
Please if I'm not clear with the question, ask me anything that you need.

I think RiCal uses TZInfo for its timezone support. You are presumably currently using the cut-down version of TZInfo that is included in Ruby on Rails' ActiveSupport library. This doesn't contain the US/Pacific timezone definition that you need.
The full version of TZInfo does include US/Pacific. If you install the tzinfo gem and then restart your Rails app, you should find that this works.

Related

In-place archive mail's parent id is wrong

Request a message-delta-API to retrieve emails from Office 365
But responsed email's parent id is different from requested mail folder id.
GET users/<user_id>/mailfolders/AAMkADE0YzI2M2ZjLWZmMWQtNGJhYS04ODAwLTQyNGE1MjRhZjBmNAAuAAAAAAA04VsRWcG1QIXIr3qrtsr6AQCQoXa_LYT9R6mod2ub97_KAAAAaLhVAAA=/messages/delta
"id": "AAMkAGE4NTUwNThkLWQ2ZTMtNDExNS04NDAxLTJlZDk1NmU0MGE2MQBGAAAAAAAfiKJvRm_JQ4jeiUSK2FOEBwCQoXa_LYT9R6mod2ub97_KAAAAaLhVAADJFo_o3DVNT7IA4GCQhOQ3AAAyXPH0AAA=",
"parentFolderId": "AAMkAGE4NTUwNThkLWQ2ZTMtNDExNS04NDAxLTJlZDk1NmU0MGE2MQAuAAAAAAAfiKJvRm_JQ4jeiUSK2FOEAQCQoXa_LYT9R6mod2ub97_KAAAAaLhVAAA=",
The mail folder id seems to have a strange translation? Maybe it is in some O365 operation like migration or something?
mail folder id
AAMkADE0YzI2M2ZjLWZmMWQtNGJhYS04ODAwLTQyNGE1MjRhZjBmNAAuAAAAAAA04VsRWcG1QIXIr3qrtsr6AQCQoXa_LYT9R6mod2ub97_KAAAAaLhVAAA=
email's parentFolderId
AAMkAGE4NTUwNThkLWQ2ZTMtNDExNS04NDAxLTJlZDk1NmU0MGE2MQAuAAAAAAAfiKJvRm_JQ4jeiUSK2FOEAQCQoXa_LYT9R6mod2ub97_KAAAAaLhVAAA=
Request informat attached, hope it can help for investgation.
cache-control →private
client-request-id →b60c6917-3e8e-41db-ac12-e0e36831ab5d
content-encoding →gzip
content-length →29658
content-type →application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
date →Thu, 07 Jan 2021 02:59:22 GMT
odata-version →4.0
preference-applied →odata.track-changes
request-id →b60c6917-3e8e-41db-ac12-e0e36831ab5d
strict-transport-security →max-age=31536000
vary →Accept-Encoding
x-ms-ags-diagnostic →{"ServerInfo":{"DataCenter":"East Asia","Slice":"SliceC","Ring":"3","ScaleUnit":"000","RoleInstance":"AGSFE_IN_9"}}
3.This mailfolder is in-place archive mail folder, ews-managed API has the same problem. too
I tried the same with EWS Editor utility (with same API call) and it works for me. So i would suggest you to try the same.

Rails w/ Google API Client: header field value cannot include CR/LF

ArgumentError in Users::OmniauthCallbacksController#google_oauth2
header field value cannot include CR/LF
Really unsure where this error is coming from.
I'm using ruby 2.5, Rails 5, and google-api-client 0.8.2
Any ideas how to fix or what information I can provide to make this question more informative?
Update: My logs show this when I am trying to authorize with Google's API
Google::APIClient::Request Sending API request get https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest {"User-Agent"=>"hello U/1.0.0 google-api-ruby-client/0.8.2 Mac OS X/10.13.4\n (gzip)", "Accept-Encoding"=>"gzip", "Content-Type"=>""}
And from my research, CRLF is "\r\n" characters, right?
So "User-Agent"=>"hello U/1.0.0 google-api-ruby-client/0.8.2 Mac OS X/10.13.4\n
is probably the issue.
So my question would be- how do I access User Agent in my request to fix this issue with Rails 5?
When using the Google::APIClient, the generated User-Agent may contains a CRLF. It can can be overridden in constructor. Example :
Google::APIClient.new(application_name: 'Foo', application_version: '1.0', user_agent: 'Foo/1.0 google-api-ruby-client/0.8.6 Linux/4.15.0-65-generic (gzip)')
You can modify the user_agent string to remove the CR/LF. I am using Rails 4.1.8 and google-api-client version `
#api_client = Google::APIClient.new(:application_name=>"Chronos", :application_version=>0)
# work around a bug that puts a CR/LF in the user agent string
#api_client.user_agent = #api_client.user_agent.gsub("\n", "")
Update gem google-api-client to version 0.20.0. It solves the problem but requires other changes to the application
Updating the version of the google-api-client gem did the trick for me.

omniauth gowalla strategy error: comparison of String with Bignum failed

as far as I can get gowalla auth code response contains both expires_at and expires_in but
expires_at is not valid date string so it throws error while comparing dates
any idea to hack omniauth or gowalla strategy would be very welcome!!!
rails 3.0.9
ruby 1.9.2
comparison of String with Bignum failed
oauth2 (0.5.0) lib/oauth2/access_token.rb:72:in `<'
oauth2 (0.5.0) lib/oauth2/access_token.rb:72:in `expired?'
oa-oauth (0.3.0) lib/omniauth/strategies/oauth2.rb:67:in `callback_phase'
{
"scope":"read",
"expires_at":"Sun, 09 Oct 2011 12:47:37 -0000",
"username":"altuure",
"expires_in":1172767,
"refresh_token":"XX",
"access_token":"XX"
}
Why don't you just use whatever you can. expires_in appears to be an interval, so you can do:
expires_at = Time.now + json["expires_in"].to_i
That said, the date string for expires_at definitely parses in 1.9.2-p290 (using DateTime.parse(str)). There's always DateTime.strptime if you need to parse a date/time string according to a given format.
sorry for delay but I commited the patch to the github you can find the details over here http://github.com/intridea/omniauth/issues/485 –

Timezone from geolocation

I have a geolocation pair latitude/longitude, is there any way/tool to get the corresponding time zone?
A website called EarthTools has a web service for that.
http://www.earthtools.org/webservices.htm#timezone
You can pass in latitude and longitude like so:
h ttp://www.earthtools.org/timezone/40.71417/-74.00639
And it spits out the time zone and a bunch of other info:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<timezone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.earthtools.org/timezone.xsd">
<version>1.1</version>
<location>
<latitude>40.71417</latitude>
<longitude>-74.00639</longitude>
</location>
<offset>-5</offset>
<suffix>R</suffix>
<localtime>4 Dec 2005 12:06:56</localtime>
<isotime>2005-12-04 12:06:56 -0500</isotime>
<utctime>2005-12-04 17:06:56</utctime>
<dst>False</dst>
</timezone>
If an external dependancy is not ideal (obviously this brilliant for client side geo location).
Then I recommend reading the answer to this question
Easiest Way to Convert lat lng/zip/city/state to Timezone in Ruby

Darwin Streaming Server Log Format?

I am writing a program that will parse and manipulate logs from Darwin Streaming Servers. Where can I get a definition of what the individual fields headers mean? Are there some kind of documentation in the DSS doc files?
For example, I have this as the log output header:
c-ip date time c-dns cs-uri-stem c-starttime x-duration c-rate c-status c-playerid c-playerversion c-playerlanguage cs(User-Agent) c-os c-osversion c-cpu filelength filesize avgbandwidth protocol transport audiocodec videocodec sc-bytes cs-bytes c-bytes s-pkts-sent c-pkts-received c-pkts-lost-client c-buffercount c-totalbuffertime c-quality s-ip s-dns s-totalclients s-cpu-util cs-uri-query c-username sc(Realm)
Please check:
QuickTime Streaming Server 2.0 Access Log Format
http://support.apple.com/kb/TA26756?viewlocale=en_US
I've managed to get some information about the log format from the net, but this is not complete. Is there a link to the complete log format?
DSS Log Format (Google Docs)

Resources