Merge pull request #196 from nickago/MM-1058

MM-1058 Added last updated for pictures
Этот коммит содержится в:
Christopher Speller
2015-07-17 09:44:51 -04:00
родитель 3f328546f8 1fe86a004e
Коммит f49fccdee3
5 изменённых файлов: 16 добавлений и 6 удалений

Просмотреть файл

@@ -729,7 +729,7 @@ func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
Srv.Store.User().UpdateUpdateAt(c.Session.UserId) Srv.Store.User().UpdateLastPictureUpdate(c.Session.UserId)
c.LogAudit("") c.LogAudit("")
} }

Просмотреть файл

@@ -45,6 +45,7 @@ type User struct {
Props StringMap `json:"props"` Props StringMap `json:"props"`
NotifyProps StringMap `json:"notify_props"` NotifyProps StringMap `json:"notify_props"`
LastPasswordUpdate int64 `json:"last_password_update"` LastPasswordUpdate int64 `json:"last_password_update"`
LastPictureUpdate int64 `json:"last_picture_update"`
} }
// IsValid validates the user and returns an error if it isn't configured // IsValid validates the user and returns an error if it isn't configured

Просмотреть файл

@@ -37,6 +37,7 @@ func NewSqlUserStore(sqlStore *SqlStore) UserStore {
} }
func (s SqlUserStore) UpgradeSchemaIfNeeded() { func (s SqlUserStore) UpgradeSchemaIfNeeded() {
s.CreateColumnIfNotExists("Users","LastPictureUpdate", "LastPasswordUpdate", "bigint(20)", "0")
} }
func (us SqlUserStore) CreateIndexesIfNotExists() { func (us SqlUserStore) CreateIndexesIfNotExists() {
@@ -120,6 +121,7 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha
user.AuthData = oldUser.AuthData user.AuthData = oldUser.AuthData
user.Password = oldUser.Password user.Password = oldUser.Password
user.LastPasswordUpdate = oldUser.LastPasswordUpdate user.LastPasswordUpdate = oldUser.LastPasswordUpdate
user.LastPictureUpdate = oldUser.LastPictureUpdate
user.TeamId = oldUser.TeamId user.TeamId = oldUser.TeamId
user.LastActivityAt = oldUser.LastActivityAt user.LastActivityAt = oldUser.LastActivityAt
user.LastPingAt = oldUser.LastPingAt user.LastPingAt = oldUser.LastPingAt
@@ -150,13 +152,15 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha
return storeChannel return storeChannel
} }
func (us SqlUserStore) UpdateUpdateAt(userId string) StoreChannel { func (us SqlUserStore) UpdateLastPictureUpdate(userId string) StoreChannel {
storeChannel := make(StoreChannel) storeChannel := make(StoreChannel)
go func() { go func() {
result := StoreResult{} result := StoreResult{}
if _, err := us.GetMaster().Exec("UPDATE Users SET UpdateAt = ? WHERE Id = ?", model.GetMillis(), userId); err != nil { curTime := model.GetMillis()
if _, err := us.GetMaster().Exec("UPDATE Users SET LastPictureUpdate = ?, UpdateAt = ? WHERE Id = ?", curTime, curTime, userId); err != nil {
result.Err = model.NewAppError("SqlUserStore.UpdateUpdateAt", "We couldn't update the update_at", "user_id="+userId) result.Err = model.NewAppError("SqlUserStore.UpdateUpdateAt", "We couldn't update the update_at", "user_id="+userId)
} else { } else {
result.Data = userId result.Data = userId

Просмотреть файл

@@ -77,7 +77,7 @@ type PostStore interface {
type UserStore interface { type UserStore interface {
Save(user *model.User) StoreChannel Save(user *model.User) StoreChannel
Update(user *model.User, allowRoleUpdate bool) StoreChannel Update(user *model.User, allowRoleUpdate bool) StoreChannel
UpdateUpdateAt(userId string) StoreChannel UpdateLastPictureUpdate(userId string) StoreChannel
UpdateLastPingAt(userId string, time int64) StoreChannel UpdateLastPingAt(userId string, time int64) StoreChannel
UpdateLastActivityAt(userId string, time int64) StoreChannel UpdateLastActivityAt(userId string, time int64) StoreChannel
UpdateUserAndSessionActivity(userId string, sessionId string, time int64) StoreChannel UpdateUserAndSessionActivity(userId string, sessionId string, time int64) StoreChannel

Просмотреть файл

@@ -820,6 +820,7 @@ var GeneralTab = React.createClass({
client.uploadProfileImage(formData, client.uploadProfileImage(formData,
function(data) { function(data) {
this.submitActive = false; this.submitActive = false;
AsyncClient.getMe();
window.location.reload(); window.location.reload();
}.bind(this), }.bind(this),
function(err) { function(err) {
@@ -989,7 +990,7 @@ var GeneralTab = React.createClass({
<SettingPicture <SettingPicture
title="Profile Picture" title="Profile Picture"
submit={this.submitPicture} submit={this.submitPicture}
src={"/api/v1/users/" + user.id + "/image"} src={"/api/v1/users/" + user.id + "/image?time=" + user.last_picture_update}
server_error={server_error} server_error={server_error}
client_error={client_error} client_error={client_error}
updateSection={function(e){self.updateSection("");e.preventDefault();}} updateSection={function(e){self.updateSection("");e.preventDefault();}}
@@ -1000,10 +1001,14 @@ var GeneralTab = React.createClass({
); );
} else { } else {
var minMessage = "Click Edit to upload an image.";
if (user.last_picture_update) {
minMessage = "Image last updated " + utils.displayDate(user.last_picture_update)
}
pictureSection = ( pictureSection = (
<SettingItemMin <SettingItemMin
title="Profile Picture" title="Profile Picture"
describe="Picture inside." describe={minMessage}
updateSection={function(){self.updateSection("picture");}} updateSection={function(){self.updateSection("picture");}}
/> />
); );