mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-17 10:21:31 +00:00
backend
This commit is contained in:
parent
21f9feb516
commit
1bb0b7fce9
@ -462,6 +462,7 @@ export default shield(
|
||||
switchUserRole: isAdmin,
|
||||
markTeaserAsViewed: allow,
|
||||
saveCategorySettings: isAuthenticated,
|
||||
updateOnlineStatus: isAuthenticated,
|
||||
CreateRoom: isAuthenticated,
|
||||
CreateMessage: isAuthenticated,
|
||||
MarkMessagesAsSeen: isAuthenticated,
|
||||
|
||||
@ -54,6 +54,7 @@ export default {
|
||||
},
|
||||
invitedBy: { type: 'relationship', relationship: 'INVITED', target: 'User', direction: 'in' },
|
||||
lastActiveAt: { type: 'string', isoDate: true },
|
||||
lastOnlineStatus: { type: 'string' },
|
||||
createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
|
||||
@ -314,6 +314,26 @@ export default {
|
||||
session.close()
|
||||
}
|
||||
},
|
||||
updateOnlineStatus: async (object, args, context, resolveInfo) => {
|
||||
const { status } = args
|
||||
const {
|
||||
user: { id },
|
||||
} = context
|
||||
|
||||
// Last Online Time is saved as `lastActiveAt`
|
||||
const session = context.driver.session()
|
||||
await session.writeTransaction((transaction) => {
|
||||
return transaction.run(
|
||||
`
|
||||
MATCH (user:User {id: $id})
|
||||
SET user.lastOnlineStatus = $status
|
||||
`,
|
||||
{ id, status },
|
||||
)
|
||||
})
|
||||
|
||||
return true
|
||||
},
|
||||
},
|
||||
User: {
|
||||
email: async (parent, params, context, resolveInfo) => {
|
||||
|
||||
4
backend/src/schema/types/enum/OnlineStatus.gql
Normal file
4
backend/src/schema/types/enum/OnlineStatus.gql
Normal file
@ -0,0 +1,4 @@
|
||||
enum OnlineStatus {
|
||||
online
|
||||
away
|
||||
}
|
||||
@ -224,6 +224,8 @@ type Mutation {
|
||||
switchUserRole(role: UserRole!, id: ID!): User
|
||||
|
||||
saveCategorySettings(activeCategories: [String]): Boolean
|
||||
|
||||
updateOnlineStatus(status: OnlineStatus!): Boolean!
|
||||
|
||||
requestPasswordReset(email: String!): Boolean!
|
||||
resetPassword(email: String!, nonce: String!, newPassword: String!): Boolean!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user