Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 221b379

Browse files
authored
Merge pull request #2685 from withspectrum/2.2.3
2.2.3
2 parents 8b4dd44 + 90b2c8b commit 221b379

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

Diff for: api/authentication.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ const init = () => {
274274
async (req, token, tokenSecret, profile, done) => {
275275
const name =
276276
profile.displayName || profile.username || profile._json.name || '';
277+
278+
const splitProfileUrl = profile.profileUrl.split('/');
279+
const fallbackUsername = splitProfileUrl[splitProfileUrl.length - 1];
280+
const githubUsername =
281+
profile.username || profile._json.login || fallbackUsername;
282+
277283
if (req.user) {
278284
// if a user exists in the request body, it means the user is already
279285
// authed and is trying to connect a github account. Before we do so
@@ -284,6 +290,23 @@ const init = () => {
284290
// 1
285291
// if the user already has a githubProviderId, don't override it
286292
if (req.user.githubProviderId) {
293+
if (!req.user.githubUsername) {
294+
return saveUserProvider(
295+
req.user.id,
296+
'githubProviderId',
297+
profile.id,
298+
{ githubUsername: githubUsername }
299+
)
300+
.then(user => {
301+
done(null, user);
302+
return user;
303+
})
304+
.catch(err => {
305+
done(err);
306+
return null;
307+
});
308+
}
309+
287310
return done(null, req.user);
288311
}
289312

@@ -299,7 +322,7 @@ const init = () => {
299322
req.user.id,
300323
'githubProviderId',
301324
profile.id,
302-
{ githubUsername: profile.username }
325+
{ githubUsername: githubUsername }
303326
)
304327
.then(user => {
305328
done(null, user);
@@ -322,7 +345,7 @@ const init = () => {
322345
fbProviderId: null,
323346
googleProviderId: null,
324347
githubProviderId: profile.id,
325-
githubUsername: profile.username,
348+
githubUsername: githubUsername,
326349
username: null,
327350
name: name,
328351
description: profile._json.bio,

Diff for: api/mutations/message/addMessage.js

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
createParticipantWithoutNotificationsInThread,
1212
} from '../../models/usersThreads';
1313
import addCommunityMember from '../communityMember/addCommunityMember';
14+
import { trackUserThreadLastSeenQueue } from 'shared/bull/queues';
1415
import type { FileUpload } from 'shared/types';
1516

1617
type AddMessageInput = {
@@ -189,6 +190,12 @@ export default async (
189190
isOwner: communityPermissions ? communityPermissions.isOwner : false,
190191
};
191192

193+
trackUserThreadLastSeenQueue.add({
194+
userId: currentUser.id,
195+
threadId: message.threadId,
196+
timestamp: Date.now(),
197+
});
198+
192199
return {
193200
...dbMessage,
194201
contextPermissions,

Diff for: api/subscriptions/message.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,18 @@ module.exports = {
5757
debug(`${moniker} listening to new messages in ${thread}`);
5858
try {
5959
return addMessageListener({
60-
filter: message => message.threadId === thread,
60+
filter: message => {
61+
if (message.threadId === thread) {
62+
trackUserThreadLastSeenQueue.add({
63+
userId: user.id,
64+
threadId: message.threadId,
65+
timestamp: new Date(message.timestamp).getTime() + 100,
66+
});
67+
return true;
68+
}
69+
70+
return false;
71+
},
6172
onError: err => {
6273
// Don't crash the whole API server on error in the listener
6374
console.error(err);

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Spectrum",
3-
"version": "2.2.2",
3+
"version": "2.2.3",
44
"private": true,
55
"devDependencies": {
66
"babel-cli": "^6.24.1",

0 commit comments

Comments
 (0)