-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes for status message text presence issues Added statusText to several api endpoints Changed statusMessage to statusText since that is what it is called everywhere * Fixed slash command for changing status * Fixed the "name is required" issue * Make sure the status is set blank if selecting a default status... we don't want an "online" status when someone is actually offline! * Fixes display of custom status on the room header * Changed the header of DM rooms to query the server for the user status text when it is not found on the internal collection * Changed Custom Status methods to check if the user is logged in * Improved code readability * Fix getting status list before logging in
- Loading branch information
1 parent
0e95941
commit 24ebd2c
Showing
24 changed files
with
232 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Users } from '../../../models/server'; | ||
|
||
export const getStatusText = function(userId) { | ||
if (!userId) { | ||
return undefined; | ||
} | ||
|
||
const fields = { | ||
statusText: 1, | ||
}; | ||
|
||
const options = { | ||
fields, | ||
limit: 1, | ||
}; | ||
|
||
const data = Users.findOneById(userId, options); | ||
return data && data.statusText; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import s from 'underscore.string'; | ||
|
||
import { Users } from '../../../models'; | ||
import { Notifications } from '../../../notifications'; | ||
import { hasPermission } from '../../../authorization'; | ||
import { RateLimiter } from '../lib'; | ||
|
||
// mirror of object in /imports/startup/client/listenActiveUsers.js - keep updated | ||
const STATUS_MAP = { | ||
offline: 0, | ||
online: 1, | ||
away: 2, | ||
busy: 3, | ||
}; | ||
|
||
export const _setStatusText = function(userId, statusText) { | ||
statusText = s.trim(statusText); | ||
if (statusText.length > 120) { | ||
statusText = statusText.substr(0, 120); | ||
} | ||
|
||
if (!userId) { | ||
return false; | ||
} | ||
|
||
const user = Users.findOneById(userId); | ||
|
||
// User already has desired statusText, return | ||
if (user.statusText === statusText) { | ||
return user; | ||
} | ||
|
||
// Set new statusText | ||
Users.updateStatusText(user._id, statusText); | ||
user.statusText = statusText; | ||
|
||
Notifications.notifyLogged('user-status', [ | ||
user._id, | ||
user.username, | ||
STATUS_MAP[user.status], | ||
statusText, | ||
]); | ||
|
||
return true; | ||
}; | ||
|
||
export const setStatusText = RateLimiter.limitFunction(_setStatusText, 1, 60000, { | ||
0() { | ||
// Administrators have permission to change others status, so don't limit those | ||
return !Meteor.userId() || !hasPermission(Meteor.userId(), 'edit-other-user-info'); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.