presence: Eliminate unused mobile-related code.

We had a plan at some point to use this to display a phone icon or
something for users who would receive push notifications if you
messaged them.  IT's not clear that feature was a good idea in any
case, but it certainly shouldn't be synced as presence data; it would
change >100x less often than the rest of presence and so should likely
be synced differently, maybe as a property on user. So it's best to
delete this prototype.
This commit is contained in:
Steve Howell
2020-02-05 14:08:51 +00:00
committed by Tim Abbott
parent 62497b394a
commit 437961fba3
3 changed files with 13 additions and 42 deletions

View File

@@ -14,12 +14,6 @@ const OFFLINE_THRESHOLD_SECS = 140;
const BIG_REALM_COUNT = 250;
const MOBILE_DEVICES = ["Android", "ZulipiOS", "ios"];
function is_mobile(device) {
return MOBILE_DEVICES.indexOf(device) !== -1;
}
exports.is_active = function (user_id) {
if (exports.presence_info[user_id]) {
const status = exports.presence_info[user_id].status;
@@ -49,24 +43,15 @@ exports.get_user_ids = function () {
function status_from_timestamp(baseline_time, info) {
let status = 'offline';
let last_active = 0;
let mobileAvailable = false;
let nonmobileAvailable = false;
_.each(info, function (device_presence, device) {
const age = baseline_time - device_presence.timestamp;
if (last_active < device_presence.timestamp) {
last_active = device_presence.timestamp;
}
if (is_mobile(device)) {
mobileAvailable = device_presence.pushable || mobileAvailable;
}
if (age < OFFLINE_THRESHOLD_SECS) {
switch (device_presence.status) {
case 'active':
if (is_mobile(device)) {
mobileAvailable = true;
} else {
nonmobileAvailable = true;
}
status = device_presence.status;
break;
case 'idle':
@@ -85,7 +70,6 @@ function status_from_timestamp(baseline_time, info) {
}
});
return {status: status,
mobile: !nonmobileAvailable && mobileAvailable,
last_active: last_active };
}
@@ -153,7 +137,6 @@ exports.update_info_for_small_realm = function () {
exports.presence_info[user_id] = {
status: status,
mobile: false,
last_active: undefined,
};
});