fix(3p/lieer): Work around issues in Google Mail API

There is a temporary issue affecting the retrieval of discovery
documents in the Google Mail API:
https://issuetracker.google.com/issues/160441983

It's possible to work around this by hardcoding the document instead
of retrieving it over the network, as all other API calls still work
as they should.

This does exactly that by generating a patch to apply to lieer, from
the file checked in to the depot with this commit.

This workaround should be reverted once Google has fixed the issue
upstream.

Change-Id: I0063d0bc67753ffa5261c2aa059c7bfd09136ba0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/945
Tested-by: BuildkiteCI
Reviewed-by: isomer <isomer@tvl.fyi>
This commit is contained in:
Vincent Ambo 2020-07-06 22:30:55 +01:00 committed by tazjin
parent a0f9ae996d
commit 8b58593193
3 changed files with 3836 additions and 0 deletions

View file

@ -26,6 +26,10 @@ let
export PROJECT_ID='${project}'
cat ${./api_client.patch} | ${gettext}/bin/envsubst > $out
'';
discoveryPatch = runCommand "discovery_doc.patch" {} ''
export DISCOVERY_DOC='${./gmail-api.json}'
cat ${./discovery_doc.patch} | ${gettext}/bin/envsubst > $out
'';
in python3Packages.buildPythonApplication rec {
name = "lieer-${version}";
version = "1.0";
@ -39,6 +43,7 @@ in python3Packages.buildPythonApplication rec {
patches = [
authPatch
discoveryPatch
./send_scope.patch
];

15
third_party/lieer/discovery_doc.patch vendored Normal file
View file

@ -0,0 +1,15 @@
diff --git a/lieer/remote.py b/lieer/remote.py
index 6e3973a..2b0b59e 100644
--- a/lieer/remote.py
+++ b/lieer/remote.py
@@ -386,7 +386,9 @@ class Remote:
if timeout == 0: timeout = None
self.http = self.credentials.authorize (httplib2.Http(timeout = timeout))
- self.service = discovery.build ('gmail', 'v1', http = self.http)
+ with open('${DISCOVERY_DOC}', 'r') as file:
+ discovery_doc = file.read()
+ self.service = discovery.build_from_document(discovery_doc, http = self.http)
self.authorized = True
def __get_credentials__ (self):

3816
third_party/lieer/gmail-api.json vendored Normal file

File diff suppressed because it is too large Load diff