Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
ec609a38
Commit
ec609a38
authored
May 25, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refetch VCards which we couldn't retrieve before
parent
ab4d0204
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
src/converse-vcard.js
src/converse-vcard.js
+15
-8
tests/mock.js
tests/mock.js
+6
-2
No files found.
src/converse-vcard.js
View file @
ec609a38
// Converse.js
// Converse.js
// http://conversejs.org
// http://conversejs.org
//
//
// Copyright (c) 201
2
-2018, the Converse.js developers
// Copyright (c) 201
3
-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2)
// Licensed under the Mozilla Public License (MPLv2)
(
function
(
root
,
factory
)
{
(
function
(
root
,
factory
)
{
...
@@ -68,7 +68,9 @@
...
@@ -68,7 +68,9 @@
'
image_type
'
:
_
.
get
(
vcard
.
querySelector
(
'
PHOTO TYPE
'
),
'
textContent
'
),
'
image_type
'
:
_
.
get
(
vcard
.
querySelector
(
'
PHOTO TYPE
'
),
'
textContent
'
),
'
url
'
:
_
.
get
(
vcard
.
querySelector
(
'
URL
'
),
'
textContent
'
),
'
url
'
:
_
.
get
(
vcard
.
querySelector
(
'
URL
'
),
'
textContent
'
),
'
role
'
:
_
.
get
(
vcard
.
querySelector
(
'
ROLE
'
),
'
textContent
'
),
'
role
'
:
_
.
get
(
vcard
.
querySelector
(
'
ROLE
'
),
'
textContent
'
),
'
email
'
:
_
.
get
(
vcard
.
querySelector
(
'
EMAIL USERID
'
),
'
textContent
'
)
'
email
'
:
_
.
get
(
vcard
.
querySelector
(
'
EMAIL USERID
'
),
'
textContent
'
),
'
vcard_updated
'
:
moment
().
format
(),
'
vcard_error
'
:
undefined
};
};
}
}
if
(
result
.
image
)
{
if
(
result
.
image
)
{
...
@@ -82,7 +84,11 @@
...
@@ -82,7 +84,11 @@
function
onVCardError
(
_converse
,
jid
,
iq
,
errback
)
{
function
onVCardError
(
_converse
,
jid
,
iq
,
errback
)
{
if
(
errback
)
{
if
(
errback
)
{
errback
({
'
stanza
'
:
iq
,
'
jid
'
:
jid
});
errback
({
'
stanza
'
:
iq
,
'
jid
'
:
jid
,
'
vcard_error
'
:
moment
().
format
()
});
}
}
}
}
...
@@ -141,7 +147,10 @@
...
@@ -141,7 +147,10 @@
'
get
'
(
model
,
force
)
{
'
get
'
(
model
,
force
)
{
if
(
_
.
isString
(
model
))
{
if
(
_
.
isString
(
model
))
{
return
getVCard
(
_converse
,
model
);
return
getVCard
(
_converse
,
model
);
}
else
if
(
!
model
.
get
(
'
vcard_updated
'
)
||
force
)
{
}
else
if
(
force
||
!
model
.
get
(
'
vcard_updated
'
)
||
!
moment
(
model
.
get
(
'
vcard_error
'
)).
isSame
(
new
Date
(),
"
day
"
))
{
const
jid
=
model
.
get
(
'
jid
'
);
const
jid
=
model
.
get
(
'
jid
'
);
if
(
!
jid
)
{
if
(
!
jid
)
{
throw
new
Error
(
"
No JID to get vcard for!
"
);
throw
new
Error
(
"
No JID to get vcard for!
"
);
...
@@ -155,10 +164,8 @@
...
@@ -155,10 +164,8 @@
'
update
'
(
model
,
force
)
{
'
update
'
(
model
,
force
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
get
(
model
,
force
).
then
((
vcard
)
=>
{
this
.
get
(
model
,
force
).
then
((
vcard
)
=>
{
model
.
save
(
_
.
extend
(
delete
vcard
[
'
stanza
'
]
_
.
pick
(
vcard
,
[
'
fullname
'
,
'
nickname
'
,
'
email
'
,
'
url
'
,
'
role
'
,
'
image_type
'
,
'
image
'
,
'
image_hash
'
]),
model
.
save
(
vcard
);
{
'
vcard_updated
'
:
moment
().
format
()}
));
resolve
();
resolve
();
});
});
});
});
...
...
tests/mock.js
View file @
ec609a38
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
var
_
=
converse
.
env
.
_
;
var
_
=
converse
.
env
.
_
;
var
Promise
=
converse
.
env
.
Promise
;
var
Promise
=
converse
.
env
.
Promise
;
var
Strophe
=
converse
.
env
.
Strophe
;
var
Strophe
=
converse
.
env
.
Strophe
;
var
moment
=
converse
.
env
.
moment
;
var
$iq
=
converse
.
env
.
$iq
;
var
$iq
=
converse
.
env
.
$iq
;
var
mock
=
{};
var
mock
=
{};
...
@@ -99,6 +100,7 @@
...
@@ -99,6 +100,7 @@
},
settings
||
{}));
},
settings
||
{}));
_converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
_converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
_converse
.
api
.
vcard
.
get
=
function
(
model
,
force
)
{
_converse
.
api
.
vcard
.
get
=
function
(
model
,
force
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
jid
;
let
jid
;
...
@@ -120,11 +122,13 @@
...
@@ -120,11 +122,13 @@
}
}
var
vcard
=
$iq
().
c
(
'
vCard
'
).
c
(
'
FN
'
).
t
(
fullname
).
nodeTree
;
var
vcard
=
$iq
().
c
(
'
vCard
'
).
c
(
'
FN
'
).
t
(
fullname
).
nodeTree
;
var
result
=
{
var
result
=
{
'
stanza
'
:
vcard
,
'
vcard
'
:
vcard
,
'
fullname
'
:
_
.
get
(
vcard
.
querySelector
(
'
FN
'
),
'
textContent
'
),
'
fullname
'
:
_
.
get
(
vcard
.
querySelector
(
'
FN
'
),
'
textContent
'
),
'
image
'
:
_
.
get
(
vcard
.
querySelector
(
'
PHOTO BINVAL
'
),
'
textContent
'
),
'
image
'
:
_
.
get
(
vcard
.
querySelector
(
'
PHOTO BINVAL
'
),
'
textContent
'
),
'
image_type
'
:
_
.
get
(
vcard
.
querySelector
(
'
PHOTO TYPE
'
),
'
textContent
'
),
'
image_type
'
:
_
.
get
(
vcard
.
querySelector
(
'
PHOTO TYPE
'
),
'
textContent
'
),
'
url
'
:
_
.
get
(
vcard
.
querySelector
(
'
URL
'
),
'
textContent
'
)
'
url
'
:
_
.
get
(
vcard
.
querySelector
(
'
URL
'
),
'
textContent
'
),
'
vcard_updated
'
:
moment
().
format
(),
'
vcard_error
'
:
undefined
};
};
resolve
(
result
);
resolve
(
result
);
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment