]> git.rmz.io Git - dotfiles.git/commitdiff
mutt: office365 contacts completion
authorSamir Benmendil <samir.benmendil@ultrahaptics.com>
Fri, 18 May 2018 17:03:27 +0000 (18:03 +0100)
committerSamir Benmendil <samir.benmendil@ultrahaptics.com>
Fri, 18 May 2018 17:03:27 +0000 (18:03 +0100)
bin/office365-book [new file with mode: 0755]
mutt/accounts/gmail
mutt/accounts/office365
mutt/muttrc

diff --git a/bin/office365-book b/bin/office365-book
new file mode 100755 (executable)
index 0000000..3054a5c
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+user=samir.benmendil@ultrahaptics.com
+pass=$(pass ultrahaptics/okta.com/samir.benmendil@ultrahaptics.com)
+url="https://outlook.office365.com/EWS/Exchange.asmx"
+
+read -r -d '' data <<EOF
+<?xml version="1.0" encoding="utf-8"?>
+<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
+    <soap:Body>
+        <ResolveNames 
+            xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
+            xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
+            ReturnFullContactData="true">
+            <UnresolvedEntry>$1</UnresolvedEntry>
+        </ResolveNames>
+    </soap:Body>
+</soap:Envelope>
+EOF
+
+out=$(curl -s -u "$user:$pass" -L "$url" -d "$data")
+
+readarray -t email < <(echo $out | xpath -q -e '//t:Mailbox/t:EmailAddress/text()')
+readarray -t name  < <(echo $out | xpath -q -e '//t:Contact/t:DisplayName/text()')
+
+count=${#email[@]}
+
+if [[ "$count" -eq 0 ]]; then
+    echo "No matches"
+    exit 1
+fi
+
+echo "$count matches"
+for (( i = 0; i < $count; i++ )); do
+    echo -e "${email[$i]}\t${name[$i]}\t"
+done
index 69458e0fdfc0161fe5d9af822a047aa8f5a52e71..f5cdc6afcb2898c34cfeea3ce2ab49a6f4ef6317 100644 (file)
@@ -9,6 +9,9 @@ set postponed    = "+gmail/drafts"  # drafts folder
 unset record                        # do not move sent msgs to a folder, gmail does that
 unset move                          # do not move read msgs, gmail does that
 
 unset record                        # do not move sent msgs to a folder, gmail does that
 unset move                          # do not move read msgs, gmail does that
 
+# goobook
+set query_command = "goobook query '%s'"
+
 mailboxes "+gmail/inbox"
 mailboxes "+gmail/sent"
 mailboxes "+gmail/youtube"
 mailboxes "+gmail/inbox"
 mailboxes "+gmail/sent"
 mailboxes "+gmail/youtube"
index 553b7e5b6fbc65cdf524683b78932ad98dd3e0a8..23ad79647aea1c69e1a3ef4e12b832f6b45e8d69 100644 (file)
@@ -9,6 +9,9 @@ set postponed    = "+office365/drafts"  # drafts folder
 unset record                        # do not move sent msgs to a folder, gmail does that
 unset move                          # do not move read msgs, gmail does that
 
 unset record                        # do not move sent msgs to a folder, gmail does that
 unset move                          # do not move read msgs, gmail does that
 
+# office365
+set query_command = "office365-book"
+
 mailboxes "+office365/inbox"
 mailboxes "+office365/sent"
 mailboxes "+office365/archive"
 mailboxes "+office365/inbox"
 mailboxes "+office365/sent"
 mailboxes "+office365/archive"
index 62b273c33c4fec54387cd1b4340bf814a76df61e..18cdb1d32dd97d17ba576cc0cfc6c287014ddf62 100644 (file)
@@ -24,9 +24,6 @@ set date_format  = "!%b %d, %Y at %-H:%M" # use 24-hour clock
 # send clacks
 my_hdr X-Clacks-Overhead: GNU Terry Pratchett
 
 # send clacks
 my_hdr X-Clacks-Overhead: GNU Terry Pratchett
 
-# goobook
-set query_command = "goobook query '%s'"
-
 # sort/threading
 set sort              = threads
 set sort_aux          = last-date-received
 # sort/threading
 set sort              = threads
 set sort_aux          = last-date-received