<commit_before>Meteor.startup ->
	RocketChat.MessageAction.addButton
		id: 'pin-message'
		icon: 'icon-pin'
		i18nLabel: 'Pin_Message'
		action: (event, instance) ->
			message = @_arguments[1]
			Meteor.call 'pinMessage', message, (error, result) ->
				if error
					return Errors.throw error.reason
		validation: (message) ->
			if message.pinned
				return false

			if !RocketChat.settings.get('Message_AllowPinning')
				return false

			if RocketChat.settings.get('Message_AllowPinningByAnyone') or RocketChat.authz.hasRole Meteor.userId(), 'admin'
				return true

			return room.u?._id is Meteor.userId()
		order: 20

	RocketChat.MessageAction.addButton
		id: 'unpin-message'
		icon: 'icon-pin'
		i18nLabel: 'Unpin_Message'
		action: (event, instance) ->
			message = @_arguments[1]
			Meteor.call 'unpinMessage', message, (error, result) ->
				if error
					return Errors.throw error.reason
		validation: (message) ->
			if not message.pinned
				return false

			if !RocketChat.settings.get('Message_AllowPinning')
				return false

			if RocketChat.settings.get('Message_AllowPinningByAnyone') or RocketChat.authz.hasRole Meteor.userId(), 'admin'
				return true

			return room.u?._id is Meteor.userId()
		order: 20<commit_msg>Combine the first two checks into one to make it more readable<commit_after>Meteor.startup ->
	RocketChat.MessageAction.addButton
		id: 'pin-message'
		icon: 'icon-pin'
		i18nLabel: 'Pin_Message'
		action: (event, instance) ->
			message = @_arguments[1]
			message.pinned = true
			Meteor.call 'pinMessage', message, (error, result) ->
				if error
					return Errors.throw error.reason
		validation: (message) ->
			if message.pinned or not RocketChat.settings.get('Message_AllowPinning')
				return false

			if RocketChat.settings.get('Message_AllowPinningByAnyone') or RocketChat.authz.hasRole Meteor.userId(), 'admin'
				return true

			return room.u?._id is Meteor.userId()
		order: 20

	RocketChat.MessageAction.addButton
		id: 'unpin-message'
		icon: 'icon-pin'
		i18nLabel: 'Unpin_Message'
		action: (event, instance) ->
			message = @_arguments[1]
			message.pinned = false
			Meteor.call 'unpinMessage', message, (error, result) ->
				if error
					return Errors.throw error.reason
		validation: (message) ->
			if not message.pinned or not RocketChat.settings.get('Message_AllowPinning')
				return false

			if RocketChat.settings.get('Message_AllowPinningByAnyone') or RocketChat.authz.hasRole Meteor.userId(), 'admin'
				return true

			console.log 'UNpin-message', '---- is user the room owner', room.u?._id is Meteor.userId()
			return room.u?._id is Meteor.userId()
		order: 21
{'fraction_non_alphanumeric': 0.11666666666666667, 'fraction_numerical': 0.007575757575757576, 'mean_word_length': 3.8458715596330277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3433135', 'n_tokens_mistral': 1040, 'n_tokens_neox': 872, 'n_words': 210}