From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: philip@warpmail.net (Philip K.) Newsgroups: gmane.emacs.bugs Subject: bug#39965: [PATCH] Add support for multiple gravatar-like services Date: Tue, 17 Mar 2020 15:37:12 +0100 Message-ID: <87pndbhwtj.fsf@bulbul> References: <20200307001141.10771-1-philip@warpmail.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="34223"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 39965@debbugs.gnu.org To: Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 17 15:38:32 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jEDMV-0008lo-EB for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Mar 2020 15:38:31 +0100 Original-Received: from localhost ([::1]:33874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEDMU-0004l1-FT for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Mar 2020 10:38:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48302) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEDM4-0004K2-Mj for bug-gnu-emacs@gnu.org; Tue, 17 Mar 2020 10:38:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEDM3-0005f9-5m for bug-gnu-emacs@gnu.org; Tue, 17 Mar 2020 10:38:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33426) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEDM2-0005bU-RH for bug-gnu-emacs@gnu.org; Tue, 17 Mar 2020 10:38:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jEDM2-0002JJ-Hr for bug-gnu-emacs@gnu.org; Tue, 17 Mar 2020 10:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: philip@warpmail.net (Philip K.) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Mar 2020 14:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39965 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 39965-submit@debbugs.gnu.org id=B39965.15844558458833 (code B ref 39965); Tue, 17 Mar 2020 14:38:02 +0000 Original-Received: (at 39965) by debbugs.gnu.org; 17 Mar 2020 14:37:25 +0000 Original-Received: from localhost ([127.0.0.1]:39397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jEDLR-0002IP-0m for submit@debbugs.gnu.org; Tue, 17 Mar 2020 10:37:25 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:47707) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jEDLP-0002IA-BM for 39965@debbugs.gnu.org; Tue, 17 Mar 2020 10:37:24 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 33A5A5C025C; Tue, 17 Mar 2020 10:37:16 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 17 Mar 2020 10:37:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=warpmail.net; h= from:to:cc:subject:in-reply-to:date:message-id:mime-version :content-type; s=fm2; bh=ZC9VuSfg+qjxmV3zkwg1tdNoaXo93g0dQff5imz ZtO8=; b=ZFSD0pPnvu4Lda7+2gycgw2TfSOciYA/bdLuR6g7Nn3baR5RW6rCK/C 25v1w3r7Ce0+u9ZerZjf97wCt0eQB6uZJZwXYAdGkHH4S2SWrdW8WBzCYgy1Ee+l UZSeAk5hr126t+8H6LvHrrzHpNx7vyXADi26d28Vh1T1la1wRh1Jw0JFfa9z2R3X 1juI1FPQlPtXnI7q7VtpcQzDH37w4i8OE/euNLqaQ/Vwoo6MxsipAZFzQBiSPmI/ IY/aM2cuMCYLEa+GLaZGK/riE0ub+Pohu7lSxzn/981+NjF6rDn4npVgy+Wcaf81 XLwZ5HZso1w6ttdJqZSq68GzBxno1jg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=ZC9VuSfg+qjxmV3zk wg1tdNoaXo93g0dQff5imzZtO8=; b=Oxw2NbcMNLDYfvYv3lizKTHOsCOJLsNa1 7AQOb6Ugp5UKFc1MLcKcMhEB2laWTECleFwy6zhL/+EcoavfBjFd6TUAvJmGFTaI Gifv0GOQhp5PixXsXU+hyD7oDm+qEpV1LyWg08anlOYvPSKVKQwOQ593X8zmAdTX B1d6+v2aIae5wlQphfKbWMHKRyX+/SiV6XmvdY7uJ/vhMMYWQVYo/BfRZCT8GdAC mTXCTgZctpa7bp1baXTIq1pBoMD3uWSL0Al/xr1KWKDyBIfs/e69Ne+2YFQrYYbg bB/1yXfdRedfowhqQkIIlPIhXbZMkRq7csvFt3AaVaROeoOAk7kxQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudefhedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufgjfffkgggtsehmtderredttdejnecuhfhrohhmpehphhhilhhiphes figrrhhpmhgrihhlrdhnvghtucdlrfhhihhlihhpucfmrddmnecukfhppeejledrvddule drudelledruddvvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpehphhhilhhiphesfigrrhhpmhgrihhlrdhnvght X-ME-Proxy: Original-Received: from localhost (p4fdbc77a.dip0.t-ipconnect.de [79.219.199.122]) by mail.messagingengine.com (Postfix) with ESMTPA id 9992530618C1; Tue, 17 Mar 2020 10:37:15 -0400 (EDT) In-Reply-To: (message from Robert Pluim on Tue, 17 Mar 2020 14:51:22 +0100) Autocrypt: addr=philip@warpmail.net; keydata= mDMEXmoX2BYJKwYBBAHaRw8BAQdA/YuGV2Dy6UZtMk+KfA7Nnlj38k22KQ/+sXVa2ttGaHm0O1Bo aWxpcCBLLiAoZ2VuZXJhdGVkIGJ5IGF1dG9jcnlwdC5lbCkgPHBoaWxpcEB3YXJwbWFpbC5uZXQ+ iJAEExYIADgWIQSx6XCgW+bhLMR4DmPClWiPoyRe6AUCXmoX2AIbAwULCQgHAgYVCgkICwIEFgID AQIeAQIXgAAKCRDClWiPoyRe6IDNAP0eOlYoYIGVcCinuewkEb762T6lqA2hIHcNeRyX8LyQ8gEA krv4pIlZNLF+nBvaCtKvCPZF9428X50CvNvRHCNqgwe4OAReahfYEgorBgEEAZdVAQUBAQdACM09 XXce+t9YpOLbLdESh5g4RTY/0Zys7U1FapIZLA4DAQgHiHgEGBYIACAWIQSx6XCgW+bhLMR4DmPC lWiPoyRe6AUCXmoX2AIbDAAKCRDClWiPoyRe6LYcAQDn15KGn/E9MqloWN4mBJ7/tepYIk2IxrkZ imC531HsIAD+LKQYjorQosVe1oym0VZjmgKsem1kJZHG2tY601I+QwM= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:177451 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Robert Pluim writes: > Sorry for my delay in getting back to you. I have one question: > > [...] > > Here you do the SRV lookup for the TCP service, but I believe there=CA=BCs > an HTTPS service type available as well. Could you look that up first, > then the TCP one, then fall back to the default libravatar URL? You're right, I missed that. This patch checks the avatar-sec and avatar record. I rewrote it a bit, to avoid duplication, so I hope the style is ok. --=20 Philip K. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-support-for-multiple-Gravatar-services.patch >From 45ef168f4c7b2c0195de040570fa613c89e41ae4 Mon Sep 17 00:00:00 2001 From: Philip K Date: Tue, 10 Mar 2020 10:21:08 +0100 Subject: [PATCH] Add support for multiple Gravatar services Now supports Libravatar and Unicornify, next to Gravatar. * lisp/image/gravatar.el (gravatar-base-url): Remove constant. (gravatar-service-alist): List supported services. (gravatar-service): Add user option to specify service, defaults to Libravatar. (gravatar--service-libravatar): Add libravatar image host resolver implementation. (gravatar-build-url): Use alist gravatar-service-alist instead of gravatar-base-url. * etc/NEWS: Add note. --- etc/NEWS | 6 ++++++ lisp/image/gravatar.el | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7f70d149d6..7d9f858555 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -171,6 +171,12 @@ key binding / v package-menu-filter-by-version / / package-menu-filter-clear +** Gravatar + +=== +*** New user-option 'gravatar-service' for host to query for gravatars. +Defaults to Libravatar, with Unicornify and Gravatar as options. + * New Modes and Packages in Emacs 28.1 diff --git a/lisp/image/gravatar.el b/lisp/image/gravatar.el index b8542bc3c3..9b4e93275d 100644 --- a/lisp/image/gravatar.el +++ b/lisp/image/gravatar.el @@ -118,9 +118,37 @@ gravatar-force-default :version "27.1" :group 'gravatar) -(defconst gravatar-base-url - "https://www.gravatar.com/avatar" - "Base URL for getting gravatars.") +(defconst gravatar-service-alist + `((gravatar . ,(lambda (_addr) "https://www.gravatar.com/avatar")) + (unicornify . ,(lambda (_addr) "https://unicornify.pictures/avatar/")) + (libravatar . ,#'gravatar--service-libravatar)) + "Alist of supported gravatar services.") + +(defcustom gravatar-service 'libravatar + "Symbol denoting gravatar-like service to use. +Note that certain services might ignore other options, such as +`gravatar-default-image' or certain values as with +`gravatar-rating'." + :type `(choice ,@(mapcar (lambda (s) `(const ,(car s))) + gravatar-service-alist)) + :version "28.1" + :link '(url-link "https://www.libravatar.org/") + :link '(url-link "https://unicornify.pictures/") + :link '(url-link "https://gravatar.com/") + :group 'gravatar) + +(defun gravatar--service-libravatar (addr) + "Find domain that hosts avatars for email address ADDR." + ;; implements https://wiki.libravatar.org/api/ + (require 'dns) + (let* ((domain (save-match-data + (unless (string-match ".+@\\(.+\\)" addr) + (error "%s is not an email address" addr)) + (match-string 1 addr))) + (result (dns-query (concat "_avatars._tcp." domain) 'SRV))) + (if result + (concat "http://" result "/address") + "https://seccdn.libravatar.org/avatar"))) (defun gravatar-hash (mail-address) "Return the Gravatar hash for MAIL-ADDRESS." @@ -142,7 +170,8 @@ gravatar-build-url "Return the URL of a gravatar for MAIL-ADDRESS." ;; https://gravatar.com/site/implement/images/ (format "%s/%s?%s" - gravatar-base-url + (funcall (alist-get gravatar-service gravatar-service-alist) + mail-address) (gravatar-hash mail-address) (gravatar--query-string))) -- 2.20.1 --=-=-=--